Game Company | Online Assessment | Questions
Anonymous User
330
  1. What are smart pointers? What do they solve and what problems do they introduce?

  2. Write C++ code that allocates memory on the stack to a specified alignment.

  3. FooStringAllocator is a multi-threaded string allocator that can be called concurrently. Fix any threading problems with FooStringAllocator with as minimal overhead as possible.

// A thread locking mechanism much like a critical section
struct FooThreadLock
{
   	// Lock will block until any other
   	// thread that has called lock calls
   	// Unlock
   	void Lock();
   	void Unlock();
};
 
struct FooString
{
   	FooString()
          	: pString( nullptr )
   	{}
 
   	char* pString;
   	FooThreadLock lock;
};
 
void FooStringAllocator( FooString* fooString, size_t strLength )
{
   	if( !fooString->pString )
   	{
          	fooString->lock.Lock();
          	fooString->pString = new char[strLength];
          	fooString->lock.Unlock();
   	}
}
  1. FooBar is of type float and contains a positive value. What will FooBar contain after this code executes?
++*(unsigned int*)&FooBar;
  1. FooBar is a struct with a default constructor and a size of 32 bytes. What is wrong with the following code?
int blobArray[32];
FooBar* pFooBar = new(blobArray + 16) FooBar();
delete pFooBar;
  1. Given the following two struct definitions which one is preferable and why?
struct foo
{
	short a;
	int b;
	int c;
	short d;
};

struct bar
{
	int a;
	int b;
	short c;
	short d;
};
  1. A bullet is shot at the head of a zombie. Assuming constant velocity of the bullet and a stationary target, write a function to determine if the zombie’s head, represented by a sphere, will be hit.

  2. You have been tasked with determining the resilience of a fridge. You are given 2 refrigerators and a 36 story building to test from. We want to know at what floor the refrigerator can be thrown from without breaking. Assuming the refrigerator either shatters or survives with no damage when thrown from a window what is the maximum number of floors you must test?

  3. Propose, in a few sentences, a tool for automatically generating “cover node” data for a level. The cover node specifies a spot where AI can take cover from incoming fire, while being able to fire back. A level should contain numerous cover nodes in advantageous positions. The cover node definition consists of:

Struct CoverNode
{
                Struct AngleRange
{
                Float minHeading;
                Float maxHeading;
};

AngleRange coveredAngles;
AngleRange returnFireAngles;
Bool crouchingCoverOnly;
Bool canFireOverhead;
};

The input to this automated tool is two triangle-soup style meshes. One represents the solid level geometry, or collision that stops bullets. The other is the “navmesh,” a 2D representation of the navigable area of the level. AI can stand anywhere within any of the navmesh triangles, and can’t reach any area not covered by navmesh.

Comments (1)