Tuesday, October 31, 2017

grammar - Single verb for multiple subjects vs multiple verbs for multiple subjects


I have different things to do. I would like to express this in a passive voice. I would like to understand the correct way to do this in English.



Suppose that a model A is given, fitted to the simulated data and estimated.



or




Suppose that a model A is given, is fitted to the simulated data and is estimated.



Do I need to repeat the verb or a single verb is enough?



Answer



You do not need to repeat the auxiliary verb:



A model is given and fitted to the data.



But I note that you do not "Estimate a model", instead you "use a model to estimate (the parameters)". So the "...and estimated" is grammatically correct, but doesn't fit the meaning. I would write




... and used to estimate ....



unity - Make one object rotate to face another object in 2D


In my 2D project, I have an object that is sometimes above or below another object.



Once the primary object comes in close proximity with the secondary object, I want the object to rotate on the z axis so that the front of the primary object is facing the secondary object.


(Here, following Unity's default setup, the z axis is the axis pointing into the screen)




Java Game how to make image follow line?



Hello I have a game where circles rotate around the centre of the frame. When I click on two circles a line is drawn between the two circles. The circles are always moving and so is the line. I have an image at the start of the line and I want it to move along the line at stop at the end of the line. I knowhow to start the image at the start but I don't know how to move the image along the line. How can I move the image along the line?


Here is my code:


   public class ship {

public int sx,sy,ex,ey;
public boolean arrived,sel1,sel2;
public int amountOfPop = 0;

public int fc = -1,sc = -1;


public ship(int sx,int sy,int ex,int ey,int aop){
this.sx = sx;
this.sy =sy;
this.ex = ex;
this.ey =ey;
this.amountOfPop = aop;



}


public void tick(){


}

public void render(Graphics g){
g.setColor(Color.blue);
g.drawLine(sx, sy, ex, ey);
}

}

sx and sy are the starting x and starting y. ex and ey is where the image should finish. Please help me.



Answer



I'm going to explain this using Vector mathematics. I would also recommend to store your x and y values as such, as it makes it easier to maintain. Here's an example:


public class Vector2 {

public float x;
public float y;


public Vector2(float x, float y) {
this.x = x;
this.y = y;
}

public static float length(float x, float y) {
return Math.sqrt(x * x + y * y);
}

public static float distance(Vector2 first, Vector2 second) {

return length(second.x - first.x, second.y - first.y);
}

public static Vector2 direction(float x, float y) {
return new Vector2(x / length(x, y), y / length(x, y));
}
}

You'll want to give your ship a Vector2 to indicate its current position, the start position, the target position, and one for the direction. You'll also need a speed variable which indicates the rate at which your image will move (you could just use 1f if you like), and a distance variable to indicate the distance from the current position:


private Vector2 position;

private Vector2 start;
private Vector2 target;
private Vector2 direction;

private float speed;

private float distance;

...


public Ship(Vector2 position, Vector2 target, float speed, ...) {
this.position = position;

// Initialize start as a new Vector2 with the same x and y coordinates as position
this.start = new Vector2(position.x, position.y);
this.target = target;

distance = Vector2.distance(start, end);
direction = Vector2.direction(end.x - start.x, end.y - start.y);


...
}

public void tick() {
position.x += direction.x * speed;
position.y += direction.y * speed;

if (Vector2.distance(start, position) >= distance) {
// The ship has reached the target
}


...
}

I'm assuming your tick() method is where you're performing your logic. What we're doing here is adding the distance * speed to the current position of the ship, making it travel along the imaginary line between the start position and the target.


If your start and target points are changing as you say, all you need to do is update the distance and direction variables in your tick() method:


public void tick() {
distance = Vector2.distance(start, end);
direction = Vector2.direction(end.x - start.x, end.y - start.y);


...
}



Equations:


Length: Length equation


Distance: Distance equation


Direction: Direction equation




The Vector2 class in this example is very basic and can definitely be improved upon. I suggest learning more about Vector mathematics, as well as taking a look at existing implementations of Vector mathematics and calculations to get a better idea on the subject. Here's one such implementation of a Vector2 class in libGDX.



sentence construction - Can we use WHOSE for things? (or should I use 'that' or 'which'?)



I have changed the net connection to a package that/which cost is $15 per month.



Which relative pronoun is proper to use in such scenarios? Can we use whose for abstract or non-living things?




business - What things should an indie game developer never do?



What are some of the biggest - and better yet: insidious and unexpected - mistakes that indie game developers make? Especially when making the transition from hobbyist to full-time indie?




Answer



One of the major pitfalls is focusing too much on developing the framework / tools / engine, and too little about making the actual game.


You risk to get all entangled up into that and lose focus. Never forget you are first and foremost making a game not making a middle-ware component.


i.e. You should not start by coding the math library but instead by figuring out how to make the game entertaining.


Monday, October 30, 2017

Indefinite article before uncountable "drink" nouns, e.g. "a water"


I have been reading Bad for You (a novel) for the last seven days. I have seen in the novel that the writer used the indefinite article a before a uncountable noun water.




I glanced at Linc again. His grin was still in place, but he rolled his eyes as if he was amused with his dad.


“Okay, well, thank you. It didn’t take me too long to get settled in though,” I said, feeling the need to say something. I wasn’t good with small talk.


“Good. I’m glad you’re ready to dive in. Please, have a seat. Can Linc get you a water?”



However, I do not think that we can put the indefinite articles (a and an) before uncountable nouns (water, milk, wine). As per my opinion, the author should have said:



“Good. I’m glad you’re ready to dive in. Please, have a seat. Can Linc get you a glass of water?”


“Good. I’m glad you’re ready to dive in. Please, have a seat. Can Linc get you a bottle of water?”





unity - Best place for learning how to write games in Unity3d



What's the best place for tutorials & other learning resources for unity3d?




Sunday, October 29, 2017

adverbs - When to begin a sentence with "Therefore"


I know we can begin a sentence with Therefore. We can also use it after commas in a sentence.



For example, which is correct?




  1. She had previous experience, therefore she seemed the best candidate.




  2. She had previous experience. Therefore, she seemed the best candidate.




I myself feel when the first or second clause is long or when the subject is switched, using "therefore" at the beginning of sentence is better. Therefore, I think sentence #1 is better here because it uses the same subject and both sentences are short.




Answer



You have asked a common question. Fortunately, there's plenty of material on the world wide web that offer guidance. See, for example, the following:



COMMON PROBLEMS WITH HOWEVER, THEREFORE, AND SIMILAR WORDS


This page explains a type of error writers often make when using words like [sic] however, furthermore, therefore, thus, consequently, and moreover.


The problem occurs when writers use these words to conjoin sentences. Readers find the error to be distracting because it disrupts their expectation about where sentences should end.


EXAMPLE MISTAKE



January may be the coldest month, however, it is a time of great beauty.




The boldface “however” and the comma after “month” are the problems. This is easy to correct. But first, here is some explanation.


A common problem writers face is the incorrect usage of conjunctive adverbs. Many times it is because they confuse them with coordinating conjunctions.


A coordinating conjunction is a familiar part of the English language and includes the following: and, but, or, nor, so, for, yet. A conjunctive adverb is not so common in everyday speech, but occurs frequently in written prose. These include the following: however, moreover, therefore, thus, consequently, furthermore, unfortunately.


Most of the time, problems occur when the writer uses a conjunctive adverb in the middle of a sentence when a coordinating conjunction is actually needed. But remember that conjunctive adverbs can be used in any part of a sentence.


This page addresses the problem that arises when conjunctive adverbs are used wrongly to connect two sentences. To avoid this problem, a basic rule to follow is this: If the two parts you are connecting can stand on their own as separate sentences, then you have probably misused the conjunctive adverb. If this is the case, you have a few options for fixing it. Usually a semicolon is the best choice, but you may also use a period or a coordinating conjunction.


INCORRECT



Watering and feeding new plants is necessary for growth, however, too much water or fertilizer can kill them.


Erica felt as if she might faint from hunger, therefore, she decided a trip to McDonald’s was necessary.


Joyce Carol Oates is a novelist, essayist, playwright, and poet, moreover, she is a distinguished scholar.




All of these examples create comma splices because there are complete sentences to the left and the right of the conjunctive adverbs however, therefore, and moreover. The commas after “growth,” “hunger,” and “poet” create the comma splices. Here is the correct way to punctuate these sentences.


CORRECT



Watering and feeding new plants is necessary for growth, but too much water or fertilizer can kill them.



Erica felt as if she might faint from hunger. Therefore, she decided a trip to McDonald’s was necessary.


Joyce Carol Oates is a novelist, essayist, playwright, and poet; moreover, she is a distinguished scholar.


Notice that the first example replaced the conjunctive adverb with a coordinating conjunction, the second with a period, and the last used a semicolon. Because many of theses parts of speech can mean basically the same thing, it is tempting to use them the same way in a sentence. Just remember: coordinating conjunctions can conjoin sentences. Conjunctive adverbs cannot. This may be a bit confusing, but with practice and a sharp eye you can avoid making this common mistake.


by Athens Battles



Examples for this handout were adapted from:
Rosen, Leonard J., and Laurence Behrens. The Allyn and Bacon Handbook. 3rd ed. Needham Heights, MA: Allyn and Bacon, 1997.



(Indiana University of Pennsylvania)



PUNCTUATION WITH ‘THEREFORE’, ‘FURTHERMORE’ AND ‘HOWEVER'


Reader’s question: I would like to know the appropriate punctuation when using the words however, therefore, furthermore.


Answer: My guidelines for words such as however, therefore and furthermore (adverbial conjuncts) are as follows.


If you use these words at the beginning of a sentence, put a comma after them.




… However, we intend following up shortly.



Some modern writers are now dropping the comma, but I still like it because I think it indicates a pause.


Use a semicolon and comma with these words to introduce a new independent clause in the middle of a sentence.



We plan to stay for another year; however, Peter is leaving now.



When you use however, furthermore or therefore as intensifiers or for emphasis, you need commas around both sides of them.



We, however, do not agree with the verdict.




PS An independent clause is a group of words that contains a subject and verb and expresses a complete thought.



(Online Grammar)


modal verbs - "Would" vs. "must"



The perfective and progressive aspects are normally excluded when the modals express 'ability' or 'permission', and also when shall or will expresses 'volition'.


These aspects are freely used, however, with extrinsic modal meanings other than ability; eg:



'possibility' -- He may/might have missed the train. She can't/couldn't be swimming all day.


'necessity' -- He must have left his umbrella on the bus. You must be dreaming.


'prediction' etc -- The guests will/would have arrived by that time. Hussein will/would still be reading his paper.




Page 235, A Comprehensive Grammar Of The English Language - 1985 Randolph Quirk, Sidney Greenbaum, Geoffrey Leech, Jan Svartvik



Based on this I contrived the following examples. For both would and must, the progressive aspect coerces a reading of an inference:



A.1. The lights are on. John must read his paper.


A.2. The lights are on. John must be reading his paper.


A.3. The lights are on. John would read his paper.


A.4. The lights are on. John would be reading his paper.




A.1. represents an imperative.


A.2. represents a logical conclusion.


A.3. sounds iffy. A well-established context would decide its meaning.


A.4. represents a present conjecture.


Is "would be doing sth" the close equivalent of "will be doing sth"? That is to say, whenever "will be doing sth" is used for inference we can use "would be doing sth" instead. Is it true?



Answer



Here's how I understand the four examples (native AmE speaker). Others will probably understand them differently.



The lights are on. John must read his paper.




"Now that the lights are on, John is required to read his paper."



The lights are on. John must be reading his paper.



"Since the lights are on, I infer that John is reading his paper right now."



The lights are on. John would read his paper.



"The lights are on. Ah, back when John was alive, on a typical day he read his paper when the lights were on." (This is a bit of a stretch. Some context is needed to set up the counterfactual situation.)




The lights are on. John would be reading his paper.



"The lights are on. As long as life is progressing in its normal way, John is reading his paper right now."


Will vs. would


To answer your question about whether "will be doing something", if it means an inference or speculation, can always be replaced with "would be doing something", my immediate, gut-level, native speaker's reaction is "No, because 'would' is softer than 'will'."


If that's too vague, here is a clear-cut counterexample:



We think that when the lights come on, John will be reading his paper. If so, that would prove that John was reading in the dark.



Here you really can't replace will be with would be, or you would lose the contrast between the two sentences, which is essential to the meaning. The will be clause states a hypothesis. The would in the following sentence states a consequence of the hypothesis.



I'm not sure if "'would' is softer than 'will'" is helpful to someone learning English, but I think it gives you some idea of how native speakers hear these words and choose between them when a sentence could contain either one. Rules try to capture a lot of specific constructions with these words, but the "softer" idea explains those constructions. For example, "I would like an ice cream sundae" is more polite than "I will have an ice cream sundae" because would comes across as softer than will. "John will be reading his paper" sounds more confident and certain than "John would be reading his paper." A hypothesis is closer to what's known, so it takes will in contrast to a consequence of that hypothesis, which takes would. There must be many more forms that this distinction takes. Sometimes the difference is just a subtle shading, and sometimes it's very clear-cut (like the hypothesis-consequence distinction).


An idea


I like the idea of learning some examples to distinguish these verbs, since examples are ripe for intelligently varying to fit new circumstances, while rules are more rigid and don't prime imagination as well. However, the examples A.1 through A.4 don't seem to work well because they're too far from the "anchoring" senses of the verbs. That makes the meaning of those examples somewhat unclear.


So, maybe it would be most helpful* to memorize some example sentences that are well-known to most native speakers, where the meaning of these verbs is extremely clear and distinct. Knowing these sentences might help a learner hear these verbs and use these verbs in ways that are in sync with most native speakers. Unfortunately, I don't have a list of such sentences off the top of my head. Maybe other people can suggest some.


Footnote


* Notice "would" rather than "will" following "maybe". "Will" could work, too, but it would sound a little pushy. I'm trying to make the suggestion as gently as possible, because it's speculative and I'm really not sure it's going to work, so I chose "would" instead of "will".


xna - Spritebatch not working in winforms


I'm using the Winforms sample on the app hub and everything is working fine except my spritebatch won't draw anything unless I call Invalidate in the Draw method. I have this in my initialize method:


Application.Idle += delegate { Invalidate(); }; 


I used a breakpoint and it is indeed invalidating my program and it is calling my draw method. I get no errors with the spritebatch and all the textures are loaded I just don't see anything on the screen. Here's the code I have:


    protected override void Draw()
{
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin();
tileSheet.Draw(spriteBatch);
foreach (Image img in selector)
img.Draw(spriteBatch);
spriteBatch.End();
}


But when I do this:


    protected override void Draw()
{
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin();
tileSheet.Draw(spriteBatch);
foreach (Image img in selector)
img.Draw(spriteBatch);
spriteBatch.End();

Invalidate();
}

then all of a sudden the drawing starts to work! but the problem is that it freezes everything else and only that control gets updated. What can I do to fix this? It's really frustrating.




Saturday, October 28, 2017

java - How do I test for intersection between a ray and a cone?


I decided that writing a ray-tracer in my game was a brilliant idea, and so now I am looking for code to use for ray to primitive intersection tests. I have based my effort on this very nimble yet complete code. It works well but only supports sphere primitives. I have added plane, disk and ring (in that order) because they are easy. Next I am thinking about adding box and cone.


But while sphere and plane intersection tests are really simple cone seems really difficult.


I have yet to find a simple and easy to adapt java implementation of a ray cone intersection test. I am in this to get a ray-tracer up and working quickly without learning too much math underway, so is does anyone have a java snippet lying around that performs a trivial ray cone intersection test suitable for a small ray-tracer?



Answer



I had some time to read up on this and decided to share.


In "serious" ray-tracers that grown-ups use, cones and other similar shapes such as cylinders are usually represented as either tesselated surfaces or as quadric shapes. There exists pure cone-only intersection code that may or may not be more optimized, but implementing the more general quadric approach will give so much more value-for-effort for the beginner that it is worth implementing it first. Thus, in this answer I will focus on the quadric solution.


In geometry quadric shapes are




any surface that can be defined by an algebraic equation of second degree



. On the normal form this equation looks like this:


Ax^2 + By^2 + Cz^2 +2Dxy + 2Exz + 2Fyz + 2Gx + 2Hy + 2Iz + J = 0


By selecting different values for A through J, and by carefully applying axis aligned clipping planes in the right places, we can define what kind of surface we want. Here are some example shapes (from here):


Different quadric shapes, including cone


Finally to the code. Since my ray-tracer was based on the ubiquitous instructional ray-tracer by Leonard McMillan I found a plethora of student extensions more or less based on this code. One in particular by a guy called Charlie had an implementation of Ray-Quadric intersection and shading code. I have shamelessly copied the important parts here (full code here), and will comment on it as soon as I get a chance to actually test it in my own application.


class Quadric extends Renderable {
private static final float twoPI = (float)(Math.PI * 2.0);


float A, B, C, D, E, F, G, H, I, J;
float A2, B2, C2;
float miny, maxy;
Matrix3D OStoWS, WStoOS;
float theta;

public Quadric(Surface s, Matrix3D o2w, Matrix3D w2o, float zmin, float zmax, float thetamax,
float a, float b, float c, float d, float e, float f, float g, float h, float i, float j )
{

surface = s;
A = a; B = b; C = c; D = d; E = e; F = f; G = g; H = h; I = i; J = j;
A2 = 2.0f * A;
B2 = 2.0f * B;
C2 = 2.0f * C;
miny = -zmin - Constants.EPSILON; maxy = zmax + Constants.EPSILON;
OStoWS = new Matrix3D(o2w);
WStoOS = new Matrix3D(w2o);
theta = (float)(thetamax * Math.PI / 180.0f - Math.PI);
}


Vector3D d = new Vector3D();
Vector3D o = new Vector3D();
float a2_1;
float a, b, c, tOS, tWS, discrim;
float dMagOS;

public boolean intersect(Ray ray) {
WStoOS.transform(ray.origin, o);
WStoOS.transformNormal(ray.direction, d);

dMagOS = 1.0f / d.length();
d.normalize();
boolean flag = false;


a = A * d.x * d.x + B * d.y * d.y + C * d.z * d.z;
b = A2 * o.x * d.x + B2 * o.y * d.y + C2 * o.z * d.z;
c = A * o.x * o.x + B * o.y * o.y + C * o.z * o.z + J;

if (a == 0.0f) {

tOS = - c / b;
flag = true; // remember this
} else {
discrim = b * b - 4.0f * a * c; // compute discriminant

if (discrim < 0.0f) return false; // no intersection

discrim = (float)Math.sqrt(discrim); // store sqrt value
a2_1 = 1.0f / (2.0f * a); // store 1 / (2a)
tOS = (-b - discrim) * a2_1; // near intersection


if (tOS < 0.0f) { // near intersection too close
tOS = (-b + discrim) * a2_1; // use far intersection
flag = true; // remember this
}
}

tWS = tOS * dMagOS; // need to scale intersection tOS to get tWS
if ((tWS > ray.tWS) || (tWS < 0)) return false; // trivial reject


ray.hitOS.addScaled(o, d, tOS); // get hit point in object space
if (ray.hitOS.y < miny || ray.hitOS.y > maxy) // outside clip box?
{
if (!flag) { // alright, so the near intersection is outside the clipping box,
// but that doesn't mean the far intersection isn't inside
tOS = (-b + discrim) * a2_1; // compute the far intersection
tWS = tOS * dMagOS; // need to scale intersection t
if ((tWS > ray.tWS) || (tWS < 0)) return false; // trivial reject

ray.hitOS.addScaled(o, d, tOS);

if (ray.hitOS.y < miny || ray.hitOS.y > maxy) return false;

} else { // both near and far intersection flunked clip box
return false;
}
}
if (theta != twoPI) { // now clip against the accept angle
float a = (float)Math.atan2(-ray.hitOS.z, -ray.hitOS.x);
if (a > theta) {


if (!flag) { // alright, so the near intersection is outside the accept angle,
// but that doesn't mean the far intersection isn't inside
tOS = (-b + discrim) * a2_1; // compute the far intersection
tWS = tOS * dMagOS; // need to scale intersection t
if ((tWS > ray.tWS) || (tWS < 0)) return false; // trivial reject

ray.hitOS.addScaled(o, d, tOS); // update intersection point
a = (float)Math.atan2(-ray.hitOS.z, -ray.hitOS.x);
if (a > theta) return false;


// we haven't actually tested this yet at this point
if (ray.hitOS.y < miny || ray.hitOS.y > maxy) return false;

} else { // both near and far intersection flunked accept angle
return false;
}
}
}

ray.tWS = tWS;

ray.object = this;
return true;
}

public void computeNormal(Ray ray) {
Vector3D nOS = new Vector3D(
A2 * ray.hitOS.x,
B2 * ray.hitOS.y,
C2 * ray.hitOS.z);


OStoWS.transformNormal(nOS, ray.n);
ray.n.normalize();

}

c# - How to make my characters turn smoothy while walking on a path(list of coordinates)?


I have a list with coordinates - output from A* algorithm - and I would like to make my characters smoothly follow this path with rotations.


So I have something like A and I want to get C



enter image description here


How can I do this ?


EDIT


To make myself a little bit more clear:


I am more interested in smooth turning as I already know how to walk from one node to another.


EDIT


As many people find this useful (me too) I am posting link to Daniel Shiffman's "Nature of code" where he discusses a lot of game AI (and physics) problems e.g. steering behaviours http://natureofcode.com/book/chapter-6-autonomous-agents/#chapter06_section8



Answer



If you want smooth paths in a tile-based environment, there's no way around applying some path-smoothing on your A* waypoints. In his book about programming game A.I., Matt Buckland describes a simple and fast algorithm to smooth a path (basically remove all edges that can be removed without causing an intersection with your obstacles).


Once you have remove unnecessary edges like this, your first case (A -> B) is solved. Smoothing out the edges in your graph could be accomplished in several ways. Most likely, Hermite splines would work (depending a bit on your obstacle density and tile-size). Another option could be steering behaviors, where you start to steer towards the next waypoint, as soon as you're half a tile away from the current target (this really depends on how fast your "agent" moves/turns).



catenative verbs - Is this a predicative adjunct?



Harry swung at it with the bat to stop it from breaking his nose, and sent it zigzagging away into the air. (Harry Potter and the Sorcerer's Stone)



‘Zigzagging’ seems to be a predicative adjunct as the case below. Can both be the same case?



They served the coffee blindfolded. [predicative adjunct]

(The Cambridge Grammar of the English Language, p529)




Answer



I finally gave up trying to answer this myself and took the problem over to ELU. As I hoped, John Lawler came through.


The construction has apparently not been named, but JL suggests treating it as a serial verb construction (SVC) of two or more verbs in sequence, like go swimming or Come help me! He describes the construction in your example as [my emphasis]:



... the initial verb part of the serial verb is



  • an intransitive motion verb (go, come)

  • a transitive causative/inchoative of a motion verb (respectively: take, bring)


  • a transitive verb that entails some kind of induced motion (pluck, send, toss, drop, etc.)


while the gerund* part normally describes some property of



  • the motion induced by the verb (lurching, zigzagging, spinning) [OR]

  • the object or person caused to move (muttering, shuddering, screaming, unmoving)


In either case, it is the moving object that functions as subject of the gerund constituent.
* I believe he uses gerund in the sense CGEL uses gerund-participle.




He goes on to remark that this construction is 'discontinuous', like a "phrasal verb" where the second part of the verb comes after the object. Thus sent it zigzagging is analogous to do it over or ask her out.


Fascinating stuff. There seems to be a substantial literature on SVCs, but mostly about languages other than English (including your own). I did find this article; section 2.1 is most relevant, but the conclusion is of great general relevance.


Do look at JL's answer for more detail. And I think you will particularly enjoy his following Comment about Harry Potter.


2d - How do I rotate a bounding box together with a sprite?


I have a game object with a sprite that can rotate. It's a rectangle. I need its bounding box to rotate with it. How do I make sure that they can both rotate, but they're always both at the same angle?



Answer



Each corner should be rotated around the center of the box.


Typically this would be done by translating the box back to the origin, rotating, then translating back to the starting position.


Imagine the points that make up the corners rotating around a circle:


enter image description here


For rotating each point, see this answer.


Friday, October 27, 2017

3d - What are "world space" and "eye space" in game development?


I am reading a book about 3D concepts and OpenGL. The book always talks about world space, eye space, and so on.




  • What exactly is a world inside the computer monitor screen?





  • What is the world space?




  • What is eye space? Is it synonymous to projection?





Answer



Before understanding what is the world or eye space, what is a space?


In an abstract sense, a geometrical space (e.g. Euclidean Space) is a boundless extent where objects tend to exist. The space defines basic properties that objects living in this space should satisfy. For example in euclidean space distance is defined as Sqrt( vector dot product with itself).


Most people tend to mix between the definition of Space and Coordinate system. A space as euclidean space defines the properties but doesn't define the coordinate system, I would say "eye space" is better called "eye coordinates".



In computer graphic we almost exclusively deal with euclidean space. When you define a Vertex of (X,Y,Z) in euclidean space it doesn't mean anything as is to us.


A more tangible definition would be to define it relative to some coordinate system. For example a Vertex(X,Y,Z) is relative to eye coordinates. So if Vertex=(0,2,3) relative to the eye coordinates. it means that this vertex is:




  • 0 in the X direction from the eye X position.

  • 2 in the Y direction from the eye Y position.

  • 3 in the Z direction from the eye Z position.

  • And the vertex distance from the eye is sqrt(0^2 + 2^2 + 3^2)=sqrt(13) unit.




But what is eye coordinates and how do we define a coordinate system ?


We define a coordinate system by providing three orthogonal basis(read: unit length and perpendicular) vectors which resembles orientation, and a position(translation). enter image description here


So if the camera in openGL was defined (note that this is relative to World coordinates):


 - Position (0,3,10)
- Up (0,1,0)
- Forward (0,0,-1)
- Right (1,0,0)

This means that the viewer is setting at (0,3,10) from the world (0,0,0) and his right is aligned with the world X axis, and his forward is reverse the world Z, and his up is aligned to the World Y.


enter image description here



But you talked too much about the eye coordinates, what is the World Coordinates?


World coordinates is just a fixed parent coordinate system. The eye coordinates itself should be relative to something. This is the global coordinate system that everything is defined relative to.


World Coordinate has a fixed i=(1,0,0) in the X direction, j=(0,1,0) in the Y direction, k=(0,0,1) in the Z direction. These are the vectors that define Cartesian coordinate system.


But that doesn't make sense! What is the coordinates that World coordinates is defined relative to?


I would say it's relative to itself, in reality that would be the center of the universe (but that's too simplistic).


But in a more practical sense, I would say in Computer Graphics it's convenient to define world space as the center of the universe (game world) so we can imagine how things can relate to each other.


3d - Data Structure (or algorithm) for fast distance-based entity lookups


For example, your game has 100 enemies (on different teams) running around and their AI wants to inspect the nearby entities to see which it should attack. What is a fast way to organize those entities so that each enemy does not have to calculate the distance between itself and all other entities?


In short, what is a fast way for an AI entity to answer the question "Who is near me?"




Answer



You want a spatial index such as quadtree (2D) or octree (3D).


unity - When shouldn't I use object pooling?


Are there any cases where I should not use object pools but instead rely on Instantiate and Destroy? (Or more generally, outside of Unity, creating objects on a per-instance basis instead of with a pool)?



Answer



It depends why you were using object pooling in the first place. Pooling mainly addresses problems with objects that are expensive to construct and which benefit from locality of reference.


Whenever you have objects that aren't expensive to construct and/or don't need to have high locality of reference, there might not be a lot of benefit to using a pool, and indeed you may start to incur some disadvantages:




  • Pools generally work on a fixed-block-size principle, and if that fixed size greatly exceeds the number of concurrently alive instances, you're wasting memory.





  • Similarly, if you can't reasonably bound the maximum number of instances, you're left with either not being able to use a pool, or use one that "grows" by allocating another fixed-size block. This starts to undermine some of the initial advantages of using a pool.




  • If the cost of resetting a "released" slot in a pool (so it can be used by a future instance) is higher than the cost of initial construction, that's a mark against using a pool for such objects.




  • If you're using a pool for improved locality of reference you generally want to swap released objects with the last used slot so you have a clear separation in the pool between "alive" and "dead" slots. If the cost of that swap is high, or if some other aspect of the object semantics require the ordering within the pool to be preserved, pools might be a poor choice.





Is Google App Engine a good platform for an online MMO?


I'm looking at some ideas of creating a smale scale MMORPG game, based in Java, this is a side/hobby project to help my learning process


I've already had a play with GAE and have put up a simple web app, I'm thinking of using this as my platform for a game


Is this a good idea? Are there any games out there that use such a platform? I can't see any limitations so far, other than Google might be able to "own" it rather than myself




level design - Voxel heightmap terrain editor


I've recently been experimenting with a simple Voxel-based 3d engine (think Minecraft) which uses heightmaps to define terrain in the following format:


http://en.wikipedia.org/wiki/Heightmap


Does anyone know of the best software for producing these kind of maps? Preferably with the ability to define a texturemap also. Are terrogen and picogen the only real alternatives?



Answer



Rolling your own is nice, since then you can just create maps, without needing to supply an image, or at least make the image optional. I use Perlin noise in my voxel game for terrain generation. It works pretty well, but is fairly plain compared to the maps that Minecraft produces. I imagine Notch does a lot more than just Perlin noise.


In my game I use 2D Perlin noise to generate the basic flow of the landscape. Then do some carving with another grid of 2D Perlin noise to make a more rugged look. Then I carve tunnels using a wandering path through the terrain.


Perlin noise is a pretty standard way to go:


https://stackoverflow.com/questions/4753055/perlin-noise-generation-for-terrain


Then this guy Paul Martz has an application that makes such maps, and the source code for doing so.



http://www.gameprogrammer.com/fractal.html


There's also a nice article in Game Developer that goes into procedurally generating voxel terrain. It goes into 2D height maps, and 3D noise for generating maps.


There is an article in the April issue on page 21 (Creator of Worlds) That's rather good, however it looks like it's paid access if you don't already have a subscription.


Thursday, October 26, 2017

adverbs - Is this word "precariously" add meaning to the first of the sentence or else?



The tall, forbidding palace perched atop the very edge of the mountainous cliff, overlooking so precariously the vast, black body of water below that it appeared almost ready to plummet into the latter's dark depths. [Warcraft War of the Ancients #1]  



Does the word "precariously" add any meaning to "the vast" for "The Forbidding palace"?



Answer



The word "precariously" is adding to the word "overlooking" in the combined phrase "overlooking so precariously", which then links to the later part of the sentence making the meaning "overlooking so precariously ... that it appeared almost ready to plummet". The use of the phrase "the latter" is used to indicate the twist in the word ordering. "the latter" means "the thing I just wrote earlier", which is the "vast black body of water".


java - When should I load assets for optimal performance?


I'm writing a game using LWJGL and Java, and was wondering if there were best practices for when to load resources.


I have seen examples that load all resources when initializing the game (XNA), ones that load the new resources needed for each level while referencing the already loaded assets again.




rendering - Drawing a circle in OpenGL ES Android, squiggly boundaries


I am new to OpenGL ES and facing a hard time drawing a circle on my GLSurfaceView. Here's what I have so far.


The circle class


public class MyGLBall {

private int points=40;
private float vertices[]={0.0f,0.0f,0.0f};
private FloatBuffer vertBuff;



//centre of circle

public MyGLBall(){

vertices=new float[(points+1)*3];
for(int i=3;i<(points+1)*3;i+=3){
double rad=(i*360/points*3)*(3.14/180);
vertices[i]=(float)Math.cos(rad);

vertices[i+1]=(float) Math.sin(rad);
vertices[i+2]=0;
}
ByteBuffer bBuff=ByteBuffer.allocateDirect(vertices.length*4);
bBuff.order(ByteOrder.nativeOrder());
vertBuff=bBuff.asFloatBuffer();
vertBuff.put(vertices);
vertBuff.position(0);



}

public void draw(GL10 gl){
gl.glPushMatrix();
gl.glTranslatef(0, 0, 0);
// gl.glScalef(size, size, 1.0f);
gl.glColor4f(1.0f,1.0f,1.0f, 1.0f);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertBuff);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 0, points/2);

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
gl.glPopMatrix();
}

}

