• Advertisement
Sign in to follow this  

Unity Need cram help for job application testing please !!!!

This topic is 4586 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello I am so excited, i just got short listed for a job interview so they must have liked at least something about my game demo that the GameDev.net community helped me so much with. ;p The position is for a Junior Programmer and I have to do a '3 hour software test' as part of the next stage. They gave me no clue other that that.... So I have about 40hrs - 2 sleeps to prepare and I am not sure how I should spend my time. I'm thinking I will be digging out my c++ books and just brushing up on that. Possibly also looking a little at the DirectX API which I am kind of familiar with. Is anyone here in a position to be able to offer me some advice on this??

Share this post


Link to post
Share on other sites
Advertisement
Hey,

Nothing that is obvious aside from:

Get enough sleep.

[and other general study stuff] - Also depending on how competent they are, you should possibly be prepared for silly questions about doing multiplication using only shifting and addition and that sort of stuff.

Hope it helps.

CJM

Share this post


Link to post
Share on other sites
Hey thanks a lot guys !

Those tests look like just the sort of thing i need to look into ;p

"multiplication using only shifting and addition"......can anyone explain how to do this ?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by bobbinus
Hey thanks a lot guys !

Those tests look like just the sort of thing i need to look into ;p

"multiplication using only shifting and addition"......can anyone explain how to do this ?


If you know long multiplication (which I would assume you do) then "multiplication using only shifting and addition" is basically just that in binary.

We all know that multiplying by 10 in decimal just involves shifting all the figures to the left then putting a zero at the end. It's similar in binary when multiplying by %10 (2 in decimal), i.e. shift left then put a zero at the end.

e.g.

%1101 * %0110=

(%00001101 * %0[bit 0])+
(%00011010 * %1[bit 1])+
(%00110100 * %1[bit 2])+
(%01101000 * %0[bit 3]) =

(%00011010 * %1)+
(%00110100 * %1) =
%1001110



In code, you would shift the multiplier to the right each time and if a 1 came out add the multiplicand to the result. Then shift the multiplicand left. Do this in a loop for all bits in the multiplier.

As to your original question, there's many different formats your test could take, from writing a function to do a particular job to a few smaller tests such as IQ tests, questions on c++, debug a small function etc. I don't think there's anything you can really prepare for.

In fact, they probably don't want you to prepare which is why they won't tell you what form the test will be. They will probably want to see how youthink about problems and how you go about solving them.


Good luck anyway.

Share this post


Link to post
Share on other sites
Quote:
Original post by bobbinus
Hey thanks a lot guys !

Those tests look like just the sort of thing i need to look into ;p

"multiplication using only shifting and addition"......can anyone explain how to do this ?



Left-Shifting doubles the value of a number, so multiplication by a power of 2 can be easily achieved.

Multiplying by a number close to a power of 2 can be achieved by combining left-shifting with addition/subtraction:

a = (a << 3)-a;//multiply a by 8 then subtract a, giving a final value of a*7.


I've also been asked how to count the number of set-bits in an integer in O(n) where n is the number of set bits (Rare asked me this)

That can be done like this:

unsigned int bitCount(unsigned int data)
{
unsigned int count=0;
while(data)
{
data &= data-1;
++count;
}
return count;
}



They key to understanding this is that subtracting 1 from a number unsets the least significant set bit and sets all less significant bits:

e.g. 10001000 - 1 == 10000111;

so x &= x-1; simply unsets the least significant set bit.










Share this post


Link to post
Share on other sites
Quote:
Original post by bobbinus
"multiplication using only shifting and addition"......can anyone explain how to do this ?


Like so:

result = 640 * y //starting example equasion which we wish to evaluate using only addition & shifting
result = (512 + 128) * y //step 1: distribute the constant into a sum of powers of two.
result = (512 * y) + (128 * y) //step 2: distribute the other operand
result = (2^9 * y) + (2^7 * y) //step 3: convert into power-of-two representation (equasion uses ^ as in power (e.g. BASIC ^) not binary xor (e.g. C++ ^))
result = (y << 9) + (y << 7); //step 4: convert each power-of-two representation into shifts, ala this equivilancy: (2^n * y) == (y << n)

This is an ancient "optimization" back from the days of C compilers without optimizers. Any recent compiler should in fact automatically do this conversion for you as needed, meaning the difference is only cosmetic.

Share this post


Link to post
Share on other sites
Hehe. I like this question (from the Codemasters test, linked above):
Quote:
What does mysteryFunction3D() compute?
struct vector_3d_typ {
// a 3-D vector along with normalization factor
float x,y,z,w;
} vector_3d,*vector_3d_ptr;


