Wednesday, January 31, 2018

physics - Spaceship acceleration for following waypoints


I'm creating a turn based space ship strategy game with simultaneous turn resolution similar to Steam Birds. After all the orders are given, the ships run through a real time simulation where they rotate, accelerate and shoot each other.


The physics work similar to the old asteroids game. At the beginning of each turn the ships can be given a constant acceleration, they will then rotate into position so that their engines will be pushing them in the acceleration direction, and they will maintain the acceleration for the rest of the turn. Each ship has a maximum acceleration value based on their engine strength and mass.


I'm having trouble calculating the proper accelerations for the AI ships to get them to go where they need to go.


I had a diagram here, but this video makes it much more clear what I'm trying to do. This is a player controlled ship moving through some asteroids in the same way I need an AI ship to move.


I've got a ship moving through some obstacles, there are waypoints defined that will guide the ship through the obstacles. There are a couple of things I'm trying to calculate:



  • I need to calculate how much the ship has to slow down to make a fairly tight turn so that it doesn't run into obstacles


  • I need to calculate the acceleration to get the ship to change directions at the waypoint, again making sure that the turn is fairly tight

  • Between the waypoints I would like the ship to accelerate to as high a speed as it can and still have time to slow down to make the turn


Any help here would be greatly appreciated. Thanks.



Answer



I'm going to assume that the rotation of the engine is purely visual, and the acceleration during any thrust is in a constant direction. (If we're accelerating in a rotating direction, the math for planning the trajectory gets a LOT more complicated very quickly, so I'd recommend turning off the thruster when turning, and just accounting for that as a linear segment in the path)


Quadratic Bézier curves are isomorphic to a point moving with constant acceleration, so you can think of this problem as a matter of planning a quadratic Bézier spline under certain constraints.


At the beginning of each turn, two of your control points are fixed, and you're making a choice for the third point (unless the ship is allowed to coast without acceleration for a span, that is - then add another two variables for pre-thrust and post-thrust drift)


Planning thrust


Point A is where the ship begins this turn.



Point B is where the ship would be halfway through the turn if it were not thrusting. If one turn is T simulation-seconds long, then this is A + (T/2)*v1, where v1 is the velocity of the ship at the start of the turn.


Point D (not part of the curve) is where the ship would end the turn with zero acceleration. It acts as an anchor for our choice of point C...


Now we get to choose point C, where the ship will be at the end of the turn. We can select any point in a radius of (T*T/2)*max_acceleration of D. This ensures our max acceleration constraint is respected. Our velocity coming out of this turn will be parallel to C-B (specifically, it will be (C-B)*2/T).