I couldn't retrieve the screenshot of my image but here's what it looks like enter image description here


As you can see the border has crests and troughs thereby rendering it squiggly, which I do not want. All I want is a simple curve.



Answer



I can't imagine how your code would produce the image you linked. I could however, imagine how it might produce an image like this:



enter image description here


With flat sides. So really what you want to do is increase the number of sides. Try setting:


private int points=40;

to something larger like


private int points=360;

If you wanted a loop like your image instead of a circle you can do something like this:


public float[] DrawLoop(float centerX, float centerY, float sides, float innerRadius, float outerRadius) {
float[] vertices = new float[(sides+1)*4];

for (int i = 0; i <= sides; i+=4) {
verticies[i+0] = centerX + (sin(toRadians(360f * (i / sides))) * innerRadius);
verticies[i+1] = centerY - (cos(toRadians(360f * (i / sides))) * innerRadius);
verticies[i+2] = centerX + (sin(toRadians(360f * (i / sides))) * outerRadius);
verticies[i+3] = centerY - (cos(toRadians(360f * (i / sides))) * outerRadius);
}
return vertices;
}

Wednesday, October 25, 2017

What's the best server architecture for real-time games?



I'm developing a Real-Time game which should hold thousands of players in real-time (FPS like. max 1s lag). What would be the best infrastructure for this?


