The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.
I am finishing up my computer science degree and will hopefully be going to some interview's for an entry level game programming position.
I am wondering what typically happens during an interview for a game programmer position. Like what type of questions do they typically ask, I heard they want you to demonstrate your coding so what type of things do they want you to code during the interview?
Also if I am going to show off a small game I have coded what type of things do they look for in that game? Like what language, libraries etc.?
Here are a couple of interview questions I've been asked. Come up with answers (no googling, it defeats the point of this exercise!) and I'll tell you what the interviewer would respond with.
Write a C++ class for a sphere object in a 3D world. Now, using that class, implement the function bool checkCollision(sphere sphereA, sphere sphereB), where it returns "true" if they are colliding and "false" if they are not.
Imagine a staircase with N stairs. When going up the stairs, you can take either one step at a time or two steps at a time. Find the number of different ways you can get to the top.
For example, if there's three stairs, you can:
1. Take one step at a time for all three steps.
2. Take two stairs, then one stair to the top.
3. Take one stair, then two stairs.
So the answer would be three.
Write a C++ function that calculates this.
Game programmer interviews will probably vary widely in the same sense as normal computer science job interviews. For example, Google/Microsoft interviews go very differently than the majority of other jobs out there. Likewise, you can expect drastically different interviews from Valve, Blizzard, 2K, etc. than you would from places like EA or Activision.
If you have any mod experience in any sense, that is extremely helpful.
I'm in a vaguely-similar boat as the OP (still have a few years left before graduating, but plan on entering the game industry as a coder). Out of sheer curiosity, is this the right idea for the first Q? (the actual C++ syntax might be kinda wonky; I've been using mostly C# and Java lately)
public class Sphere
{
int x, y, z; //the coordinates of the center of the sphere
int radius;
}
bool checkCollision(sphere A, sphere B)
{
int distance = sqrt( (A.x-B.x)^2 + (A.y-B.y)^2 + (A.z-B.z)^2) ); //distance formula
int collideDistance = A.radius + B.radius; //at this distance, the two spheres would be touching
return(distance <= collideDistance);
}
I'm in a vaguely-similar boat as the OP (still have a few years left before graduating, but plan on entering the game industry as a coder). Out of sheer curiosity, is this the right idea for the first Q? (the actual C++ syntax might be kinda wonky; I've been using mostly C# and Java lately)
public class Sphere
{
int x, y, z; //the coordinates of the center of the sphere
int radius;
}
bool checkCollision(sphere A, sphere B)
{
int distance = sqrt( (A.x-B.x)^2 + (A.y-B.y)^2 + (A.z-B.z)^2) ); //distance formula
int collideDistance = A.radius + B.radius; //at this distance, the two spheres would be touching
return(distance <= collideDistance);
}
Imagine a staircase with N stairs. When going up the stairs, you can take either one step at a time or two steps at a time. Find the number of different ways you can get to the top.
For example, if there's three stairs, you can:
1. Take one step at a time for all three steps.
2. Take two stairs, then one stair to the top.
3. Take one stair, then two stairs.
So the answer would be three.
Write a C++ function that calculates this.
Ahh recursion... I remember the days... Is it bad that I got sad looking at this because I don't have to use any recursion in my current job?
I tried the same thing out of college and never got into the game biz. Stupid Nintendo called me one day after I had signed my most recent contract! That and I wasn't fully prepared to move to the west coast.
Oh well I've had some varied experiences.
Volition had a wicked entry test that made me feel retarded. Lots of high level math to start. Then onto creating code examples. That was part one of their interview.
Can't remember which company, but it was a GBA coding job. All they wanted was for you to create a game demo for them. Like create a platformer. The character must accelerate while running when starting from rest and then speed would plateau. Also the character must collide with solid objects and not pass through them. Then create some platforms where the character could jump through the bottom of a solid object, but when land on top have the platform solid.
I'd say the most important thing I saw was having a portfolio of demo games to display. Show them you can grasp and code core concepts like collision detection, physics, some AI would be good too. 2D and 3D visuals.
It may be early, but it would help to have a focus like I want to be an audio engineer, or level design, AI programmer and cater your skills to the specific job. I found that computer science degree gave me a broad spectrum of skills, but during job searching really made me realize where my talents lie. I have no artistic skill which meant a good chunk of gaming work was already eliminated from my search. Could I make games? Yes, but they were ugly with bad audio choices. That meant I had to focus on showing I could do the background coding like engine work, physics, in house tools, AI.
Hopefully that gives you a good sense on how to start. Ask some friends to try out one of your games. And then get their opinion on the games and force them to be brutally honest about it. Do you think my artwork sucks, audio sucks, physics/gameplay didn't feel right? If yes then explain why.
Imagine a staircase with N stairs. When going up the stairs, you can take either one step at a time or two steps at a time. Find the number of different ways you can get to the top.
For example, if there's three stairs, you can:
1. Take one step at a time for all three steps.
2. Take two stairs, then one stair to the top.
3. Take one stair, then two stairs.
So the answer would be three.
Write a C++ function that calculates this.
Ahh recursion... I remember the days... Is it bad that I got sad looking at this because I don't have to use any recursion in my current job?
That's O(n^2). Can you think of a way to calculate it faster?
Damn you... I want to use recursion
eh... looking at it now it's just Fibonacci numbers so I'm sure there's a faster way. Probably just with a loop instead of bothering with the recursion...
something like:
int step (int num_steps) {
int x[n+1];
x[0] = 1;
x[1] = 1;
for (int n = 2; n<=num_steps; n++)
x[n] = x[n-2] + x[n-1];
return x[num_steps];
}
I'm rusty on my O notation, but I think that's O(n)
I'm in a vaguely-similar boat as the OP (still have a few years left before graduating, but plan on entering the game industry as a coder). Out of sheer curiosity, is this the right idea for the first Q? (the actual C++ syntax might be kinda wonky; I've been using mostly C# and Java lately)
public class Sphere
{
int x, y, z; //the coordinates of the center of the sphere
int radius;
}
bool checkCollision(sphere A, sphere B)
{
int distance = sqrt( (A.x-B.x)^2 + (A.y-B.y)^2 + (A.z-B.z)^2) ); //distance formula
int collideDistance = A.radius + B.radius; //at this distance, the two spheres would be touching
return(distance <= collideDistance);
}
That's the idea, yeah.
One thing to note is that they will test you for small optimizations amongst other things here as well.. For example, instead of having to square root the whole thing (sqrt is TRADITIONALLY slow.. they're not now depending on how they're done though), so you can just return true if the distance formula without the sqrt is <= the sum of the radii squared, i.e if( (sq(A.x-B.x) + sq(A.y-B.y) + sq(A.z-B.z)) < sq(A.r+B.r) ) . . .
they will also test to see if you're protecting your code properly and things like that. They will check for const correctness and other stuff which is important. If you don't know it then you should google that before the interview.
template <typename T>
static inline T sq( T x ) { return (x * x); };
class Sphere
{
public:
Sphere();
bool isInSphere( const Sphere * const other ) const;
float x,y,z,r;
};
Sphere::Sphere( void )
{
x = y = z = r = 0.0f;
}
bool Sphere::isInSphere( const Sphere * const other ) const
{
if( other != NULL )
{
return( ( sq( x - other->x ) +
sq( y - other->y ) +
sq( z - other->z ) ) <=
sq( r + other->r ) );
}
return false;
}
Something like that would be good if you can do that
One sphere could be inside the other, in which case they're not colliding. Need to check for that too.
Re: number of steps
Yeah, it's just the fib. numbers, which have a closed-form solution for the nth one. You could also do it from the bottom up in O(n) steps.
Most computer programming interview questions I've had/heard of will ask you to design a class or come up with an algorithm for doing something. Consider things like input sizes to your algorithms as well as other things like "how easy is it to take this class/these ideas and apply them to more general situations?" In other words, is the code you're writing just ad-hoc, or can it be easily re-used for other, similar things?
Most computer programming interview questions I've had/heard of will ask you to design a class or come up with an algorithm for doing something. Consider things like input sizes to your algorithms as well as other things like "how easy is it to take this class/these ideas and apply them to more general situations?" In other words, is the code you're writing just ad-hoc, or can it be easily re-used for other, similar things?
Yep, I've also had them ask me to design a parking lot in code, where there is an algorithm used to make sure that there are spaces for cars. Then they asked me to modify it so that I could fit busses, where there needed to be two end-to-end spaces to fit them. Then motorcycles, where you can fit two to a space.
The questions Doc asked are dead on the money as to what to expect from an interview. They're not super hard and they don't rely on trivia. They rely purely on logical, analytical, and coding skills.
As for some of the responses: one sphere being inside the other is most definitely collision. Curby, you're also dead on. I think you go too far on the const correctness (no reason for the pointer you take in to be const), but you make good sense.
Volition had a wicked entry test that made me feel retarded. Lots of high level math to start. Then onto creating code examples. That was part one of their interview.
I'm a programmer at Volition :-) One thing I should note about Volition is that we're a very tech-oriented company and, to put it plainly, you have to be a pretty good coder to get through the interview.
Here was how it worked for me:
1. Apply
2. Get a timed coding test. The questions get progressively harder, but you should be able to get 50% reasonably easy. 75%+ is a good score.
3. Phone interview
4. In-person interview - zomg. This was *very* scary. The questions were a total mix across the spectrum from compression to rendering to collision to basic logic. There were some questions that I got right away, there were some I needed some help with, and there was one that I didn't get at all.
Overall, expect to be stumped on some questions, and be able to write/talk about your reasoning. Marty: it may be the way you say at typical programming places, but not at game companies. For a question on a test/interview, they want your reasoning/answer. The code should work, be safe, and be relatively neat, but I've never seen anyone care about it being reusable. They might ask you to modify it on the fly, but typically, they're not looking to make sure your implementation is extensible.
Now, onto some questions that could/would be asked on a test/interview:
Write a function to randomize an array of integers.
Write a function to determine if a matrix (array of arrays) of integers is a magic square.
Write a linked list class.
What is the difference between an array and a linked list? A queue and a stack?
As far as what they'll look for in a demo/code sample... something non-trivial and either something not typical, or a spin on the typical (for example - if you want to do a particle system, make sure there's something unique about it, like that it can be controlled from a scripting language). My code samples were a small application to convert an R8G8B8 bitmap to a B5G6R5 array of color entries for use on the GBA and a neat lighting system I came up with for a project. Along with that, I had done mod work on an HL2 mod (SourceForts), and I had done the networking for an online FPS for a school project. I was applying as a network programmer, so obviously, having done networking for a game already was a huge plus. So, have one or two cool demos that can be explained relatively quickly and get some experience. Mods are the way to go.
As for some of the responses: one sphere being inside the other is most definitely collision.
Sorry to nitpick, but one sphere inside of another is not collision. You're thinking of balls, not spheres. See the mathematical definition in http://en.wikipedia.org/wiki/Sphere. I doubt your interviewer would dock you for solving the problem for balls instead of spheres, but I wanted to clear this up.
As for some of the responses: one sphere being inside the other is most definitely collision.
Sorry to nitpick, but one sphere inside of another is not collision. You're thinking of balls, not spheres. See the mathematical definition in http://en.wikipedia.org/wiki/Sphere. I doubt your interviewer would dock you for solving the problem for balls instead of spheres, but I wanted to clear this up.
Spherical collision detection means solid, despite whatever the mathematical terms are. I can't think of an instance in game programming where it'd be defined as a shell, which wouldn't be completely ridiculous.
I doubt your interviewer would dock you for solving the problem for shells instead of solids, but I wanted to clear this up.
I'm a programmer at Volition :-) One thing I should note about Volition is that we're a very tech-oriented company and, to put it plainly, you have to be a pretty good coder to get through the interview.
Your name looked really familiar, so I thought I just remembered you from PA forums, but then I remembered the name from the IGDA forums.
Rather than sitting here arguing semantics and shells and solids and spheres, would the interviewer actually dock you if you simply asked for clarification?
Not 100% sure, but it seems right, and it works on the simple test cases I was comfortable doing in my head.
Oh it's a bloody search problem.
Fuck, it looks so simple now.
I feel like an idiot
Definitely don't do it the recursive way, though. As stated before, this is O(n^2), and you're calculating each value twice. The better solution is to recognize it's a Fibonacci sequence and used a closed form (O(1)), or build your way up with a dynamic programming solution (O(n)). You can easily tell it's the Fibonacci sequence by looking at either the recursive or DP solution, though... d = d[i-1] + d[i-2], which is the definition of said sequence.
The best way to think about these problems is:
If you are on staircase n, don't count up from the bottom. Just imagine if you had an array (I'll call it A) already filled up of correct values for staircases 1, 2, ..., n-1. If you had this information, solving this really comes down to this reasoning: I can arrive on step n either by taking 1 step from step n-1 (and there are A[n-1] ways to do this, because I can arrive at step n-1 in A[n-1] ways), or I can arrive at step n by taking 2 teps from step n-2 (and there are A[n-2] ways to do this). Using this reasoning, you can quickly and easily calculate in O(n) with any ruleset. If, for example, I also said you could also... I don't know... jump from 3 steps back, but if you jump off your left foot or your right foot, it counts as different ways. Then your new dynamic programming solution would be A[n] = A[n-1] + A[n-2] + 2 * A[n-3], and all you have to do is fill up the 3 base cases.
Also, a TON of different problems can follow this reasoning and be solvable with dynamic programming in O(n). If you're ever asked to count the number of ways something can happen, immediately try to apply this line of reasoning. Another example has already been said; parking spaces. Suppose there are n parking spaces, and buses take up two, cars take up one, and 2 motorcycles can fit in one space. You can calculate the total number of ways a specified group of vehicles can fit in n spaces using exactly this approach.
For the record, I'm not a games programmer... though I have developed a game. I'm doing my Masters in computer science in graphics, though.
XenoScholar on
Check out my demonstration of the Street Fighter 4 hard trial combos, showing hands on the joystick, on my Youtube channel!
Current characters done: Ryu, Dan, C. Viper
Xbox Live: Infilament
Double posting because it doesn't really apply to my last post.
Here's a really great question which is fairly math-based.
Suppose you have a circular pond with radius r. There is a duck swimming around in the pond, and he can swim with a certain speed (call it s). However, a wolf comes up to the side of the pond and wants to get at the duck. The wolf cannot swim, but he can run at a speed of 4s (that is, 4 times the duck's swimming speed). The duck cannot take flight from the water, but he wants to escape the pond. He has to swim to shore to take flight, but obviously the wolf will be running around the outside of the pond, trying to meet the duck at the shore.
The question is... is it possible for the duck to escape from the wolf? If so, explain how the duck can do it. If not, explain why it is impossible.
XenoScholar on
Check out my demonstration of the Street Fighter 4 hard trial combos, showing hands on the joystick, on my Youtube channel!
Current characters done: Ryu, Dan, C. Viper
Xbox Live: Infilament
The question is... is it possible for the duck to escape from the wolf? If so, explain how the duck can do it. If not, explain why it is impossible.
The circumference of a circle is pi*d, where d is the diameter. Assuming the wolf has perfect knowledge of the duck's movements and doesn't do something like get confused or wander off, the duck is screwed. Assuming the duck travels all the way across the pond - the diameter, the wolf only has to be going pi/2 times the speed of the duck (he doesn't have to go all the way 'round, just halfway) to catch the duck on the other side. pi / 2 is about 1.57, which is far less than four, so the wolf has no problem catching the duck.
Let's assume that the duck starts in the center of the pond. This is as far as he can get away from the wolf, because if he moves anywhere away from the center the wolf will realign himself to be at the closest point to the duck. The wolf is now at some arbitrary point on the edge. The duck has to travel d/2 distance, so he starts hauling ass directly away from the wolf. The wolf still has to travel the same distance - halfway around the circle, only now he has half the time to do it. So he has to be going at least pi times as fast as the duck. Since 3.14 < 4, the duck is still screwed.
Now what if the wolf has to compute his trajectory on-line--that is, without perfect knowledge of the duck's path in advance? I think the duck might have a shot. Assume the duck starts from the center of the lake and starts moving in one direction. Obviously, the wolf starts running around the lake edge. But now the duck course-corrects so he's always heading in the direction most opposite where the wolf is at that moment. At this point I think you need calculus to figure out whether the duck is caught or not, but maybe I'm missing something.
Now what if the wolf has to compute his trajectory on-line--that is, without perfect knowledge of the duck's path in advance? I think the duck might have a shot. Assume the duck starts from the center of the lake and starts moving in one direction. Obviously, the wolf starts running around the lake edge. But now the duck course-corrects so he's always heading in the direction most opposite where the wolf is at that moment. At this point I think you need calculus to figure out whether the duck is caught or not, but maybe I'm missing something.
At some distance from the middle, the duck can out run the wolf in angular velocity, just by running in circles. The duck is 1/4th as quick, so his inner track needs to be at most 1/4th the r, or 0.25r. Therefore the duck can keep itself on the farside away from the wolf for any distance > 0.75r from the shore. That essentially gives the duck a quarter off the distance he needs to get away. The wolf still needs to do a distance of pi*r.
So which has the least distance to travel?
Assuming the duck travels in a straight line to the shore, and giving the wolf 1/4th the distance for the 4x speed advantage:
0.75*r ? pi*r/4
0.75 ? 3.14/4
0.75 < ~0.785
Therefore the duck beats the wolf. I'm not sure if the duck can beat the wolf any further using curves; but if so, then yeah, calculus would be required to calculate that advantage.
Now what if the wolf has to compute his trajectory on-line--that is, without perfect knowledge of the duck's path in advance? I think the duck might have a shot. Assume the duck starts from the center of the lake and starts moving in one direction. Obviously, the wolf starts running around the lake edge. But now the duck course-corrects so he's always heading in the direction most opposite where the wolf is at that moment. At this point I think you need calculus to figure out whether the duck is caught or not, but maybe I'm missing something.
At some distance from the middle, the duck can out run the wolf in angular velocity, just by running in circles. The duck is 1/4th as quick, so his inner track needs to be at most 1/4th the r, or 0.25r. Therefore the duck can keep itself on the farside away from the wolf for any distance > 0.75r from the shore. That essentially gives the duck a quarter off the distance he needs to get away. The wolf still needs to do a distance of pi*r.
So which has the least distance to travel?
Assuming the duck travels in a straight line to the shore, and giving the wolf 1/4th the distance for the 4x speed advantage:
0.75*r ? pi*r/4
0.75 ? 3.14/4
0.75 < ~0.785
Therefore the duck beats the wolf. I'm not sure if the duck can beat the wolf any further using curves; but if so, then yeah, calculus would be required to calculate that advantage.
Solution below:
Yeah, this is correct.
To those who want a further explanation: If the duck is at the center, and he tries to book it exactly in the opposite direction of the wolf, he clearly cannot make it. He has to swim a distance of r, where the wolf has to run a distance of pi*r. Yet, the wolf runs at 4 times the speed, and 4 > pi. So the wolf will beat the duck to that location.
Suppose the duck forms a very small circle in the middle of the pond and starts swimming in it (imagine the radius of the pond is 1 unit, and the duck swims in a mini-circle with radius, say, 0.05). Clearly, the duck will be able to swim one lap of his mini-circle faster than the wolf can run around the outside of the pond. However, if you consider the circle to be the size of the pond itself, clearly the duck cannot complete a lap faster than the wolf. This suggests, by intermediate value theorem, that there must be a circle with some radius where the duck can complete one lap of the mini-circle at exactly the same speed as the wolf can run around the entire pond. It is not hard to convince yourself that this distance is 0.25r away from the center of the circle (or, you can just reason your way there as falsedef has shown).
Therefore, the duck should follow this plan. Swim in a circle that has radius 0.25r - e, where e (epsilon) is some very small positive number. This gives the duck a swimming edge, as he can now complete a lap very slightly faster than the wolf can keep up around the outside of the pond. The duck continues to swim in this circle until the wolf has lost the maximum amount of ground, and is exactly halfway around the circle from where the duck is (more mathematically, drawing a line from the wolf to the duck will pass through the center of the circle). The duck now books it for the shore. He only has 0.75r + e (basically 0.75r) to travel, instead of r, but the wolf still has to run the full pi*r as before. Since pi/0.75 > 4, the duck will beat the wolf to the shore. If you're worried about that extra e, just choose e small enough so that pi/(0.75+e) > 4.
It's an interesting problem, and one that I've seen asked on programming tests before. It's a bit more math-based, so I decided to share it as per the request of one of the posts.
XenoScholar on
Check out my demonstration of the Street Fighter 4 hard trial combos, showing hands on the joystick, on my Youtube channel!
Current characters done: Ryu, Dan, C. Viper
Xbox Live: Infilament
Double posting because it doesn't really apply to my last post.
Here's a really great question which is fairly math-based.
Suppose you have a circular pond with radius r. There is a duck swimming around in the pond, and he can swim with a certain speed (call it s). However, a wolf comes up to the side of the pond and wants to get at the duck. The wolf cannot swim, but he can run at a speed of 4s (that is, 4 times the duck's swimming speed). The duck cannot take flight from the water, but he wants to escape the pond. He has to swim to shore to take flight, but obviously the wolf will be running around the outside of the pond, trying to meet the duck at the shore.
The question is... is it possible for the duck to escape from the wolf? If so, explain how the duck can do it. If not, explain why it is impossible.
My response to the duck in the pond question:
Yes. If the duck is on the edge of the left side of the pond when the wolf approaches from the right, he can very easily make it out. You'll need to ask the question some other way to force someone to do math.
Your name looked really familiar, so I thought I just remembered you from PA forums, but then I remembered the name from the IGDA forums.
Do you have a web portfolio I can check it out?
Yeah. I posted on IGDA defending Full Sail and the education I received there. I only posted twice, so I must have made an impression :-) I don't have a portfolio, but if you want to talk, we can bring it to PM.
Posts
Write a C++ class for a sphere object in a 3D world. Now, using that class, implement the function bool checkCollision(sphere sphereA, sphere sphereB), where it returns "true" if they are colliding and "false" if they are not.
Imagine a staircase with N stairs. When going up the stairs, you can take either one step at a time or two steps at a time. Find the number of different ways you can get to the top.
For example, if there's three stairs, you can:
1. Take one step at a time for all three steps.
2. Take two stairs, then one stair to the top.
3. Take one stair, then two stairs.
So the answer would be three.
Write a C++ function that calculates this.
If you have any mod experience in any sense, that is extremely helpful.
PSN: TheScrublet
If you are having trouble with the first one, work it out in 2D first, with a "circle" class.
That's the idea, yeah.
Ahh recursion... I remember the days... Is it bad that I got sad looking at this because I don't have to use any recursion in my current job?
Not 100% sure, but it seems right, and it works on the simple test cases I was comfortable doing in my head.
Oh well I've had some varied experiences.
Volition had a wicked entry test that made me feel retarded. Lots of high level math to start. Then onto creating code examples. That was part one of their interview.
Can't remember which company, but it was a GBA coding job. All they wanted was for you to create a game demo for them. Like create a platformer. The character must accelerate while running when starting from rest and then speed would plateau. Also the character must collide with solid objects and not pass through them. Then create some platforms where the character could jump through the bottom of a solid object, but when land on top have the platform solid.
I'd say the most important thing I saw was having a portfolio of demo games to display. Show them you can grasp and code core concepts like collision detection, physics, some AI would be good too. 2D and 3D visuals.
It may be early, but it would help to have a focus like I want to be an audio engineer, or level design, AI programmer and cater your skills to the specific job. I found that computer science degree gave me a broad spectrum of skills, but during job searching really made me realize where my talents lie. I have no artistic skill which meant a good chunk of gaming work was already eliminated from my search. Could I make games? Yes, but they were ugly with bad audio choices. That meant I had to focus on showing I could do the background coding like engine work, physics, in house tools, AI.
Hopefully that gives you a good sense on how to start. Ask some friends to try out one of your games. And then get their opinion on the games and force them to be brutally honest about it. Do you think my artwork sucks, audio sucks, physics/gameplay didn't feel right? If yes then explain why.
Steam
XBOX
That's O(n^2). Can you think of a way to calculate it faster?
Damn you... I want to use recursion
eh... looking at it now it's just Fibonacci numbers so I'm sure there's a faster way. Probably just with a loop instead of bothering with the recursion...
something like:
One thing to note is that they will test you for small optimizations amongst other things here as well.. For example, instead of having to square root the whole thing (sqrt is TRADITIONALLY slow.. they're not now depending on how they're done though), so you can just return true if the distance formula without the sqrt is <= the sum of the radii squared, i.e if( (sq(A.x-B.x) + sq(A.y-B.y) + sq(A.z-B.z)) < sq(A.r+B.r) ) . . .
they will also test to see if you're protecting your code properly and things like that. They will check for const correctness and other stuff which is important. If you don't know it then you should google that before the interview.
Something like that would be good if you can do that
Re: number of steps
Most computer programming interview questions I've had/heard of will ask you to design a class or come up with an algorithm for doing something. Consider things like input sizes to your algorithms as well as other things like "how easy is it to take this class/these ideas and apply them to more general situations?" In other words, is the code you're writing just ad-hoc, or can it be easily re-used for other, similar things?
Yep, I've also had them ask me to design a parking lot in code, where there is an algorithm used to make sure that there are spaces for cars. Then they asked me to modify it so that I could fit busses, where there needed to be two end-to-end spaces to fit them. Then motorcycles, where you can fit two to a space.
As for some of the responses: one sphere being inside the other is most definitely collision. Curby, you're also dead on. I think you go too far on the const correctness (no reason for the pointer you take in to be const), but you make good sense.
I'm a programmer at Volition :-) One thing I should note about Volition is that we're a very tech-oriented company and, to put it plainly, you have to be a pretty good coder to get through the interview.
Here was how it worked for me:
1. Apply
2. Get a timed coding test. The questions get progressively harder, but you should be able to get 50% reasonably easy. 75%+ is a good score.
3. Phone interview
4. In-person interview - zomg. This was *very* scary. The questions were a total mix across the spectrum from compression to rendering to collision to basic logic. There were some questions that I got right away, there were some I needed some help with, and there was one that I didn't get at all.
Overall, expect to be stumped on some questions, and be able to write/talk about your reasoning. Marty: it may be the way you say at typical programming places, but not at game companies. For a question on a test/interview, they want your reasoning/answer. The code should work, be safe, and be relatively neat, but I've never seen anyone care about it being reusable. They might ask you to modify it on the fly, but typically, they're not looking to make sure your implementation is extensible.
Now, onto some questions that could/would be asked on a test/interview:
Write a function to randomize an array of integers.
Write a function to determine if a matrix (array of arrays) of integers is a magic square.
Write a linked list class.
What is the difference between an array and a linked list? A queue and a stack?
As far as what they'll look for in a demo/code sample... something non-trivial and either something not typical, or a spin on the typical (for example - if you want to do a particle system, make sure there's something unique about it, like that it can be controlled from a scripting language). My code samples were a small application to convert an R8G8B8 bitmap to a B5G6R5 array of color entries for use on the GBA and a neat lighting system I came up with for a project. Along with that, I had done mod work on an HL2 mod (SourceForts), and I had done the networking for an online FPS for a school project. I was applying as a network programmer, so obviously, having done networking for a game already was a huge plus. So, have one or two cool demos that can be explained relatively quickly and get some experience. Mods are the way to go.
Sorry to nitpick, but one sphere inside of another is not collision. You're thinking of balls, not spheres. See the mathematical definition in http://en.wikipedia.org/wiki/Sphere. I doubt your interviewer would dock you for solving the problem for balls instead of spheres, but I wanted to clear this up.
Spherical collision detection means solid, despite whatever the mathematical terms are. I can't think of an instance in game programming where it'd be defined as a shell, which wouldn't be completely ridiculous.
I doubt your interviewer would dock you for solving the problem for shells instead of solids, but I wanted to clear this up.
addendum:
Your name looked really familiar, so I thought I just remembered you from PA forums, but then I remembered the name from the IGDA forums.
Do you have a web portfolio I can check it out?
And is mod experience better then coding your own small programs, or it's best to have both?
Thanks for the tips so far.
Oh it's a bloody search problem.
Fuck, it looks so simple now.
I feel like an idiot
The best way to think about these problems is:
Also, a TON of different problems can follow this reasoning and be solvable with dynamic programming in O(n). If you're ever asked to count the number of ways something can happen, immediately try to apply this line of reasoning. Another example has already been said; parking spaces. Suppose there are n parking spaces, and buses take up two, cars take up one, and 2 motorcycles can fit in one space. You can calculate the total number of ways a specified group of vehicles can fit in n spaces using exactly this approach.
For the record, I'm not a games programmer... though I have developed a game. I'm doing my Masters in computer science in graphics, though.
Current characters done: Ryu, Dan, C. Viper
Xbox Live: Infilament
Here's a really great question which is fairly math-based.
Suppose you have a circular pond with radius r. There is a duck swimming around in the pond, and he can swim with a certain speed (call it s). However, a wolf comes up to the side of the pond and wants to get at the duck. The wolf cannot swim, but he can run at a speed of 4s (that is, 4 times the duck's swimming speed). The duck cannot take flight from the water, but he wants to escape the pond. He has to swim to shore to take flight, but obviously the wolf will be running around the outside of the pond, trying to meet the duck at the shore.
The question is... is it possible for the duck to escape from the wolf? If so, explain how the duck can do it. If not, explain why it is impossible.
Current characters done: Ryu, Dan, C. Viper
Xbox Live: Infilament
The circumference of a circle is pi*d, where d is the diameter. Assuming the wolf has perfect knowledge of the duck's movements and doesn't do something like get confused or wander off, the duck is screwed. Assuming the duck travels all the way across the pond - the diameter, the wolf only has to be going pi/2 times the speed of the duck (he doesn't have to go all the way 'round, just halfway) to catch the duck on the other side. pi / 2 is about 1.57, which is far less than four, so the wolf has no problem catching the duck.
Let's assume that the duck starts in the center of the pond. This is as far as he can get away from the wolf, because if he moves anywhere away from the center the wolf will realign himself to be at the closest point to the duck. The wolf is now at some arbitrary point on the edge. The duck has to travel d/2 distance, so he starts hauling ass directly away from the wolf. The wolf still has to travel the same distance - halfway around the circle, only now he has half the time to do it. So he has to be going at least pi times as fast as the duck. Since 3.14 < 4, the duck is still screwed.
Now what if the wolf has to compute his trajectory on-line--that is, without perfect knowledge of the duck's path in advance? I think the duck might have a shot. Assume the duck starts from the center of the lake and starts moving in one direction. Obviously, the wolf starts running around the lake edge. But now the duck course-corrects so he's always heading in the direction most opposite where the wolf is at that moment. At this point I think you need calculus to figure out whether the duck is caught or not, but maybe I'm missing something.
At some distance from the middle, the duck can out run the wolf in angular velocity, just by running in circles. The duck is 1/4th as quick, so his inner track needs to be at most 1/4th the r, or 0.25r. Therefore the duck can keep itself on the farside away from the wolf for any distance > 0.75r from the shore. That essentially gives the duck a quarter off the distance he needs to get away. The wolf still needs to do a distance of pi*r.
Assuming the duck travels in a straight line to the shore, and giving the wolf 1/4th the distance for the 4x speed advantage:
0.75*r ? pi*r/4
0.75 ? 3.14/4
0.75 < ~0.785
Therefore the duck beats the wolf. I'm not sure if the duck can beat the wolf any further using curves; but if so, then yeah, calculus would be required to calculate that advantage.
Solution below:
To those who want a further explanation: If the duck is at the center, and he tries to book it exactly in the opposite direction of the wolf, he clearly cannot make it. He has to swim a distance of r, where the wolf has to run a distance of pi*r. Yet, the wolf runs at 4 times the speed, and 4 > pi. So the wolf will beat the duck to that location.
Suppose the duck forms a very small circle in the middle of the pond and starts swimming in it (imagine the radius of the pond is 1 unit, and the duck swims in a mini-circle with radius, say, 0.05). Clearly, the duck will be able to swim one lap of his mini-circle faster than the wolf can run around the outside of the pond. However, if you consider the circle to be the size of the pond itself, clearly the duck cannot complete a lap faster than the wolf. This suggests, by intermediate value theorem, that there must be a circle with some radius where the duck can complete one lap of the mini-circle at exactly the same speed as the wolf can run around the entire pond. It is not hard to convince yourself that this distance is 0.25r away from the center of the circle (or, you can just reason your way there as falsedef has shown).
Therefore, the duck should follow this plan. Swim in a circle that has radius 0.25r - e, where e (epsilon) is some very small positive number. This gives the duck a swimming edge, as he can now complete a lap very slightly faster than the wolf can keep up around the outside of the pond. The duck continues to swim in this circle until the wolf has lost the maximum amount of ground, and is exactly halfway around the circle from where the duck is (more mathematically, drawing a line from the wolf to the duck will pass through the center of the circle). The duck now books it for the shore. He only has 0.75r + e (basically 0.75r) to travel, instead of r, but the wolf still has to run the full pi*r as before. Since pi/0.75 > 4, the duck will beat the wolf to the shore. If you're worried about that extra e, just choose e small enough so that pi/(0.75+e) > 4.
It's an interesting problem, and one that I've seen asked on programming tests before. It's a bit more math-based, so I decided to share it as per the request of one of the posts.
Current characters done: Ryu, Dan, C. Viper
Xbox Live: Infilament
My response to the duck in the pond question:
Yeah. I posted on IGDA defending Full Sail and the education I received there. I only posted twice, so I must have made an impression :-) I don't have a portfolio, but if you want to talk, we can bring it to PM.