From this, a few things follow:




  1. If we want to come out of the turn with a velocity in a particular direction (say, we've passed one waypoint and want to steer toward the next one), we can draw a line with that direction through point B. The part of that line that overlaps the circle around D includes all our options that put us on the desired trajectory, with the one furthest from B being the fastest option.




  2. The turn is fully-contained within the triangle ABC, so we can check that triangle for collisions and re-plan as necessary.





  3. If the radius of the circle is r = max_acceleration * (T*T/2), then the maximum angular change we can effect in one turn is:


    180° if (T/2)*v1.magnitude <= r


    asin(r/((T/2)*v1.magnitude)) = asin(T * max_acceleration/v_1) otherwise




So, if you need to pivot through an angle of theta in one turn, slow down to (2 * r)/(T * sin(theta)).


If you're still n turns away from this rotation, then you can safely travel up to nmax_accelerationT faster than this limit and still slow down in time. If you're going faster than that, start braking.


Note that you can apply this recursively to get the AI thinking one or more steps ahead - any choice for point C this turn dictates A, B, and D next turn. So you can choose C this turn in such a way that the circle around next turn's D includes next turn's goal, and reject choices of C that take you too far off course even with a full turn to correct it.



There are still a lot of judgement calls for you to make in designing your AI, but I hope this provides a useful framework for making those decisions in a way that's appropriate for your game.


exam questions - Why "the" should be used before 'truth'


Please identify and explain error in the following sentence


After knowing truth , (1)/they took the right decision (2) / in the matter (3)/No error (4).


Also , Is it correct to use 'ing' form of 'know' here?





prepositions - Sleep in bed or sleep on bed



From the Faraway Tree



They showed him the bed he was to sleep on.



And



Dick peered in at his window and saw the big owl asleep on a bed.




Considering this answer what context should I understand by the above sentence?


https://ell.stackexchange.com/a/20115/5198



Answer



Both "in" and "on" are possible.


When you are under the covers, you're "in bed". When you are shown to a bedroom where you will be spending the night, you're shown the bed you will "lie on" or "sleep on" or "sleep in".


I would choose "on" if I were shown to a cot, not a full bed.


The hotel room was small and since there were five of us, we had to sleep on cots.


So "on" could imply something like a cot.


Most Americans, I think, would also use "on" if complaining about the mattress or thinking of the bed in terms of its mattress. Some mattresses look as though they will deliver an unpleasant night's sleep.



I'd like to speak to the manager! This room was quite expensive, and yet the mattress was terribly uncomfortable. The springs were poking me and I couldn't get to sleep on that old bed!


Tuesday, January 30, 2018

modal verbs - Would used for willingness in the present


In Macmillan would has such usage Source


used when you think someone is willing to do something

Bruce would lend you the money, I'm sure.


I thought this usage is only for willingness in the past. Now it can refer to the present!


I wonder if this usage is common in everyday speech (both British and American). If I substitute "could", "will" or "might" for "would", will this bring any subtle differences?



Answer



The usages of "would" are almost endless. Even though one definition of the word is a past tense of "will", in this case it is more like a prediction, almost "future tense". Read Merriam Webster's Definition


"You know Bruce would loan you the money, just ASK for it!"


"Bruce is running for Governor. He would loan you the money if you could get that bill passed."


As to your second question, absolutely. Each of those words could be substituted for "would" and the sentence would have a completely different meaning.


"Could" would say that he has the money, therefore he can lend it to you, but it gives no hint as to whether Bruce would be inclined to do so.


"Will" says that Bruce has the money and will be happy to loan it to you. That Bruce will make the loan is assured.



"Might" is a big question mark. Hmmm, it's worth a shot.


Map tile terrain transitions with 3-4 different types


Making transitions between two different tiles is a fairly well understood problem. The easiest way is to look at the 0.5, 0.5 and use the resulting 4 corner points to select a transition tile, as mentioned here for example: http://playtechs.blogspot.se/2007/04/tileset-design-tip.html


The problem comes when three or four tiles meet, for example:


(s for swamp, p for plains and . for water)


pppp

..sp
..pp

If we look at the offset in the corner, the edges in our transition tile looks like:


pp
.s

In this case there are no suitable transition tiles to be found, as they typically are created to work between 2 types only. Unless we work out a three way transition tile with these types, we appear to be stuck.


I'm well aware of this often referenced article on the tile transitions in Artifact: http://archive.gamedev.net/archive/reference/articles/article934.html


But looking at the actual screenshots from that game, it doesn't seem like it will yield professional looking maps: http://www.samugames.com/artifact/screenshots.htm



Aside from using intermediary tiles (which frankly would be problematic since two out of grassland/swamp/desert would then not be able to border directly to water), are there any solutions?


EDIT


I think I've found a solution that can will create terrain transitions for 3-4 different types, using only one extra transition tile to each set of transition tiles. I've yet to make an implementation of the algorithm, but the mockups look fine. This solution will work well for pixel art.




sentence construction - Got a cold, cure it by yourself?


When a person got a cold, but he didn't want to have any medicine as he believed that it could be got well after having a rest. In this situation, does this sentence below sound natural? Or how would you express this?



He wanted to cure it by himself after he got a cold.




Answer



Firstly, it sounds unnatural to refer to "it" before introducing the word "cold" in your sentence. Secondly, the word "by" is unnecessary. I would phrase the sentence as such:




He got a cold and wanted to cure it himself.



You might also use the word "insist" to emphasize how your subject didn't want to take other people's advice.



He got a cold and insisted on curing it himself.



To make it clear that the subject wanted to get better without the use of medicine, you might also say:



He got a cold and insisted on letting it heal naturally.




Another suggestion from snailboat's comment, which makes it absolutely clear that there was no treatment is involved:



He got a cold and insisted on letting it run its course.



meaning - Is "We are running the red lights" right?


I read the following dialogue which I think is quite weird.





  • Look! Some people are running the red lights.

  • We should wait although others are breaking the rule.



I don't think the sentence "Some people are running the red lights" is correct. Suppose there is a scene: There is the red light, but we still run across the road without stopping. We can't say "we are running the red light", right? So how to say it in an authentic way?



Answer



"Run a red light" is an idiomatic expression which means "to pass through an intersection while the traffic light is red without stopping."


So there is nothing "weird" in that dialogue and, as far as I can tell, using idiomatic English is pretty "authentic" as long as you correctly use it.



(Reference: "Dictionary of American Idioms" by R.A. Spears".)


The idiom is also used in British English along with "jumping a red light". Discussion in the comments revealed that "breaking a red light" is used in Ireland.


meaning - What does this 'where' mean in this context?



“It is an art where you’ve got to deal with the demands of every day but at the same time place it strategically at the heart of what the company is doing.” — Jeroen Tas, group CIO of Philips 5



I have problem in where meaning. I think it mean "what".


EDIT: Does the sentence mean "deal with demands of every day and also place it at the heart of what the company is doing in"?




Answer



This where means "in which".


According to Collins English Dictionary – Complete and Unabridged, 12th Edition 2014 (via The Free Dictionary), under the definition of where:



Usage: It was formerly considered incorrect to use where as a substitute for in which after a noun which did not refer to a place or position, but this use has now become acceptable: we now have a situation where/in which no further action is needed





As for the meaning of the sentence, you got its main idea correctly. (Reading the chat log, I can see that you weren't sure about the structure of the sentence.) You asked, does the sentence mean "deal with demands of every day and also place it at the heart of what the company is doing in"? My answer is yes, more or less.


Here is how you can understand (and parse) the sentence:




It is an art where you’ve got to deal with the demands of every day but at the same time place it strategically at the heart of what the company is doing.


= It is an art. In this art, you've got to [ deal with the demands of every day ] but at the same time [ (you've got to) [ place it strategically at the heart of what the company is doing ] ].



Monday, January 29, 2018

phrase meaning - "I think we're going to have to be chessmen" - what does "be going to" mean here?



They were standing on the edge of a huge chessboard, behind the black chessmen, which were all taller than they were and carved from what looked like black stone. Facing them, way across the chamber, were the white pieces. Harry, Ron and Hermione shivered slightly –– the towering white chessmen had no faces.
"Now what do we do?" Harry whispered.
"It's obvious, isn't it?" said Ron. "We've got to play our way across the room."

Behind the white pieces they could see another door.
"How?" said Hermione nervously.
"I think," said Ron, "we're going to have to be chessmen."
He walked up to a black knight and put his hand out to touch the knight's horse. At once, the stone sprang to life. The horse pawed the ground and the knight turned his helmeted head to look down at Ron.
"Do we –– er –– have to join you to get across?"
The black knight nodded.
(Harry Potter and the Sorcerer's Stone)



Is the auxiliary are going to used to soften the meaning of have to?



Answer




I don't know what you mean by soften here but we're going to definitely goes to put more emphasis on the have to part and that it clearly shows that they really need to be chessmen if they're going to go across the room and that there are no two ways about the whole arrangement.


xna - How should I structure my Tetris clone's code?


I programmed my first game (a Tetris clone in XNA) and all my code is in a Game1.cs file with 730+ SLOC. It's fairly well-commented, and each piece of functionality has its own subroutine, but I have a feeling that I'll have to move toward a more organized approach as my games increase in complexity.


To offer some background, my current approach separates the "view" (the tetrimino sprites visible on the board) from the underlying "data" (represented by an 18x10 bool array), which determines if there is a block at some point on the grid. In other words, my "data" determines my "view." Also, here's a list of all my subroutines:


Game1()

Initialize()
LoadContent()
UnloadContent()
GetBlockType()
IsFreeBlock()
IsPossibleMovement()
GetXInBlocks()
GetYInBlocks()
StorePiece()
DeleteLine()

DeletePossibleLines()
IsGameOver()
ResetBoard()
Update()
Draw()

I hear a lot about game components in XNA, which sounds like something that could make my code more organized and extensible. Are there any organizing features of XNA that I could incorporate into my future games?



Answer



I like the component architecture, but for a Tetris-clone it might be overkill. Instead I would just move away from the monolithic Game-class to separate classes. Here's an idea how you could separate into several classes and what methods/properties they could have:


Board

- reset()
- checkCollision(Tetromino)
- canRotate(Tetromino)
- commit(Tetromino)

Tetromino
- get/set position
- rotate()

GameController

- spawnBrick()
- processUserInput()
- increaseSpeed()
- updateBoard()

Renderer
- RenderBoard(Board)

You could also use messaging or events to attach other subsystems. Eg. your Board could send a message when a row was cleared. Then a "SoundController" could listen to this message and play a sound, or your "ScoreManager" could update the score. etc.


Sunday, January 28, 2018

Is there a word in English meaning "see something incorrectly"?



For example, I saw someone just now. I thought he was Jack, but turned out he was not. Or, I saw something and recognized it as something else incorrectly. Is there a word for such situations?


I know if I read something wrongly, I could say "I misread it". and if I hear something wrongly, I could say "I misheard it". But I cannot find the word "missee" in any dictionaries. Is there something else people use?



Answer



Here are my possible answers,



I'm sorry. I thought you were someone/somebody else.
I'm sorry. I mistook you for someone/somebody else.
I'm sorry. I've mistaken you for someone/somebody else.



unity - Adding functionality to make individual anchor points of bezier continuous or non-continuous


I am creating bezier curves with the following code. The curves can be extended to join several bezier curves by shift clicking in the scene view. My code has functionality for making the whole curve continuous or non-continuous. I realised that I need to make individual points (specifically anchor points) have this functionality.


I believe the most ideal way to go about this is creating a new class for the points with this functionality (making points continuous or non-continuous) since this can be used to add other properties that might be specific to the points. How can do this?


Path



[System.Serializable]
public class Path {

[SerializeField, HideInInspector]
List points;

[SerializeField, HideInInspector]
public bool isContinuous;

public Path(Vector2 centre)

{
points = new List
{
centre+Vector2.left,
centre+(Vector2.left+Vector2.up)*.5f,
centre + (Vector2.right+Vector2.down)*.5f,
centre + Vector2.right
};
}


public Vector2 this[int i]
{
get
{
return points[i];
}
}

public int NumPoints
{

get
{
return points.Count;
}
}

public int NumSegments
{
get
{

return (points.Count - 4) / 3 + 1;
}
}

public void AddSegment(Vector2 anchorPos)
{
points.Add(points[points.Count - 1] * 2 - points[points.Count - 2]);
points.Add((points[points.Count - 1] + anchorPos) * .5f);
points.Add(anchorPos);
}


public Vector2[] GetPointsInSegment(int i)
{
return new Vector2[] { points[i * 3], points[i * 3 + 1], points[i * 3 + 2], points[i * 3 + 3] };
}

public void MovePoint(int i, Vector2 pos)
{

if (isContinuous)

{

Vector2 deltaMove = pos - points[i];
points[i] = pos;

if (i % 3 == 0)
{
if (i + 1 < points.Count)
{
points[i + 1] += deltaMove;

}
if (i - 1 >= 0)
{
points[i - 1] += deltaMove;
}
}
else
{
bool nextPointIsAnchor = (i + 1) % 3 == 0;
int correspondingControlIndex = (nextPointIsAnchor) ? i + 2 : i - 2;

int anchorIndex = (nextPointIsAnchor) ? i + 1 : i - 1;

if (correspondingControlIndex >= 0 && correspondingControlIndex < points.Count)
{
float dst = (points[anchorIndex] - points[correspondingControlIndex]).magnitude;
Vector2 dir = (points[anchorIndex] - pos).normalized;
points[correspondingControlIndex] = points[anchorIndex] + dir * dst;
}
}
}

}

else {
points[i] = pos;
}
}

PathCreator


public class PathCreator : MonoBehaviour {


[HideInInspector]
public Path path;


public void CreatePath()
{
path = new Path(transform.position);
}
}


PathEditor


[CustomEditor(typeof(PathCreator))]
public class PathEditor : Editor {

PathCreator creator;
Path path;

public override void OnInspectorGUI()
{
base.OnInspectorGUI();

EditorGUI.BeginChangeCheck();

bool continuousControlPoints = GUILayout.Toggle(path.isContinuous, "Set Continuous Control Points");
if (continuousControlPoints != path.isContinuous)
{
Undo.RecordObject(creator, "Toggle set continuous controls");
path.isContinuous = continuousControlPoints;
}

if (EditorGUI.EndChangeCheck())

{
SceneView.RepaintAll();
}
}

void OnSceneGUI()
{
Input();
Draw();
}


void Input()
{
Event guiEvent = Event.current;
Vector2 mousePos = HandleUtility.GUIPointToWorldRay(guiEvent.mousePosition).origin;

if (guiEvent.type == EventType.MouseDown && guiEvent.button == 0 && guiEvent.shift)
{
Undo.RecordObject(creator, "Add segment");
path.AddSegment(mousePos);

}
}

void Draw()
{

for (int i = 0; i < path.NumSegments; i++)
{
Vector2[] points = path.GetPointsInSegment(i);
Handles.color = Color.black;

Handles.DrawLine(points[1], points[0]);
Handles.DrawLine(points[2], points[3]);
Handles.DrawBezier(points[0], points[3], points[1], points[2], Color.green, null, 2);
}

Handles.color = Color.red;
for (int i = 0; i < path.NumPoints; i++)
{
Vector2 newPos = Handles.FreeMoveHandle(path[i], Quaternion.identity, .1f, Vector2.zero, Handles.CylinderHandleCap);
if (path[i] != newPos)

{
Undo.RecordObject(creator, "Move point");
path.MovePoint(i, newPos);
}
}
}

void OnEnable()
{
creator = (PathCreator)target;

if (creator.path == null)
{
creator.CreatePath();
}
path = creator.path;
}
}


Saturday, January 27, 2018

sentence construction - Could you help me finding some less colloquial equivalent to highlighted phrases of this speech



Today I want to be able to give you some good tips on parallel parking. It's part of your road test. It's something you need to learn. For most new drivers it's real difficult, because they're not able to judge angles. And parallel parking is all about angles. I'll take you through a typical parking, I'll take you through how I teach it , and maybe that'll help you in passing your road test. The first thing you want to do is you want to pull over over and you want to stop alongside a parked car. Typically, an inspector will give you a command to pull over, stop next to the red or blue car. You're just going to pull over, put your blinker on to the right, and pull over even with that car.





  • taken from a series of videos teaching driving





    1. Why did the man use be able in his speech? What is the difference between be able and I would like to or I want ? I mean what the listener should make of I want to be able to give you ... . Why did not he say I want to give you... ?




    2. When he says I'll take you through a typical parking , I get the meaning of take one through ,It means I am going to teach you , isn't it? But my real concern is what the second I'll take you through means, while saying I'll take you through how I teach it . Perhaps it doesn't mean I will teach you that how I teach it ! , does it?




    3. The man always says the first thing you want to do . Why does not he say the first thing you should do , the first thing you need to do ? What are the diffrences in meaning? Isn't it unnatural saying you want to do ?




    4. In the last sentence he says You're just going to pull over, is the use of going to just weakening would and will? I think here it means something else. I think it means you just want to or you just start









Friday, January 26, 2018

path finding - Pathfinding: Tile-Based Navigation Mesh


I'm developing a real time, tile-based RTS. This is an example map:


Map


This map consists of 4 regions with 256 tiles each. Blue tiles represent obstacles. Units can move in the standard eight directions. Units are bound to tiles; one tile can hold one unit.


These are some examples of the ideal paths I'm looking for. Typical A* stuff:


enter image description here


My question is: Is a navigation mesh applicable to a tile-based RTS? I've only seen navigation maps used in games where units are free-moving and not bound to a grid of tiles. What would the navigation mesh look like on this particular map? An example image would be excellent.




Answer



Yes, navigation meshes are still applicable to tile based games. Although, they would primarily be used as a optimization. For example, I've converted the lower left of your image to use a navigation mesh:


enter image description here


In this case, each green square would be a navigation node. As you can see, this drastically reduces the number of nodes that A* needs to process. Units can then simply path to the center of each of these nodes.


The generation of these nodes is a different issue. It can be complex deciding how to form the nodes. There's a few questions on the site where you might find some ideas on how you'd like to implement that:


Subdividing a polygon into boxes of varying size


Identifying quad patterns in a two-dimensional array


https://stackoverflow.com/questions/20220215/minimum-number-of-rectangles-in-shape-made-from-rectangles


This navigation mesh can also essentially be used as a "first pass" path finding. If a path is found through the navigation mesh, you know that a path exists. This is a faster test to see if two points are connected.


unity - 2D bouncing formula doesn't work properly


I am new to Unity, and I am trying to create a bouncing ball, so I've been researching bouncing related physics and I found a formula:


Formula:


-2*(V dot N)*N + V

Where V is the velocity vector and N is the normal of the surface on which the ball will bounce



Here is my script :


using UnityEngine;

using System.Collections;

public class BallPhysics : MonoBehaviour {



void Start () {

rigidbody2D.velocity =new Vector2 (-1,-3);

}

// Update is called once per frame
void Update () {

}
void OnTriggerEnter2D(Collider2D col) {


if (col.gameObject.name == "Pong") {
tBounce ();
}


}

void tBounce(){
RaycastHit2D hit = Physics2D.Raycast (new Vector2 (transform.position.x,transform.position.y), rigidbody2D.velocity);
Vector2 n = hit.normal;

Vector2 v = rigidbody2D.velocity;
Vector2 R = -2 * (Vector2.Dot (v, n)) * n + v;
rigidbody2D.velocity = R;
}
}

I am giving the ball a velocity vector in the start function, i am using OnTriggerEnter2D for collision handling and raycast2D to get the normal of a surface.


The problem is that the script doesn't reflect the velocity vector called R, I think the problem is in the normal vector.


For example let's say V is a Vector2(-1,-1) so basically R should be (-1,1), but it's not. R is (3,1) !


I've successfully been able to make a ball bouncing on Horizontal/vertical surface by reversing the ball velocity but this won't work properly with arbitrary angles, that's why I am using this formula. So what's the problem ?





Pronunciation of -ies, like the last syllable of "accessories" and "bees" in BrE



Accessory noun BrE /əkˈsesəri/




What is the pronunciation of the last syllable of accessories?



  1. / r iː z /




  2. / r i z /





  3. / r ɪ z /




My guess is 3. / r ɪ z /



Bee noun BrE /biː/



What is the pronunciation of the last syllable of bees?




  1. / b iː z /




  2. / b i z /




  3. / b ɪ z /





My guess is 1. / b iː z /



Answer



This is partly a matter of variation between accents, and partly just an arbitrary matter of "choosing a transcription system."


The variation is in the final vowel of "accessory." As I describe in this answer, the vowel here can be identified with either the vowel of "kit" or the vowel of "fleece" depending on the accent. The pronunciation tutor Geoff Lindsey has a blog article, "The fallac[ɪj]of schwee," where he recommends that English language learners use the vowel of "fleece" for this sound even if you're trying to use a British accent.


The vowel in "bee" is always the same as the vowel in "fleece."


Transcription systems


There are many IPA transcription systems for English. As John Wells explains in the linked article, one type, the "qualitative scheme," does not use the length marker /ː/. In this scheme, the "fleece" vowel is transcribed /i/, and the "kit" vowel is transcribed /ɪ/. The last syllables of "accessories" and "bees" would be transcribed /riz/ and /biz/ or /rɪz/ and /biz/ depending on the accent of the speaker.


Another type, the "quantitative-qualitative scheme," uses the length marker to distinguish "quantity." In this scheme, the "fleece" vowel is transcribed /iː/, and the "kit" vowel is transcribed /ɪ/. The last syllables of "accessories" and "bees" would be transcribed /riːz/ and /biːz/ or /rɪz/ and /biːz/ depending on the accent of the speaker... at least, that's probably the best phonemic transcription (although apparently some phonologists, such as Dwight Bollinger, do treat "weak" vowels as distinct phonemes).


The complicated part is that even for phonologists who only recognize two vowel phonemes in this region, the use of the length marker allows us to cover the two accents with a single transcription using a kind of "shortcut": /i/, which is not used otherwise in the quantitative-qualitative scheme, can be defined as "/ɪ/ for some speakers, and /iː/ for others." This is called a "diaphonemic transcription." It is convenient in some ways, but it can also be confusing. This would give us the transcriptions /riz/ and /biːz/.



As an English language learner, you should avoid thinking of this /i/ as a third vowel that has to be distinguished in pronunciation from /ɪ/ and /iː/. It would be more accurate to think of it as not being distinguished from either of them, but that's still an unnecessary complication: as Geoff Lindsey says, it's simple and correct to just pronounce it exactly the same as /iː/.


Phonetic realization


Phonetically, Lindsey says the British English vowel /iː/ can vary between more-or-less monophthongal [i] and more diphthongized pronunciations like [ɪj].


opengl - Multiplatform GLSL shader validator?


Im working on a multiplatform (Pc,Mac,Linux) game that uses shaders quite extensively. Since we do not have any funding, it is pretty hard to test our game on all possible hardware configurations.


While our engine seems to run fine on different platforms, its usually the slight differences in GLSL compiling that gives us headaches. We have things set up such that we can test the shaders on Ati/Nvidia cards, but since the new Macbooks have Intel graphics, I'm really looking for a tool that can simply validate my GLSL shaders for different hardware without the need of yet another system.


Does anyone know such a tool?



Answer



The GLSL specification defines how the language works. If you write a shader that conforms to that specification, and it does not work on a particular OpenGL implementation, then that OpenGL implementation has a bug in it. Which means that you are effectively asking for a tool that can reproduce the bugs in Apple's Intel drivers.


That is pretty much impossible. To do that, someone would have to have a list of every bug for every driver revision in Apple's Intel graphics drivers. Even if someone tried to get a list of those bugs and wrote a parser that reproduced them, that wouldn't guarantee you anything, since there could always be new bugs introduced. Or the "validator" could have implemented those bugs incorrectly.


The best you can hope for would be a shader validator that could tell if your GLSL shader conformed to the specification. But that's about it.


grammar - Usage of 'Only'


What are the differences in the following sentences:



(1)I eat burger and pizza only.(My understanding is he doesn't eat anything > except burger and pizza)


(2)I eat only burger and pizza.(My understanding is it relates to same concept as no.1)


(3)I only eat burger and pizza.(My understanding is that he only eats burger and pizza ,and do nothing,i.e he doesn't talk,read,walk etc.)


(4)Only I eat burger and pizza.(My understanding is that he has the copyright to eat burger and pizza)




Are my understandings correct?


Many people use only in a wrong way,as there are basic differences.


Please focus on this topic.




Thursday, January 25, 2018

nouns - When is Earth upper case?


I recenty got my essay back from my teacher and she said that it was wrong to use upper case "Earth". When I'm writing Earth, I'm referencing to the planet Earth, not soil. This is the sentence which included "errors". She gave me an error in every word that I marked with strong first letter.



This is why the Moon orbits the Earth, and the Earth orbits the Sun, and the Sun orbits the black hole in the middle of the Milky Way.



Who is right, me or her?




Answer



When talking about the planet Earth, it is a proper noun and is always capitalized. When talking about soil, or dirt, then earth is not capitalized (except when used as part of a title).


Your example sentence is correct. Another example if you need more proof, but there are many more on Google.


Another example using "earth"


[Edit] Apparently some editors are lazy. In common usage, the name of the various celestial bodies is often not capitalized (possibly because apparently it's too hard to reach the "Shift" key). Such is the evolving nature of English in a technological age, lol.


Anyway, this might be a better example -- although I would look specifically at the responses by the "experts" and not the questions themselves.


So a more comprehensive answer is that while perhaps Earth should be capitalized when talking about the planet itself, it often is not. It also may not be capitalized when talking figuratively about a large region of the planet, e.g. "his empire stretched from one side of the earth to the other", or in an idiom like "to the ends of the earth".


java - How do I calculate the distance between a point and a rotated rectangle?


This question is similar to another one about axis-aligned rectangles. However, I specifically want to calculate this for rotated rectangles.




I have a rectangle with a (cx, cy) for the center point and a width, and height, and a (x, y) for the test point, as well as a θ for the angle of rotation.


What's the fastest way to determine the distance between that point, and the nearest edge of the rectangle? If the point is inside the rectangle, the distance should be zero.


I believe that there is going to be only a small change to the equation in the linked question, but I have no idea what it might be.



Answer




Just rotate the point at an angle of -θ around the center of the rectangle.


relx = x-cx
rely = y-cy
rotx = relx*cos(-theta) - rely*sin(-theta)
roty = relx*sin(-theta) + rely*cos(-theta)
dx = max(abs(rotx) - width / 2, 0);
dy = max(abs(roty) - height / 2, 0);
return dx * dx + dy * dy;

Also, remember this is still the distance squared, so you need to take the square root of it to get the actual distance



rts - What data to exchange in multiplayer real time games?



I am a hobbyist programmer and right now I am curious about what data is exchanged in a multiplayer session in real time games like starcraft 2. I did a bunch of searches. I found gafferongames.com offering a very good overview of the issues to consider.


Glenn in his article and comments gives a very strong case for using UDP over TCP, but SC2 obviously uses TCP. To qoute Gleen,



The problem with using TCP for games is that unlike web browsers, or email or most other applications, multiplayer games have a real time requirement on packet delivery. For many parts of your game, for example player input and character positions, it really doesn’t matter what happened a second ago, you only care about the most recent data.



So from his statement, I am guessing that his approach is to send the the full game state of every unit on each frame. If the server does not receive a player input on the current frame, then it's just back luck on that player. For God of War: Acension, in which he is lead network dev, this should work quite well I guess.


For SC2, due to it's replay capability, my gut feeling tells me that the underlying engine is a deterministic fixed timestep "user input playback machine", where the only data exchanged is player inputs. Hence Glenn's statement mybe completely irrelevant for SC2. Player input is important, and input sequence is even more important. I don't think it's feasible for SC2 sending game state of 200 units and more at 30 - 60 FPS.


Question: I could be wrong, but I have attempted to identify 2 possible types of data. What are other techniques? Will be good to qoute the game if you will.


EDIT: found this link about starcraft networking model



Answer





Glenn in his article and comments gives a very strong case for using UDP over TCP, but SC2 obviously uses TCP.



Glenn mostly talks about physics-driven games, ie. first person shooters and driving games. These have different requirements to real time strategy games where precise unit positions at every logic step are important. So the communications strategies are necessarily different.


"Real-time" means different things in different contexts. Games are not 'hard' real time in that if a message is late, the whole thing breaks. (At least, there is no good reason for a game to be so demanding, as a software-only system should be able to recover from processing delays, unlike a nuclear power station or a piece of medical equipment for example.) Games are really 'soft' or 'firm' real time. (Definitions at Wikipedia as usual.) The type of game makes a difference as to how quickly you need the information, whether you can lose information and get away with it, etc. Suffice to say that TCP is good enough for many games, but for other games, UDP is preferable.



I am guessing that his approach is to send the the full game state of every unit on each frame.



He would send enough information to reconstruct the relevant game state of any unit that has changed.




  1. You don't need to send any information about something that has not changed.

  2. You don't need to send the full state if you can send enough information for the recipient to construct the new state from the old state. (eg. Just send a delta value relative to an old state. Or just send the parts of the state that have changed and not the rest.)

  3. If two games run exactly the same algorithm and have exactly the same data then you can just send inputs and the recipient resimulates the effects locally to derive the new state.


Most games don't fulfil the criteria for 3, so they use 1 and 2 instead. Many RTS games however can, and do, make use of 3.


Also, it doesn't necessarily have to be "every frame". The concept of a frame is also nebulous. Is it a frame of rendering? Is it a batch of logic? Is it a frame of network data being sent? Do the three always align one-to-one or do you get variable graphics rate with fixed logic rates? Some games, especially real time strategy games like Starcraft 2, or games with replay ability (as you touch upon) like to keep everything in perfect lockstep by having regular network updates (which may or may not match 'frames' in other senses) but this is not a requirement for all games. Many games just send out updates on a semi-regular basis, depending on how far behind they're willing to let the clients run.



Player input is important, and input sequence is even more important. I don't think it's feasible for SC2 sending game state of 200 units and more at 30 - 60 FPS.



Many games won't necessarily treat a rendering frame as a logical frame. They might have 60FPS in graphics but only have 10 logic updates a second, and send 1 network update for each one. But even 30 network updates per second is reasonable if you use the 'send input' method, certainly.




I have attempted to identify 2 possible types of data. What are other techniques? Will be good to qoute the game if you will.



It's not so much that there are distinct techniques, but several different constraints on the systems, and the importance of each constraint will vary from game to game. So you just have to pick a system that works for you.



  • Few units, moving quickly and erratically via user input, latency is sensitive, exact synchronisation across systems not important - broadcast positions via an unreliable protocol (eg. UDP) to get maximum speed, and missed messages won't matter as a new one will come in soon. Simulate physics locally to improve rendering quality but correct the positions when new information arrives. Good for shooters and driving games.

  • Many units, but most are irrelevant, and they move slowly - only send updates for units near the recipient, send them as changes rather than full states, send them relatively infrequently, and send over a reliable protocol (eg. TCP) to avoid having to worry about how to handle missed updates. Good for MMOs.

  • Many units, moved by the AI based on prior user input, exact synchronisation across systems very important - send time stamped user input over a reliable protocol and resimulate locally to have the game algorithms keep state synchronised. Good for RTSes and turn-based games.


Wednesday, January 24, 2018

'Zoning' up areas on a large tile map, as well as dungeons


My game is having a map like that of Minecraft, in the way it's pseudoinfinite and randomly generated. And big. Say the user has explored a 1000x1000 zone (2D here), so that's 1,000,000 tiles.


Obviously I'm not going to be able to store it all in memory. Nor do I just want to ignore everything out of a 10 tile or whatever radius - both will nothing update (all the NPCs, perhaps reactive tiles) and I would have to work with awkward positions like 1382,12918.


So if I was to split it down into chunks or zones or whatever of say 64x64 tiles, I would have to store each tile and object's position like:




Chunk a,b. Position x, y.



But what if I wanted dungeons and the like in my map? So a single tile that leads to maybe a 40 floor dungeon, each with an area of 40x40. I can't exactly store those in the same map.


And there's the memory side; how much could I potentially store in memory at the same time reasonably? I could do tiles by ID quite easily, and have the normal 2D array there. Or again, is there a more effective solution than having a data file of tile types? So for a 64x64..that's only going to be 20K or whatever. I'd like as much as possible surrounding to be loaded for the most realistic update. But I don't know what sort of limits I can hit without becoming memory hogging.



Answer



While I agree with the sentiment: "don't worry about it unless it's a proven issue", I do think it's worth thinking about early on: retro-fitting a solution is much more painful. And yes, only updating 'nearby' tiles is they way to go. But storage and addressability of items in your game world efficiently is very important for performance reasons.


What you're really thinking about here is a sparse data-set: something where the potential indexes are large (or unlimited), but only a small proportion are actually used. The key point is that you do not know exactly which proportion will be used.


The standard solution to a sparse data-set problem is to separate the index/addressability from the actual data storage. So if the tile object is expensive, then store it in a compact form (e.g. a flat array). But allow it to be indexed through a cheaper object. In its simplest form, this can be a 2D (or 3D) matrix which you can easily index by coordinate, but each item in the matrix is simply an index. You then use that index to look up the actual tile contents in a separate, compact array. If the tile contents do not yet exist, then add them to the end of the array, and store the index in the 3D matrix.


The solution gets more complex if you wish to support deletion of contents (as it leads to fragmentation of the contents array), and if your tile contents are cheap, then the extra weight of the index (32-bit or 64-bit indices) will probably overwhelm the savings from not storing every single potential tile. It's also an extra lookup, which will hurt your cache performance.


You can get even more storage efficiency by introducing extra layers of indirection. Let's say you organise your tiles into chunks, and chunks have a granularity of 64x64x64. Given a tile at 125, 1, 132, you know it belongs in chunk (1,0,2). So you have a world, which consists of a compact chunk array, and a matrix of chunk indices (-1 if the chunk doesn't exist). The contents of each chunk (if present) are a 64x64x64 matrix of tile indices (-1 if the tile doesn't exist yet), and a compact array of used tiles. This way, you don't burn a massive amount of tile indices for chunks which are never used. By following this sort of approach, and picking sensible numbers for the chunk granularity, you can scale up your universe massively, and keep your memory usage under control. Actually, if you make your chunks 32x32x32, you can even make your tile indices 16-bit.



You can also do sneaky tricks as well, like using the high order bit of your chunk or tile indices to mean something special. So if an entry in the tile matrix has the top bit set, then the lower 31 bits don't mean a tile index, instead they mean a 'warp index' or something similar, and you can look that up in a separately maintained list to find out the coordinates it leads to.


legal - How not to break licence laws?




I have an idea for a game. Also I have almost everything worked out considering coding.


What interests me the most is how can I know if that game can be published.


As it would be for iOS and android, these markets are of the geratest interest for me.


I found on apples store something similair to what I would make and it's published by some big game developer. How can I be sure I am not breaking any laws when publishing the game? Can I make a game like board game 'Risk'?


I don't have any knowledge considering licencing. This game would be avaliable for free, with an option to donate, so money isn't my objective (but it won't hurt) [:



Answer



There are three areas that you must take care of:



  1. Copyright

  2. Patents


  3. Trademarks


Even if you break something, you might get away with it. The company legal department can contact you and ask you nicely to remove the infringement. Or they can directly sue you, especially when the company is making profit by holding and licensing patents.


Copyright


Every piece of art, source code or documentation is copyrighted by the author or the game studio. By using the original art you not necessarily breaking the copyright. Copyright gives the author exclusive right to allow or disallow anyone else to use the art. In case of commercial games, read the EULA to prevent any infringement. It is safe to assume that you can't use any original media files, but you can contact the authors - they might be willing to make an exception.


Patents


Copyright protects artwork, patents protect ideas. Even a simple idea like how to treat game achievments on consoles can be (and IS!) patented. You can read about some of the well known game patents here. You can never be sure that you are breaking some patent unless you know all of them. You need a legal department to make sure you are not, it's not an easy job. If there is any patent infringement, the patent holder will most likely contact you and ask you to either license their patent or remove it from your software. I have seen this happen several times, but not in a game. In case you dispute their right, they will most likely sue you. However as stated above, some companies make money by sueing other companies over patent infringement, so they might not even issue a warning.


Trademarks


Trademarks protect brands and names. You can't use identical or confusingly similar name to the trademarked one. Trademarks are usually limited to one industry, unless the trademark holder broadens (read: pays more) the trademark. E.g. you might be ok with your McDonald's shoe repair, but not with McDoland's fast-food.





But even if you really take care of all this, you might run into problems. Depends on how much revenue you are making and how much revenue is the other company losing. As an example, look at the image below. It is from one of the big lawsuits recently, EA vs. Zynga. No original artwork was used, no patents and no trademarks infringements. They settled the suit without anyone winning.


EA vs. Zynga


See also: Wikipedia article Video Games Clone


3d - Advanced Animation for 2d Isometric Game?


I need help with workflow suggestions for a flash game. (although the concepts would apply to other game engines, too).


In a game like: Hero Academy



There are several different character models each with a multiplicity of animations (walking, standing, getting hurt, attacking, etc.). I am certain that each of these could be manually animated and a sprite sheet generated and used, but when you add up how many animations and core drawings would be needed...that would be near insanity to complete.


So, in research I found that some are creating character models in Blender, Maya, a 3d engine of some kind - setting the camera angle to 45deg, etc. animating and exporting that sprite.


In each of these examples however, the character models were 3d looking i.e.: 3d to 2d


When I look at Hero Academy, they still look like a 2d drawing.


If I am looking to re-create a similar art style to Hero Academy and need several animations per model what is the most efficient/correct workflow to creating the animation? Manually creating each animation sprite in Flash? Or utilizing 3d and texturing it to look 2d?(if that is even possible)?


EDIT: Thank you to all those who have posted great answers. To add information to the concept, one 'issue' I am contending with is the modeling/view of our desired game. To further clarify, if you look at Hero Academy's grid system (a la chess board) if you wanted an entity to be able to move vertically or diagonally this would need it's own sprites. However, is this still a simple 2d side scrolling game since the camera is fixed? And they have simply designed the background map to have the EFFECT of perspective?


If that is the case, then using Nuoji's comments, a 2d skeleton would then again be possible.


The base question is: if we are looking at close to 100 different character entities all with their own movement animation, long and close range attack animations, taunts, etc. what is the most expeditious method of doing this?


Note that I have experience in programming but no design/modeling experience. Whether we went the flash animation route or 3d modeling route I would be learning from scratch so any previous skill or preference is nullified.



Answer




After looking at the trailer in your link, they are indeed hand-drawn sprites. The animation seems smooth, so I wouldn't be surprised if they used some sort of skeletal 2D animation. This style involves drawing the movable parts of the character separately, so limbs, head, etc are separate sprites and they are posed and rotated accordingly to create keyframes, and tween the animation by code.


The other method as you mentioned, would be to make 3D models and export their animations individually for use in a 2D medium. If you are familiar with 3D modeling, this approach can be a lot quicker. You'd make your keyframes and tween them as usual but you will be able to export the entire animation as a sequence of images ready to be used in your game.


Ultimately, it depends on the aesthetic you want to achieve. Skeletal animation isn't suited for complex deformations.


Tuesday, January 23, 2018

unity - How can I fade a game object in and out over a specified duration?


I would like to know how I can fade a game object in and out. I would like to achieve this using a C# script. As I am quite new to Unity I've read about coroutines but still haven't fully grasped the concept. I would appreciate some assistance.



Answer



Assuming you've already configured your material in the Inspector to use transparent blending (otherwise it will ignore the mucking with alpha we're doing below), you can use a simple coroutine like this:


(If using a SpriteRenderer, you'd modify the color property of the SpriteRenderer rather than passing the material, but the rest can stay the same)


// Define an enumerator to perform our fading.
// Pass it the material to fade, the opacity to fade to (0 = transparent, 1 = opaque),

// and the number of seconds to fade over.
IEnumerator FadeTo(Material material, float targetOpacity, float duration) {

// Cache the current color of the material, and its initiql opacity.
Color color = material.color;
float startOpacity = color.a;

// Track how many seconds we've been fading.
float t = 0;


while(t < duration) {
// Step the fade forward one frame.
t += Time.deltaTime;
// Turn the time into an interpolation factor between 0 and 1.
float blend = Mathf.Clamp01(t / duration);

// Blend to the corresponding opacity between start & target.
color.a = Mathf.Lerp(startOpacity, targetOpacity, blend);

// Apply the resulting color to the material.

material.color = color;

// Wait one frame, and repeat.
yield return null;
}
}

You can use this like so:


// .material getter clones the material, 
// so cache this copy in a member variable so we can dispose of it when we're done.

_myMaterial = GetComponent().material;

// Start a coroutine to fade the material to zero alpha over 3 seconds.
// Caching the reference to the coroutine lets us stop it mid-way if needed.
_currentFade = StartCoroutine(FadeTo(_myMaterial, 0f, 3f));

tiles - Isometric rendering and picking?


I've been looking for a formula to plot (world->screen) and mouse pick (world->screen) isometric tiles in a diamond-shaped world. The ones I've tried always seem to be, well, off. What's the usual/correct way to do this?



Answer



Based on your comment, here's the code I'm using to convert tile x,y values to on screen coordinates. Now, it doesn't take into account "3d tiles", everything is considered as being on the same plane, so if you're writing a game where that matters, this code will not work.


//this converts a map x/y coordinate into screen coordinates
//public, static method, so can be called outside the Tile object

point Tile::convertToScreen(int x, int y, int offsetX, int offsetY)
{
point screen;
//calculate the screen coordinates
//note: these will then be modified by the camera
screen.x = offsetX - (y * TILE_WIDTH/2) + (x * TILE_WIDTH/2) - (TILE_WIDTH/2);
screen.y = offsetY + (y * TILE_DEPTH/2) + (x * TILE_DEPTH/2);
return screen;
}


point is simply a structure containing x and y ints, TILE_WIDTH would be 64 in your case, TILE_DEPTH is kind of badly named (it is actually the height of the tile graphics), but it would be 32 in your case. The offsets are if you want your tile map to "start" at a different x,y location (such as if you want tiles to be above another set of tiles). Typically the offset can be 0,0.


This will generate a map with 0,0 on top, middle, like this:


        0,0
0,1 1,0
0,2 1,1 2,1

As for finding the tile x,y of the cursor:


point selectedTile;
int x = mX - camera.x;
int y = mY - camera.y;

selectedTile.x = (y + x/2)/TILE_DEPTH;
selectedTile.y = (y - x/2)/TILE_DEPTH;

In this bit of code, mX and mY are the mouse screen coordinates, which we're combining with the camera values to find out where we are in "world coordinates". Everything else is the same as the previous code example.


Once again, this assumes a flat 2d isometric tile map. There's some additional work if you want to use a semi-3d view of the map, and this all assumes that you're working in 2d anyway.


Monday, January 22, 2018

phrase meaning - Saying "You'll feel me on this"


So, recently, I saw someone commenting, "You'll feel me on this" on a certain post. Since I'm not really familiar with phrases that are more informal (even regarded as slang) in English, I wanted to know what exactly does this phrase mean and when would it be appropriate to use this?



Answer



Saying "You'll feel me on this." is like saying "You know EXACTLY what I mean." At a core level deeper than thinking the same, you'll FEEL the same.


It's more of an emotional language and used for bonding. We as humans are emotional creatures, so when someone say's "you'll feel me on this" it builds a deeper connection between the people talking.


In short, this is a good phrase to use to make someone feel connected to you on a deeper level, deeper than them just understanding the literal words you're saying.


conjunctions - Should we cut "so" in this sentence?



Ducks, geese, and swans are different types of waterfowl, but because they are similar in behavior and physical characteristics, so they comprise a single bird family.



I have to find an error in the sentence above.


The answer key says that we have to remove “ so” because there are too many conjunctions. I don’t quite understand because I think we can still keep “so” in the sentence.



Do you think whether it is correct to remove “so” or it is possible to keep “ so “ in this sentence?



Answer



Short answer


You should remove "so". Removing "because" is also possible but not recommended.


You can read more details below.


Conjunctions: 'so' and 'because'


So and because are both conjunctions, and both can be used to join two clauses together: a reason/cause clause with a result/consequence clause. Basically, these two patterns are equivalent:



[Cause], so [consequence].
Because [cause], [consequence].




However, so and because work a little differently. So works as a coordinating conjunction to join two independent clauses. Because works as a subordinating conjunction to join a subordinate clause (or a dependent clause) to the main clause.


For example, consider these two sentences:



They had a test. They studied hard.



We can join them with so. (Using so this way, you can read "so" as "it follows that". The result sentence is a compound sentence.)



They had a test, so they studied hard.




We can also join them with because. (The result sentence is a complex sentence.)



They studied hard because they had a test.
Because they had a test, they studied hard.



One subtle difference between the two is that because puts more emphasis on the reason, while so puts more emphasis on the consequence. Also, in a complex sentence, we can delete subordinate clauses without losing the main idea of the sentence because the main clause is still there. For example, They studied hard because they had a test.


How to fix the sentence



Ducks, geese, and swans are different types of waterfowl, but because they are similar in behavior and physical characteristics, so they comprise a single bird family.




This sentence has three clauses:



a) Ducks, geese, and swans are different types of waterfowl.
b) They are similar in behavior and physical characteristics.
c) They comprise a single bird family.



Using both because and so in the same sentence is considered incorrect. You can see the reason why clearly if we try to remove the subordinate clause. (Remember that a complex sentence will still make sense after having any subordinate clauses removed.)



*Ducks, geese, and swans are different types of waterfowl, but because they are similar in behavior and physical characteristics, so they comprise a single bird family.
* denotes an incorrect usage




The sentence doesn't make sense anymore, and that is exactly why using both because and so in the same sentence is considered incorrect.


To fix that, we have two choices: remove either because or so. Both work fine, though I prefer removing so (and keeping because).



d) Ducks, geese, and swans are different types of waterfowl, but because they are similar in behavior and physical characteristics, they comprise a single bird family.
f) Ducks, geese, and swans are different types of waterfowl, but they are similar in behavior and physical characteristics, so they comprise a single bird family.



(d) is correct. (f) is acceptable, but less preferred. The reason is that (f) contains three independent clauses. (f) has the structure [A, but B, so C]. This is perfectly fine in my opinion; however, because most compound sentences have only two independent clauses, some people might read a sentence having more than two independent clauses, (f) for example, as a run-on sentence.


References




word meaning - What is the difference between "What are you?" and "Who are you?"?


I am often asked "Who are you?" and "What are you?", but I don't know the difference between these two questions.


Please explain it to me.




mathematics - How do you read these mathematical expressions aloud?


enter image description here


enter image description here


(both above are from Wikipedia.org)



Answer





  • The absolute value of the difference between S and

  • the sum from i equals one through i equals n of


  • the function f evaluated at t sub i times the width of each i

  • is less than epsilon.



If it is clear that i and n are one-indexed, then "the sum from i equals one through i equals n" can be replaced by "the sum of the first n terms". "The width of each i" is an interpretation of "delta i".




  • The function is one divided by the quantity x plus one close quantity, all divided by the square root of x.

  • The integral from zero to infinity of the function d x

  • equals the limit as s goes to zero of the integral from s to 1 of the function d x


  • plus the limit as t goes to infinity of the integral from 1 to t of the function d x.



"Goes to" can be replaced by "goes toward", or (as Damkeng suggests) "tends to", or (as J.R. suggests) "approaches".


I often use a notation like "integral from x equals a to x equals b" instead of "integral from a to b". I also often say "to positive infinity" instead of "to infinity".


I "factored out" the definition of the function in the first sentence. If the function were easy to say (such as "x squared"), I would not "factor out" the definition of the function. Instead, I would include the "x squared" in the statements of the integrals, a la Damkeng's answer.


use "if" rather than "whether" when the object clause is negative?


Sentence 1: I don’t know if it won't rain tomorrow.


Sentnece 2: I don’t know whether it won't rain tomorrow.


Which sentence sound natural to you? Is there a rule that we should use "if" rather than "whether" when the object clause is negative?


Thank you very much!




Sunday, January 21, 2018

Can we use some modals interchangeably?



What's the difference among the following sentences?



It might rain tomorrow
It would rain tomorrow
It feels like rain tomorrow
It could rain tomorrow
It will rain tomorrow



Secondly, can we can use will and would interchangeably to indicate the future? For example,




I would study tomorrow
I will study tomorrow



Do both of them convey same meaning or is there any difference?



Answer



There are some contexts where more than one modal is possible, with identical or very similar meaning; but in general, no they are not interchangeable.


To take your examples:



It might rain tomorrow.




and



It could rain tomorrow.



mean the same.



It would rain tomorrow.



is meaningless unless there is some particular context which makes it possible (for example, a conditional protasis such as "If I decided to spend today visiting friend and not gardening, then ... ")




It feels like rain tomorrow.



This, to me expresses a greater likelihood of rain than the first two.



It will rain tomorrow.



This expresses certainty.


Similarly with your other pair,




I would study tomorrow.



would not be said unless there is some special context, most often a condition (eg "If I didn't have to go to work")



I will study tomorrow.



is a normal expression of intention.


tense - I've got, I have


I know this subject was discussed for many times, but I still don't get it..


I've read in a book that we can use "I've got" instead of "I have" for possesion and it gave some examples,



I've got an English book.
I've got a red car.




So I understand that it can be used only for possession of physical objects, but I saw it used in sentences like "I've got something to say", is it correct? I hope it's not a stupid question..Thank you very much!



Answer



I've got something to say is fine.


HAVE got can be used almost anywhere that bare HAVE is used as a "lexical" verb—that is, as a main verb rather than a perfect auxiliary. It can also replace HAVE in the "periphrastic modal" HAVE to = 'must', as in "I've got to get a haircut."


The principal restriction on HAVE got is that it can be used only with HAVE in the simple present form: I/you/we/they have got, he/she/it/John has got. It can't be cast in the past-tense form, or the progressive construction, or in the infinitive or participial form.


There are marked differences in BrE and AmE use. In AmE HAVE got is largely restricted to conversational situations, probably because it was for a long time deprecated as vulgar by US English teachers. It is acceptable in all registers in BrE.


In BrE HAVE got is routinely used in questions and negations:



Have you got any money?

I haven't got a penny.



This is rare in AmE; US speakers tend to revert to the ordinary HAVE in these contexts:



Do you have any money?
I don't have a penny.



The distinction may be attributable to the AmE preference for gotten as the past participle of get, where BrE speakers prefer got: BrE treat HAVE got as a sort of idiomatized perfect. This analysis is supported by the fact that ain't got is fairly ordinary, and by the growing frequency of bare got, without the HAVE, in AmE:



You got any spare cash? We gotta get some gas.

Yeah, I got plenty, I'll buy.



Colloquial AmE, it appears, is coming to regard got as the core of the expression and HAVE as a dispensable ornament.




The descriptions of AmE use rest on my own analysis of the UCSB corpus of spoken English. In conversational contexts I found 545 instances of indicative have/has and 158 instances of DO have, against 171 instances of HAVE got, all indicative, and 90 instances of bare got. In non-conversational contexts I found 167 instance of have/has/DO have and only 4 instances of HAVE got.


phrase meaning - Is 'to avoid company' a correct expression?


I am trying to convey the next message:




Being an introvert doesn't mean [avoiding company/to avoid company].



Is it correct to use 'to avoid company' in the meaning of 'to be alone, to keep yourself away from company'? Should I use an article before 'company'?




Since it's uncountable, I am supposed to not use an indefinite article to describe a general idea.



company (U) - the fact of being with a person or people, or the person or people you are with




Answer



There is nothing wrong with to avoid company in and of itself.




An introvert is not someone who wishes to avoid company.


Being an introvert does not mean wanting to avoid company.


Being an introvert does not mean you want to avoid company.



unity - Instantiate objects in a List and use it


Why does the following code not work?


I want to instantiate prefabs in a list and then use it as a GameObject like that :


public GameObject prefab;

void Start()
{


ArrayList players = new ArrayList();

for(int i=0; i<5; i++)
{
players.Add( (GameObject)Instantiate(prefab));
}

players[2].transform.position = new Vector3(1, 1, 1);


}

there is an error message


enter image description here




articles - see Batman in the theatre



I’m going to see Batman in the theatre.



In the case that I’m going to see a specific movie, e.g. Batman, do I use definite or indefinite article in locative adjunct? (It’s not yet decided which theatre I would go to.)



Answer




As far as I know it's entirely idiomatic, with no particular reason, but when we talk about certain places we commonly use the definite article even when we're discussing an unspecified one out of several places:



I'm going to the theater.



(even if there are several theaters I might be going to)



Bob was in the hospital for three days.


We had fun at the park.



In none of these cases would we substitute "a" for "the".



Also note, British English (sometimes?) uses no article at all for the case of "hospital". ("Bob was in hospital for three days").


As J.R. points out, there are also cases where the indefinite or definite article could both be used:



Q: I can't wait until Guardians of the Galaxy comes out on DVD.


A: I'm not waiting that long; I want to see it in a (the) theater.



Unfortunately I can't tell you what makes this example different from the previous ones.


Edit


Thinking about CarSmack's comment, I think when we use "the" with a place we are implying that we were there to do whatever activity is typical in that place.




I went to the theater [to watch a movie].


Bob was in the hospital [to receive medical care].



If we talk about going to these places to do something non-typical, then using the indefinte article sounds more natural



I went to a hospital to repair the air-conditioning.



or



Q: Where do you work?



A: I work at a hospital [doing IT support].



java - How can I move a sprite in the direction it is facing?


I'm using Java/Slick 2D. I'm trying to use the mouse to rotate the sprite and the arrow keys to move the sprite. I can get the sprite to rotate no problem, but I cannot get it to move in the direction it is supposed to. When I hit "forwards", the sprite doesn't necessarily move towards the mouse. Actually, it will only move towards the left of the screen really. I'm sure there has to be some standard code for this since many games use this style of motion. Can anyone help me out with what the trig is supposed to be? Thanks


EDIT: Here is the rotation code (which does something else weird: https://stackoverflow.com/questions/12610320/why-is-my-image-rotating-off-center)


int mX = Mouse.getX();
int mY = HEIGHT - Mouse.getY();
int pX = sprite.x;

int pY = sprite.y;
int tempY, tempX;
double mAng, pAng = sprite.angle;
double angRotate=0;

if(mX!=pX){
mAng = Math.toDegrees(Math.atan2(mY - pY, mX - pX));
if(mAng==0 && mX<=pX)
mAng=180;
}

else{
if(mY>pY)
mAng=90;
else
mAng=270;
}

sprite.angle = mAng;
sprite.image.setRotation((float) mAng);


And the movement code. I can only move towards the left of the screen...


double ang = sprite.angle;
Input input = gc.getInput();

if(input.isKeyDown(sprite.up)){
sprite.x += Math.cos(ang)*sprite.moveSpeed;
sprite.y += Math.sin(ang)*sprite.moveSpeed;
}if (input.isKeyDown(sprite.down)){
sprite.x += -1*Math.cos(ang*Math.PI/180)*sprite.moveSpeed;
sprite.y += -1*Math.sin(ang*Math.PI/180)*sprite.moveSpeed;

}if (input.isKeyDown(sprite.left)){
sprite.x -= Math.cos(ang*Math.PI/180)*sprite.moveSpeed;
sprite.y += Math.sin(ang*Math.PI/180)*sprite.moveSpeed;
}if (input.isKeyDown(sprite.right)){
sprite.x += Math.cos(ang*Math.PI/180)*sprite.moveSpeed;
sprite.y -= Math.sin(ang*Math.PI/180)*sprite.moveSpeed;
}

Answer



You'll want to get a vector based on your current velocity and heading. Then use that vector to increment your position.


//first get the direction the entity is pointed

direction.x = (float) Math.cos(Math.toRadians(rotation));
direction.y = (float) Math.sin(Math.toRadians(rotation));
if (direction.length() > 0) {
direction = direction.normalise();
}
//Then scale it by the current speed to get the velocity
velocity.x = direction.x * speed;
velocity.y = direction.y * speed;

So now you know your velocity based on your rotation. You can the update your position with that information.



//Update the position based on our current speed
//This is basic s = vt physics
position.x += velocity.x * timeElapsed;
position.y += velocity.y * timeElapsed;

Saturday, January 20, 2018

difference - "Would you mind if I [do something]?" versus "Would you mind me [doing something]?"


Is there any difference between the following sentences?



Would you mind if I smoke a cigarette outside?


Would you mind me smoking a cigarette outside?




Would you mind if I prepare a tea cup for you?


Would you mind me preparing a tea cup for you?




To me, "Would you mind me [doing something]?" and "Would you mind if I [do something]?" seem equivalent ways to ask before doing something, but maybe there are differences between those phrases that a native speaker would catch.



Answer



Yes, there is a very subtle difference between the two forms



Would you mind if I smoke a cigarette outside?



is equivalent to



Would you mind my smoking a cigarette outside?




since both phrases refer to the action of smoking. In the second form, when referring to the action of smoking and you want to use the verbal noun (gerund) smoking, you have to use my.



Would you mind me smoking a cigarette outside?



refers to me personally and not the action of smoking.


Would you mind if..? or Do you mind if..? is just another way of saying May I..?


grammar - using "the" before "most" in a sentence


I found this book the most interesting.
According to a book, the should be removed. Why?
Shall I have to mention that of all the books that I've read so far, this one was the most interesting? (or even here "the" has been wrongly placed before "most")
what about the use of "the" before most in this sentence.
He is the most intelligent student of this class. (Correct I think)




auxiliary verbs - Past participle vs being+past participle


What is the difference in the meaning between the following sentences:





  1. Being beaten by snow, he died.







  2. Beaten by snow, he died.





Or:





  1. Being taken to the hospital, he survived.







  2. Taken to the hospital, he survived.





Here are my opinions about them:


When we use Being+past participle as a participle clause, it refers to the reason for the action of the main clause and it replaces 'Because'.



when we use past participle clause as a subordinate clause it also refers to the reason for the action in the main clause. Thus, both(being+p.p and p.p) work the same and their meanings also same in sentences. They convey the same meangs but only their construction is different. I'm not sure,so I'm confused here.


If i understand the usage and meaning of them, my confusion will certainly be eliminated.



Answer



tl;dr


The two participle clauses you cite are in the passive voice, and being puts them in the present continuous tense. They are continuous passive participle clauses.


Compare:



Continuous passive:
Being beaten by (the*) snow, he died.


Passive:

Beaten by (the) snow, he died.


Active:
The snow beat him, (and) he died.



One of your opinions about the two sentences is correct: being+past participle is identical in meaning to the past participle alone, and the gerund being can be omitted in both sentences.


Being beaten here is a continuous passive participle. Without being, it is a passive participle. Their meanings are nearly identical, and being can be omitted, but as you suggest, being in the first example emphasizes that he died because the snow beat him. It "tells a story", in a way, of the beating as it progresses. (In the longer and "optional" part of this answer, because is discussed more thoroughly.)


The verb to be is not just a useful and meaningless sound used to form tenses and the passive voice. Be is a "real" verb with a "real" meaning of its own. Being means having place in the objective universe or realm of fact; existing. In your sentence, Being beaten means Existing in the state of "beaten"-ness. Understanding what being really means, and thinking deeply about the verb be in relation to your two sentences, may open up for you an understanding of how the passive voice works in English, and the other ways in which we use the verb.




Optional


The verb to be is often taught as a linking verb or auxiliary verb, and it performs those duties very well. However, without knowing what the verb means, it is impossible to truly grasp the sense of many constructions in English which employ be in its various forms—including, I think, its workmanlike service in linking and forming tenses and the passive voice.



In your first example, the verb to be helps to describe the cause of the subject's death:



Being beaten by the snow, he died.



Being beaten is routinely analyzed as a continuous passive participle using the gerund of the verb to be, but with the "meat" of meaning provided by the participle beaten. Analysis might center on that verb's meaning; but the verb be is important here, even though it could be omitted without changing the sense of the sentence:



Beaten by the snow, he died.



What does it mean to "be"?


In most beginning English classes, the verb to be is the first one studied. Because it is the most irregular of verbs, and because of its wide use as a linking verb, the forms of the copula (as it is known to linguists) are memorized early on.



Webster's Unabridged Dictionary (1913) has this to say about to be:




  1. To exist actually, or in the world of fact; to have existence.




  2. To exist in a certain manner or relation, -- whether as a reality or as a product of thought; to exist as the subject of a certain predicate, that is, as having a certain attribute, or as belonging to a certain sort, or as identical with what is specified, -- a word or words for the predicate being annexed; as, to be happy; to be here; to be large, or strong; to be an animal; to be a hero; to be a nonentity; three and two are five; annihilation is the cessation of existence; that is the man.




  3. To take place; to happen; as, the meeting was on Thursday.





  4. To signify; to represent or symbolize; to answer to.




Many words are used to define this very small one, and rightly so. It is a part of the very "framework" of English (and of all Indo-European languages) and is so entwined in our languages that it has even "disappeared" in some of them: it is "understood" rather than spoken! After all, what is more elementary to language than the expression of existence itself? That is exactly what to be means.


When we say that something is, we are expressing its existence. When we say that something was, we express its existence in the past. The participle phrase Being beaten uses be in the sense of the second definition above: it expresses the state of existing with the attribute of "beaten-ness."


In comments, you were asked to compare the verb to eat and its participle eating with the verb to be and its participle being. Of course anyone knows what it means to eat; and anyone knows what the act of eating is. No matter what language they speak, all humans engage in eating. The same is true of being, and the definition of that word is easy to grasp if you consider that:



Being is to be as Eating is to eat.




Of course, eat is a dynamic verb that describes an action, and be is a stative verb that describes a state or condition, but it is easy to understand that being and eating both express what happens when the action or state described by the verb is undertaken or experienced.


Here we can come back to the part of your question in which you suggest that the participle phrase Being beaten replaces the adverb because. You are nearly correct! It is Being which could be replaced, and we can express the same thought like this:



Because (he was) beaten by the snow, he died.



Yet even here, the verb to be is involved: The adverb because is itself descended from the verb be and the noun cause! As Webster's 1913 Unbridged also tells us in its definition of be:



  • Note: It is joined with certain substantives, and a few adjectives, to form verbs; as, bedew, befriend, benight, besot; belate (to make late); belittle (to make little). It also occurs in certain nouns, adverbs, and prepositions, often with something of the force of the preposition by, or about; as, belief (believe), behalf, bequest (bequeath); because, before, beneath, beside, between. In some words the original force of be is obscured or lost; as, in become, begin, behave, behoove, belong.



In the original form of because, the words be and cause were separate:



For be-cause þat I know þe sorw þat þay haue, ich am com doune to deliuer hem.



(From a sermon composed in the 1400s by an unknown writer and preserved in a manuscript at Worcester Cathedral.)



& þer power was adraw be cause he made þe signe of þe cros...



(from a Middle English Treatise on the Ten Commandments)


And Geoffrey Chaucer in The Merchant's Tale writes:




If Hys Squyors / whiche fat stoodon ther bisyde
Excused hym / by cause of his siknosse



A discussion of the verb to be cannot but end by noting that it is the subject of what some believe to be the most perfect poetry written in English. In 1600 CE, The Bard of Avon put these words in the mouth of Hamlet, the Prince of Denmark:



To be, or not to be, that is the question:





Both of your example sentences numbered as 1.) contain clauses in different voices and tenses, which presents problems not addressed by your question. In English, they would at least be written to agree in tense, e.g.:

Being beaten by snow, he dies.
Being taken to the hospital, he survives.


* I have here added the definite article which the questioner omitted in his example.


Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...