My idea was using 2 server clusters - one for the Server End (all the computing side) and one for the Database end, where a load balancer is "responsible" for each of the clusters. One main server will receive the requests from the users and send back the IP address of the relevant server that the user can work this.


The database cluster will use database replication for consistency between the databases.


There should be a geographical load balancer as well - so it will assign the regional load balancer to each user for best response.


I'm using .NET + MSSQL for the game.


Thanks!




sprites - Top-Down mapping with GLEED2D: Collision and Faux 3D


This is just a theoretical question. I was thinking of using GLEED2D to map a top-down game (I haven't decided on what type, but that shouldn't matter for this question.). I chose GLEED2D because I was getting tired of tile-based maps, and wanted to try something new.


However, two questions come to mind: How would you implement collision, and how would you display faux 3d? (I can't come up with a better name. It's where in RPGs and other topdown games you can have a bottom wall that obscures your character if you walk up to it. Say there's a pillar on the map. On a tiled map, it takes up one tile of space that you can't move on to, but the sprite itself is taller than one tile, so it covers character when you are behind it.)


An idea I had was to use the primitive shapes such as the Path to define areas where the character should collide. But then there's the faux 3d issue, which I can't figure out. Maybe GLEED2D isn't meant for it?



Answer




Problem #1 - Collision Detection