float mysteryFunction3D_1(vector_3d_ptr u,vector_3d_ptr v)
{
return( (u->x * v->x) + (u->y * v->y) + (u->z * v->z));
}

Since it's under the "3D" section of the test I assume they're looking for an answer of "the (unnormalized) dot product", but in actual fact the answer is "nothing"!. They forgot to typedef their struct, so vector_3d_ptr is a global variable of type vector_3d_typ *, not a type and subsequently mysteryFunction3D_1 fails to compile. [lol]

Enigma

Share this post


Link to post
Share on other sites
Go learn the format of the floating point- how many bits are used for the mantissa and the exponent. People love asking about that.

Actually, make sure you know the typical sizes of all the data types.

The floodfill algorithm is popular, I've had to write that one like 3 times. Hint: Don't use recursion. Depending on how big the area is to be floodfilled, either keep a big queue for "next cells to look at", or have a flag for every pixel/cell that means "checked".

In fact, I remember one question that just asked "what is a better way to solve this problem, iteration or recursion?" The answer is almost always iteration.

Also, the quicksort algorithm seems to show up a lot. Luckily I don't think anyone has asked me to write quicksort from memory, which is good because it's a damn confusing algorithm. More likely, they'll show you a broken version of quicksort and ask you to fix it.

And these days, everybody seems to throw in a question about 3d math. Here's an example of one that I got: "Given a triangle defined by points A,B,C (<Ax,Ay,Az>, <Bx,By,Bz>,<Cx,Cy,Cz>) using clockwise winding, determine whether point P (<Px,Py,Pz>) is in front of the triangle, behind it, or coplanar."

Share this post


Link to post
Share on other sites
A test I was asked to complete had these sort of questions:

1. Some round about word problem that required binary partitioning. [a range of numbers, and you could tell if the answer was 'above' or 'below' a given guess, so you divide the range in two, successively until you find the solution]

2. Write a pathfinding function for a basic map type.

3. Add two abritrarily long strings, and return the result as a string.

4. Define an object class which has to do such-and-such things. [how to design for collision detection elegantly]

and one other I don't remember.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster

If you know long multiplication (which I would assume you do) then "multiplication using only shifting and addition" is basically just that in binary.

We all know that multiplying by 10 in decimal just involves shifting all the figures to the left then putting a zero at the end. It's similar in binary when multiplying by %10 (2 in decimal), i.e. shift left then put a zero at the end.

e.g.
%1101 * %0110=

(%00001101 * %0[bit 0])+
(%00011010 * %1[bit 1])+
(%00110100 * %1[bit 2])+
(%01101000 * %0[bit 3]) =

(%00011010 * %1)+
(%00110100 * %1) =
%1001110


In code, you would shift the multiplier to the right each time and if a 1 came out add the multiplicand to the result. Then shift the multiplicand left. Do this in a loop for all bits in the multiplier.



I have a vague idea of what you are doing but I cant get this into code...Is that actual legal syntax what you are using ??

Share this post


Link to post
Share on other sites
Hi bobbinus,

One word of advice. Don't let yourself get too put off if you find the test difficult, or can't answer all the questions. Most good software companies will use it just as a guide, and won't expect everyone to get everything right.

Just do your best, and if you find you can't answer the questions as well as you hoped, don't give up; make up for it by showing your enthusiasm and willingness to learn, during the rest of the interview.