Under the assumption that you will use Gleed2D mostly for sprite based level editing, i.e. by placing, rotating and scaling a set of rectangular sprites in the world, I would suggest one of the following approaches to collision detection depending on your needs (read to the end even if the first suggestions don't apply to your case):




  1. Use a physics engine such as Farseer or Box2D to handle both collision detection and collision response between physics bodies that are good representations of your sprite's bounds. These bodies could be simple oriented bounding boxes or some other shape if more appropriate. Good for when the collision geometry should be fairly similar to the sprite's look.




  2. Similar to number 1 but handling collision detections yourself using an OBB-OBB intersection test between your sprite's bounds. See the Separating Axis Theorem for one common way to implement this sort of intersection. That's only valid if you want to use the sprite's bounds as the collision geometry though.





  3. If you wanted you could also add an additional pixel perfect collision test after step 2 by checking the opacity of the pixels on the sprites against each others. For this you'd need to transform pixels into the same space first. But I wouldn't really recommend doing this, and would go with one of the other alternatives instead.




  4. If on the other hand you need different collision shapes than the sprite's bounds then I think your idea was right on track. So what I'd suggest in that case is to add a new layer on Gleed2D just for collision geometry, and draw it using the Path tool. I actually do something similar to this on my graphic adventure game engine, although I use my own editor for creating the geometry. Here's a video of how it behaves. You could always add this functionality outside of Gleed2D if needed, and it's pretty easy to do using the Clipper library as I did on the video above.




Example:


enter image description here




Problem #2 - "Faux 3D"



I'm not sure I really understood your problem, but from my interpretation, I think it's just a matter of choosing the correct drawing order for your sprites. The approach I would take would be:



  1. Assign an origin to each sprite that would act as the sprite's "feet", i.e. a point in the sprite that is touching the ground. In its simplest form, you could simply pick the middle-bottom point of your sprites.

  2. Sort your sprites so that they're drawn starting from the ones with lower origin Y values and moving towards higher origin Y values. This way, objects further down the screen will automatically occlude objects that are supposed to be behind them.


Example:


Note: I marked the origins on the sprites using a blue dot, and drew them top to bottom. I assume this is the effect you were talking about.


enter image description here


Tuesday, October 24, 2017

game design - How do you prevent inflation in a virtual economy?


With your typical MMORPG, players can usually farm the world for raw materials essentially forever. Monsters/mineral veins/etc are usually on some sort of respawn timer, so other than time there really isn't a good way to limit the amount of new currency entering the system.


That really only leaves money sinks to try to take money out of the system. What are some strategies to prevent inflation of the in-game currency?



Answer



Money sinks are I guess the only real answer. Which means items or currency getting lost forever.


Eve Online blatantly has this through the mass destruction of items and ships through pvp (only partially replaced by insurance). Eve also has many other money sinks such as office rent, station fuels, ammunition etc.


Other games have similar consumables, either necessities like ammo or items that provide buffs etc. (food, potions, pet food, poisons etc.)


Many games (such as World of Warcraft) feature Bind on Pickup and Bind on Equip items. They are actually money sinks. You can enchant and add gems to your items but at some point you will upgrade it. So upgrading actually destroys the old item along with any value added to it via enchanting etc. Or in some games you can 'recycle' it for less that the original value.



This is a nice sink because it doesn't negatively impact players. They only really notice it at the same time as they are cheering about their brand new shiny loot. Also, even if the item is never lost and just remains in a character's backpack it can be considered out of the economy because it will never pass to another player.


Which brings us to other utility money sinks like increased bank and inventory space.


Aesthetic upgrades are also a good way to introduce sinks without affecting the gameplay balance of your game. Things like clothing dye or vanity mounts and pets.


tense - "I look forward" or "I'm looking forward"?


Which should I say:



I'm looking forward to our meeting.



or



I look forward to our meeting.





mathematics - Are there any disadvantages of using Distance Squared checks rather than Distance?


I use distance squared checks for basically all my distance (vector3 length) checking, due to the performance increase from not incurring a square root (like in plain length checks).


From the looks of it, squared distance checks work fine in every situation:


if x^2 < y^2, then x < y, even when 0 < (x or y) < 1



I am not considering situations where x or y is less than 0, as distance and distance-squared is always going to be positive.


Since this works, it looks like distance checks are never ever needed, but I have a nagging feeling that i'm missing something. Will this still hold up in accuracy-critical situations?



Answer



There's no disadvantage I'm aware of when using squared length to compare distances. Think about it like that: You're just skipping the sqrt which doesn't give you any additional accuracy. If you don't need the actual Euclidean distance, then you can safely leave the sqrt out.


Of course the squared length scales quite differently than the Euclidean distance and is therefore a bad candidate for things like pathfinding heuristics.


synonyms - Difference between "advantage" and "benefit"?


From Webster:


advantage:




  • something (such as a good position or condition) that helps to make someone or something better or more likely to succeed than others

  • a good or desirable quality or feature

  • benefit or gain




benefit:




  • a good or helpful result or effect

  • money that is paid by a company (such as an insurance company) or by a government when someone dies, becomes sick, stops working, etc.

  • something extra (such as vacation time or health insurance) that is given by an employer to workers in addition to their regular pay



It seems same to me. My professor use benefit more, some website use advantage more, is two of them same? or which one is more official?





Monday, October 23, 2017

Necessity of a definite article before the antecedent of relative pronoun


From "NASA’s computers used to wear skirts. They’re finally getting the attention they deserve" by Rachel Feltman in The Washington Post, August 17, 2016.



Take that in for a second: Johnson was helping her country win the space race, calculating trajectories that got spacecraft in and out of space, for a decade before it became illegal for her co-workers to discriminate against her.



Why don’t we need a definite article the before trajectories while it is specified by the following that clause? If I put the there, what difference will it make?




word choice - the other/other


I have been struggling with the understanding of the others/others. I know that'the other or the other' is used when you talk about rest of some identified group, it is like 'the remaining ones'.


So e.g. here:



I implemented 50 out of 100 requirements. The others will be implemented tomorrow.




Is that correct?




Sunday, October 22, 2017

2d - Efficient way of drawing outlines around sprites


I'm using XNA to program a game, and have been experimenting with various ways to achieve a 'selected' effect on my sprites. The trouble I am having is that each clickable that is drawn in the spritebatch is drawn using more than a single sprite (each object can be made up of up to 6 sprites).


I'd appreciate it if someone could advise me on how I could achieve adding an outline to my sprites of X pixels (so the outline width can be various numbers of whole pixels).


Thanks in advance,




Answer




By far the easiest way to do this (so probably the best way, unless you are really strapped for performance) is to have two copies of your sprites.



  • The regular version

  • A"fat", uncoloured version - basically a white version of your sprite X-many pixels "fatter" than the original.


Draw your entire object using the "fat" version, then draw the regular version over the top.


By making the "fat" version white, you can use SpriteBatch's built-in colour tinting to change the selection colour dynamically.


To generate your "fat" verison I recommend writing a Content Pipeline Extension that can automatically take your original sprites, read their alpha channel, create a new alpha channel by sampling the maximum alpha channel in the original image X-many pixels around each pixel, and setting RGB = (1,1,1).


You will have to make sure your sprites all have sufficient transparent border to add the outline (you could check this in the content processor - and even make room if necessary).


If you only have a few sprites, then you could just use a good image editor (GIMP, Photoshop) and do it by hand: Alpha channel to selection, expand selection, selection to alpha, fill colour channels white.



javascript - HTML5 mobile game development vs. native game apps



What is the current state of game engines, frameworks, libraries and conversions related to the HTML5 set of technologies (including CSS3 and JavaScript libraries such as RaphaelJS, Impact, gameQuery); and how does the best of that compare with developing a native app (especially for iOS and Android)?



Especially in terms of performance, visuals and getting that "native feel".


Thoughts on solutions such as Appcelerator and Corona SDK are also appreciated. In regards to Unity3D, is it possible to develop in it and still have the game be playable on a browser (such as current releases of Chrome or Firefox, at least) without any dependencies or having the user install anything (no unity web player).


What I'm looking for is how to develop in web standards as to reach the maximum number of platforms (including outside mobile) while still retaining a native experience for mobile without having to implement the game anew for iOS and Android.




algorithm - Calculate 8 different directional input based on arrow keys combinations


Considering I have four variables event binded to each arrow key, that can be 0 or 1


My current approach to this issue is simply 8 nested ifs checking each combination or keys


Is there a more math-y clever way to solve this issue?




c++ - How to hide assets from user? ( e.g.: a png file )


I think the title is quite self-explaining, still this is a big area I think, so let me drop a few words:


I've got a simple experiment game project going, and I want to make sure, that the user isn't messing with the game assets like player skin etc.


In my opinion the best way would be that on production I would merge all the assets into one file and the application would check the hash of that file, so it could detect the corrupted data.


Is this an acceptable practice? There must be sum libraries / applications which are targeting this problem, could you guide me on this?



Project details: unix/linux, c++, sdl



Answer



My answer to this question won't be complete, because there is no real good way to achieve what you want.


Assume you would pack all your assets in one zip file and compute the hashes. This leads to the problem that you need to recompile your project if you hardcode your expected hashes. However if you save the hash in another external location, you would need to protect that, too.


One method to protect your assets I often rely on is using PhysicsFS to pack my assets in different packed zip files. In order to protect them, you could use some kind of symmetric encryption to secure your archives. If you do not plan any AAA-game this should be fairly enough to protect everything. But keep in mind, too much encryption etc. won't be useful and eventually decrease performance if you load your assets on-the-fly.


2d - How do you handle uneven tiles while rendering a tile map?


enter image description here



Here is what I want to do with my tile map that I am unsure of. As you can see the top walls are way larger then the bottom and side ones (this is also an issue with my corners which are odd shapes [more like an L then a square] as well as larger then the 40x40px that my current tiles are).


enter image description here


I have also attached the tile sheet I am using for the tiles to show you what the corners and tops look like compared to the rest of the tiles.


What I’m thinking is I might be able to just draw them using the same array I have if I use the tiles width and height instead of a set WxH? I dont know how well this will work, but were the blocks that will have different values will be blocks the player/NPCs can’t step on then it may not be an issue, again I’m not even sure if that is a viable solution.


My code in case you want to see how I'm currently handling it: Map.java (pastebin) (edit:im not handling it, meant how I'm currently doing the map)