Good luck.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
  • Advertisement
  • Popular Tags

  • Advertisement
  • Popular Now

  • Similar Content

    • By khawk
      Watch the latest from Unity.
       
    • By GytisDev
      Hello,
      without going into any details I am looking for any articles or blogs or advice about city building and RTS games in general. I tried to search for these on my own, but would like to see your input also. I want to make a very simple version of a game like Banished or Kingdoms and Castles,  where I would be able to place like two types of buildings, make farms and cut trees for resources while controlling a single worker. I have some problem understanding how these games works in the back-end: how various data can be stored about the map and objects, how grids works, implementing work system (like a little cube (human) walks to a tree and cuts it) and so on. I am also pretty confident in my programming capabilities for such a game. Sorry if I make any mistakes, English is not my native language.
      Thank you in advance.
    • By Ovicior
      Hey,
      So I'm currently working on a rogue-like top-down game that features melee combat. Getting basic weapon stats like power, weight, and range is not a problem. I am, however, having a problem with coming up with a flexible and dynamic system to allow me to quickly create unique effects for the weapons. I want to essentially create a sort of API that is called when appropriate and gives whatever information is necessary (For example, I could opt to use methods called OnPlayerHit() or IfPlayerBleeding() to implement behavior for each weapon). The issue is, I've never actually made a system as flexible as this.
      My current idea is to make a base abstract weapon class, and then have calls to all the methods when appropriate in there (OnPlayerHit() would be called whenever the player's health is subtracted from, for example). This would involve creating a sub-class for every weapon type and overriding each method to make sure the behavior works appropriately. This does not feel very efficient or clean at all. I was thinking of using interfaces to allow for the implementation of whatever "event" is needed (such as having an interface for OnPlayerAttack(), which would force the creation of a method that is called whenever the player attacks something).
       
      Here's a couple unique weapon ideas I have:
      Explosion sword: Create explosion in attack direction.
      Cold sword: Chance to freeze enemies when they are hit.
      Electric sword: On attack, electricity chains damage to nearby enemies.
       
      I'm basically trying to create a sort of API that'll allow me to easily inherit from a base weapon class and add additional behaviors somehow. One thing to know is that I'm on Unity, and swapping the weapon object's weapon component whenever the weapon changes is not at all a good idea. I need some way to contain all this varying data in one Unity component that can contain a Weapon field to hold all this data. Any ideas?
       
      I'm currently considering having a WeaponController class that can contain a Weapon class, which calls all the methods I use to create unique effects in the weapon (Such as OnPlayerAttack()) when appropriate.
    • By Vu Chi Thien
      Hi fellow game devs,
      First, I would like to apologize for the wall of text.
      As you may notice I have been digging in vehicle simulation for some times now through my clutch question posts. And thanks to the generous help of you guys, especially @CombatWombat I have finished my clutch model (Really CombatWombat you deserve much more than a post upvote, I would buy you a drink if I could ha ha). 
      Now the final piece in my vehicle physic model is the differential. For now I have an open-differential model working quite well by just outputting torque 50-50 to left and right wheel. Now I would like to implement a Limited Slip Differential. I have very limited knowledge about LSD, and what I know about LSD is through readings on racer.nl documentation, watching Youtube videos, and playing around with games like Assetto Corsa and Project Cars. So this is what I understand so far:
      - The LSD acts like an open-diff when there is no torque from engine applied to the input shaft of the diff. However, in clutch-type LSD there is still an amount of binding between the left and right wheel due to preload spring.
      - When there is torque to the input shaft (on power and off power in 2 ways LSD), in ramp LSD, the ramp will push the clutch patch together, creating binding force. The amount of binding force depends on the amount of clutch patch and ramp angle, so the diff will not completely locked up and there is still difference in wheel speed between left and right wheel, but when the locking force is enough the diff will lock.
      - There also something I'm not sure is the amount of torque ratio based on road resistance torque (rolling resistance I guess)., but since I cannot extract rolling resistance from the tire model I'm using (Unity wheelCollider), I think I would not use this approach. Instead I'm going to use the speed difference in left and right wheel, similar to torsen diff. Below is my rough model with the clutch type LSD:
      speedDiff = leftWheelSpeed - rightWheelSpeed; //torque to differential input shaft. //first treat the diff as an open diff with equal torque to both wheels inputTorque = gearBoxTorque * 0.5f; //then modify torque to each wheel based on wheel speed difference //the difference in torque depends on speed difference, throttleInput (on/off power) //amount of locking force wanted at different amount of speed difference, //and preload force //torque to left wheel leftWheelTorque = inputTorque - (speedDiff * preLoadForce + lockingForce * throttleInput); //torque to right wheel rightWheelTorque = inputTorque + (speedDiff * preLoadForce + lockingForce * throttleInput); I'm putting throttle input in because from what I've read the amount of locking also depends on the amount of throttle input (harder throttle -> higher  torque input -> stronger locking). The model is nowhere near good, so please jump in and correct me.
      Also I have a few questions:
      - In torsen/geared LSD, is it correct that the diff actually never lock but only split torque based on bias ratio, which also based on speed difference between wheels? And does the bias only happen when the speed difference reaches the ratio (say 2:1 or 3:1) and below that it will act like an open diff, which basically like an open diff with an if statement to switch state?
      - Is it correct that the amount of locking force in clutch LSD depends on amount of input torque? If so, what is the threshold of the input torque to "activate" the diff (start splitting torque)? How can I get the amount of torque bias ratio (in wheelTorque = inputTorque * biasRatio) based on the speed difference or rolling resistance at wheel?
      - Is the speed at the input shaft of the diff always equals to the average speed of 2 wheels ie (left + right) / 2?
      Please help me out with this. I haven't found any topic about this yet on gamedev, and this is my final piece of the puzzle. Thank you guys very very much.
  • Advertisement