tl;dr - how can I take take my 2d looking tile map and change it to have different size tiles? or is there a better way to do what I am trying to do? Is there a name of a method that I should be looking for while googling?



Answer



There are two standard ways of doing this.



  • Break up your non-standard tile sizes into standard tile sizes. So those strips of walls become a "stack" of square tiles that you just know to place together in your level editor. Games like the early Final Fantasy games worked this way.


  • Let any tile piece be taller than your standard tile height. Align tiles to the bottom of your tile rectangle, allowing any extra to draw higher than the usual tile height. When drawing your map, you draw tiles starting from the back (the tile squares higher on the screen), and ending with the bottom tiles (the ones at the bottom of the screen). This ensures that tall tiles in the foreground are properly overlayed on top of tiles in the background. Note that in this approach, your tiles are still limited to a single tile in width.


You can do either or both of these approaches. Even games which do the "break up into stacks of tiles" approach will often allow some objects (trees, etc) to break the tile height limits, and just enforce a top-to-bottom map draw ordering in order to make sure everything layers correctly.


Servers are never available to download CryENGINE


I have been having some trouble downloading the CryENGINE. I am directed to log in and download the engine through the CryENGINE Launcher, but whenever I try to log in, I get the error "Login failed. Server unreachable."


I can not find any reports of server malfunction, and others seem to be using it perfectly fine. This has gone on for over a week now. Whats going on?



Answer




"Server unreachable" is actually a poorly-worded error that appears to be associated with trying to log in with an unconfirmed account.


When you first create the account, Crytek will send you an email to confirm the account. Until you actually confirm the account, attempting to log in through the CryENGINE Launcher will give you the error "Server unreachable".


Unfortunately, confirming your account may also be bugged.


Sometimes, confirming your account may be harder than you would think. Crytek send you the email, and you click on the link to confirm the account. This takes you to a page that acknowledges your confirmation, but the launcher still gives you the "server unreachable" error.


Sometimes, the link takes you to a page asking you to log in. When you attempt to log in, you are asked to confirm your account. If you follow the link provided via email, it takes you back to the same page, and the vicious cycle repeats itself. Attempting to resend the confirmation email may, instead, send you a thank you for confirming your email. Despite this apparent acknowledgement, you still can not log in to the CryENGINE Launcher.


This appears to be a known, yet uncommon, problem. Unfortunately, the only direct solution I have found is to contact Crytek, directly. The only times I have seen this solved is through direct communication on the forums, which in turn requires you to have a confirmed account to access, giving you a painful Catch-22 not being able to contact Crytek was especially relevant to my question and answer, but I have since found contact through email at cryengine@crytek.com. This may be a helpful point of contact, if anybody runs into the same problem, and really wants to keep their original username or associated email.


By far, the easiest solution is to make a new account with a different email.


After several weeks of frustration, this solved the problem, for me. If you signed up with a particular email or username you really must have, use your new account to communicate with Crytek, who can directly toggle the "confirmed" switch on your original account.


Saturday, October 21, 2017

grammar - "He lay on the bed gazing up at the ceiling." - Is this sentence from a dictionary correct?


In the definition article of "gaze" (MacMillan Dictionary) I found the following example sentence:



He lay on the bed gazing up at the ceiling.



I cannot figure out what form "he lay" should be. My alternatives are "he lays" or "he laid" but not "he lay".


Is that sentence correct? If yes: what form is "he lay"?




Ohhh! After reading the answers (thx!), I found the source of my confusion: in this online dictionary you can click on each word and you would be forwarded to its definition. Clicking on "lay" in this sentence forwards to "lay (verb)" what is obviously a tricky linking error of the dictionary.



Answer




Lay in this case is the past of "lie", which is an intransitive verb. The difficulty occurs because "lay" can be a form of two different verbs which have similar meanings:



  1. lay, laid, laid (transitive): to put someone or something down in a careful way, especially so that they are lying flat https://www.macmillandictionary.com/dictionary/british/lay_1

  2. lie, lay, lain (intransitive): to be in a position in which your body is flat on a surface such as the floor or a bed https://www.macmillandictionary.com/dictionary/british/lie_1


Even native speakers get tripped up on the proper forms. "Lain" in many cases sounds old-fashioned to some people.


determiners - When can we omit the preposition "of" in such cases?


I'm struggling to understand when we can omit the preposition "of" in cases when we use determiners in English (distributives and quantifiers).


I mean we all know that both "half the students were absent" and "half of the students were absent" are correct as well as "all my friends are there" and "all of my friends are there".


I would like to know the rule - when can we or can't we omit the "of"?



Scrolling through various examples online I've noticed that even with "all" and "half" it doesn't always apply and sometimes we can use it with other determiners and other times - not:



  • Both of the cars were stolen. (can we omit "of"?)

  • Half of every apple on the table was bitten. (can we omit "of"?)

  • All of it was a lie. (can we omit "of"?)

  • Several of my books were printed in Canada. (can we omit "of"?)

  • Most of the people living in our town are teenagers. (can we omit "of"?)




game loop - Replay system: record inputs or events?


I read this: How to design a replay system But it don't really answer my question.


My game is built with the client "view" of the game as a separate program from the server "model" and "controller". (a bit like a mmo, or any multiplayer game built this way). The server side is always the "truth" of the game, it only accept action requests as input from the clients and output events and "current state" messages.


The game model and rules are fully deterministic with a fixed "tick" update cycle, so on the server side I can record both the events sent to the client views, and the action requests. Both are associated to specific cycle number.


The question is: in this case, to setup a replay system, should I use the input, or user action requests (as suggested in there) or the events?



It looks to me that both would give exactly the same output. The only differences I can see are:



  • Events gives the real output while action requests have to be processed to give events.

  • Action requests might be far less data to record.


Are there other things to consider?



Answer



Given a deterministic system they are logically equivalent so your summary is pretty much correct. However there are 2 more things that would sway me towards recording input actions rather than output events:



  1. If you save the actions, you can use them as test data later, as they exercise more of your code than just replaying events will. This can help with diagnosing crash bugs, finding behavioural regressions between builds, etc.


  2. In future you might change the events that you send for a certain action, or you might send different events to different clients for some reason. In this case, the replay could become invalid or incomplete. The same problem could in theory apply to inputs, but usually the domain of inputs is more constrained than outputs and so is less likely to change and easier to accommodate with backwards compatibility when it does. (Inputs are limited to what the player and other input sources (eg. random number generator) can do, whereas the outputs include all the results of those inputs plus any other outputs generated by the game rules, such as presentation hints, periodic server-side events, etc.)


grammar - Do these sentences in each set mean the same or not?


Could you possibly let me know whether both of the following sentences in each set mean the same thing or not:


A) - I can’t wait for you until 8 p.m.



  • I can’t wait for you up to 8 p.m.


B) - I can’t wait for you until one week.



  • I can’t wait for you up to one week.





grammaticality - "Isn't it time you stopped acting the goat"- Is this correct grammatically?


Another question from Tintin's Flight 714. At a particular time, Professor Calculus started acting very foolishly in front of some respectable people. So, Captain Haddock, Calculus's friend, whispered into the professors' ears:



Isn't it time you stopped acting the goat?




I read it in my mind as:



Isn't it the time you stopped acting like the goat?



I admit, during speaking, people can forget the "the" and "like" (although I wouldn't have forgotten adding the "like"), but using "the" before "goat" seems a blunt grammatical mistake. I think it should be "a" instead of "the". It could have been "the" if Haddock was comparing the Homo sapiens (human) species with the Capra aegagrus hircus species. But he was comparing a human from the human species with just a goat from the goat species. So it should be "a" instead of "the". How come then Haddock used "the" instead of "a"? Or is it just a simple error while speaking?




prepositions - In the morning VS on the morning


Which one is correct? (Maybe both are correct.)



He passed away on the morning of March 5.



Or




He passed away in the morning of March 5.





tense - Preterite perfects with a doubly remote intrepretation



If they had gone tomorrow they would have met her son.

I’d rather you had gone tomorrow.


-- The Cambridge Grammar of the English Language



I have familiarity with temporal anteriority of perfect tense, but not with the perfect above. The book says they are doubly remote with future time. It seems like it says the preterite expresses modal remoteness and the perfect makes further remoteness, and so they call it doubly remote construction. It amazes me that perfect tense makes time distance not backward but forward for making psychological remoteness.


Do you really make psychological distance by using preterite prefect with future time, or is it just an imaginary possibility?



Answer



You seem to be misreading slightly.



It seems like it says the preterite expresses modal remoteness and the perfect makes further remoteness, and so they call it doubly remote construction.




Yes. In both of your examples, CGEL makes the point that the doubly remote construction is necessarily counterfactual ("If they had gone tomorrow" necessarily means "they're not going tomorrow", perhaps because they already went yesterday, and "I'd rather you had gone tomorrow" necessarily means "you're not going tomorrow"); whereas with the preterite alone, as in "If they went tomorrow" and "I'd rather you went tomorrow", they wouldn't necessarily be counterfactual. (However, CGEL also gives some present-time examples where the doubly remote construction is not necessarily counterfactual.)



It amazes me that perfect tense makes time distance not backward but forward for making psychological remoteness.



No. The remoteness here is not the remoteness of future time; after all, CGEL says this construction can occur "with present and future time" (emphasis mine), and explains in a footnote that "The double remote construction is not available for past time because the perfect construction is not recursive"; that is, the reason you can use the doubly remote construction with present and future time, but not with past time, is that with past time the perfect is already being used to express anteriority, so it can't be re-used to express remoteness (since *"if they had had gone yesterday" is ungrammatical).


pronouns - Where to find what "this" and "that" refer to?


I read from somewhere a long time ago that "that" refers to something that was mentioned earlier, while "this" refers to something that is going to be mentioned. But I saw some examples where "this" refers to something that was just mentioned earlier, and I was not sure if the examples were correct. What are the correct usage of "this" and "that"?


Note that I am not talking about the other meanings of "this" and "that" in terms of long or short distance from the speaker, but about their meanings in terms of referring to something in the context.


Thanks!



Answer




You are right about "this" refers to something is going to be mentioned. But we can use both "this" and "that" (and actually "it" too) to refer to something that was mentioned earlier too.


Here is an excerpt from a couple of entries in Practical English Usage by Michael Swan,



590.1 referring back


This, that and it can all be used to refer back to things or situations that have just been talked or written about. It does not give any special emphasis.


This and that are more emphatic; they 'shine a light', so to speak, on the things or situations, suggesting 'an interesting new fact has been mentioned'.
"So she decided to paint her house pink. This/That really upset the neighbours, as you can imagine."


This is preferred when there is more to say about the new subject of discussion.
"So she decided to paint her house pink. This upset the neighbours so much that they took her to court, believe it or not. The case came up last week ..."


590.4 referring forward



Only this can refer forward to something that has not yet been mentioned.
"Now what do you think about this? I thought I'd get a job in Spain for six months, and then ? (NOT Now what do you think about that/it ...)"



Friday, October 20, 2017

meaning - (of which) Seventy (of which) are from the northern region


I have a question about the meaning of two different sentences:




  1. The battalion consists of two hundred soldiers, seventy of which are from the northern region, stationed along the coast.

  2. The battalion consists of two hundred soldiers, of which seventy are from the northern region, stationed along the coast.




In sentences 1 & 2, does "stationed along the coast" apply to all two hundred soldiers of the battalion, or just the seventy soldiers from the northern region?




adverbs - "Most everyone" versus "mostly everyone"?


Saying "most everyone" is much more popular in books than "mostly everyone".




To compute the distance between two coordinates most everyone/mostly everyone uses the Spherical Law of Cosines equation.



Which expression should I use?



Answer



You've left out the most important alternative: almost. Here's an expanded version of your Google Ngram: enter image description here In most everyone, most is a contracted version of almost, an adverb modifying the every component of everyone. (Yes, I know everyone is written as one word, but syntactically it's apprehended as a 'pronominal' version of every. Any(one) works the same way.)


Most everyone and mostly everyone are colloquial variants; I advise you to avoid them in formal registers.


Thursday, October 19, 2017

meaning - How to concisely express 'at many place' similar to somewhere, nowhere and everywhere?


I searched on the Internet and found the opposite of 'somewhere' is 'nowhere.' This confuses me, because I see it like this:




  • The opposite of "everywhere" (at all places) is "nowhere" (at no places).




  • The opposite of "somewhere" (at some place) in my logic-thinking should be something like "manywhere" (at many places).





  • I know 'manywhere' is not an accepted English word. But the English construction {no, some, any, every} + "where" seems to have left-out a concise and logical way to express "manywhere".




The following fictional dialog demonstrates my questions/thinking. This is not factual:




  • "Have you heard about the ritual of hanging a voodoo doll on buildings under construction to keep away negative energy?"


    "Yeah, I saw that somewhere in my home town of New York City."


    "Well in India, you can find that everywhere."


    "What? Voodoo dolls are in every construction building in India?"



    "No! I mean, you can find that manywhere. Many places have it - not every one."


    (You see, I don't want to say, "In India, you can find that everywhere" because that would mean every construction building would have a voodoo doll.)




This question is not about "manywhere" which is asked here as a separate question. But it is to help me understand the logic behind the opposite of "somewhere" and how can one discuss "many places" with a lack of a "manywhere-type word". It's not logical to me. What are the various acceptable ways to express "many places" as described above? Can I use "many where"? It'll still solve the problem.


(I would like to acknowledge @CoolHandLouis for very helpful editing of this Question.)



Answer



(I address only your first question here; I hope you will break the second out to another post.)


SHORT ANSWER: Restrict your use of terms like somewhere and anywhere and everywhere to the colloquial register, and avoid them in the formal register.


LONG ANSWER:





  1. With regard to somewhere: the some part of this collocation never has the sense “a few”, contrasting with “many” or “all”. It always means ”at least one“ (in many, perhaps most, cases “exactly one” is implied: I can’t find my glasses; they’ve gotta be somewhere), and it contrasts with “none”. The antonym of somewhere is nowhere.




  2. With regard to everywhere: allow me to tip my hat to CoolHandLouis’ handle and say that “What we have here is a failure to communicate across registers.”


    The primary function of language—not just English but any language, not just some or many languages but all languages and every language—is to mediate ordinary everyday discourse: what grammarians call the ‘colloquial register’.


    I have written elsewhere on this site that the colloquial register is governed by the ‘Tolerance Maxim’: Whatever should be understood may be omitted. That is, the colloquial register tolerates a great degree of imprecision because speakers-together assume that they bring to the discourse a common understanding of words and syntax and the real world which does not have to be explicitly articulated.


    For instance, if you say to me, in the course of the conversation you have described, “Oh, yeah, we’ve got voodoo dolls everywhere in India”, there are many critical qualifications to that statement which you tacitly assume I bring to interpreting your utterance:




    • You assume that I understand that when you say voodoo you don’t intend a specific reference to the practices of Louisiana Voodoo or Haitian Vodou or American Hoodoo or Dahomeyan Vodun but to an Indian practice analogous to these.

    • You assume that I understand that when you say everywhere the scope of the every piece is not all places but the places specifically identified earlier in the discourse, viz., construction sites.

    • Most importantly for our current discussion, you assume that I understand that the collocation everywhere does not mean “in every place of the sort previously defined” but “widely distributed throughout places of the sort previously defined”.


    In the colloquial register this is not a problem: everybody understands that everywhere means “in lots of places”, just as somewhere means “in at least one place”. It only becomes problematic when you move terms like these into the formal register. The formal register is based on the written language, which does not tolerate nearly so much ‘conversational implicature’ as the spoken language. It is governed by the ‘Adamantine Law’: Whatever can be misunderstood will be.


    Scientists and philosophers and mathematicians and programmers require a very high degree of expressive precision. Their form of discourse needs terms like some and every and many to mean the same thing in every context; the common understanding which prevails in the colloquial register is intolerably contingent and sloppy for their purposes. (It is not in fact sloppy, it is quite precise; but it is contingent.) This is very amusingly illustrated in a brief monologue from the revue Beyond the Fringe in which Jonathan Miller impersonates the philosopher and mathematician Bertrand Russell; you may listen to it here.


    The upshot is that terms like somewhere and anywhere and everywhere should be avoided in the formal register. In fact, my wife (who teaches Freshman Composition at a local university) explicitly tells her students that the some-, any-, every- terms are Red Flags: they almost always tell her that the writer has failed to specify something which needs narrower specification. In the formal register using a coinage like manywhere, to distinguish your meaning from somewhere and everywhere is simply an evasion of the real problem, which is that you shouldn’t be using these terms at all. You should be saying exactly what you mean, which is probably something on the order of:



    We find dolls of this sort on construction sites throughout India.








The term ‘register’ is a musical metaphor. A register is a mechanical device on pipe organs, activated by a ‘stop’ on the manual, which determines whether a particular set or ‘rank’ of pipes is sounded in playing. The sense of the term was gradually extended to the particular pitch and timbre of a rank of pipes, then to the various pitches and timbres of other instruments and of the human voice, and eventually to the analogous ‘styles’ of language employed in various sorts of discourse.


xna - How to I coordinate a camera with the eyes of a model?


I am currently working on an FPS in XNA and I wanted to know how I would position the camera at the eyes of the model and whenever the model rotated or moved it's head (where the eyes are), the camera would move along with it. Also, whenever the player moves the camera (with their mouse) the model would turn it's head and eventually it's body.


I believe this would reduce the need for constant transformations and the planning of cutscenes by having an animation play and the camera follow that animation. It would also cut the need for transforming the model constantly when I add a future multiplayer.


I'm also open to any other ideas, so please, leave a comment letting me know what you think would be good and efficient.





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...