Things You Need to Know before Interviewing for a Game Programming Position
Matt posted in Getting into Games on August 11th, 2006
For quite some time, the game industry was an exclusive club that didn’t allow any new blood because every opening required applicants to have 2+ years of experience and 1 shipped title. I don’t think there has ever been a better time to get into the games industry right out of college than now. Because next gen team sizes are increasing drastically, people with experience are harder to find, so more and more companies are recruiting right from colleges. Regardless, of what college you go to, you can still get a job in the games industry provided you have a certain proficiency in the following areas.
Math – This is an important area to video game development. No, you don’t need to remember how to compute the surface area of a curve when rotated about the x axis. You do need to have very good linear algebra skills. If you don’t know what the formula for a dot product is (a dot b = a.x * b.x + a.y * b.y + a.z * b.z ) and what it means geometrically (|a| * |b| * cosine of the angle between a and b), then there’s no chance you can get a job. You need to know how to project a vector onto another vector (a projected onto b = ( a dot b ) / |b|^2 * b) and onto a plane. You need to know what the cross product is (a x b = [a.y * b.z – a.z * b.y, a.z * b.x – a.x * b.z, a.x * b.y – a.y * b.x]) and what it means geometrically (a vector perpendicular to the vectors with a length equal to the sine of the angle between them). The way I remember how to compute a cross product, is to put i, j, k in the first row of a matrix, then the first vector and finally the second, and then compute the determinant. If you don’t know how to compute a determinant or what that is, that’s a bad sign! You should know what the inverse of a matrix is and how to compute it for any matrix. You should know how to transpose a matrix. You should know what an orthonormal matrix is and a shortcut to compute its inverse (just transpose the matrix). Familiarity with conversions between different coordinate spaces is essential. The math behind collision routines is very important to learn also. How do you find the collision point between a parametric ray and another ray? a plane? a sphere? What are quaternions? How do you do common operations with them? If you are very rusty on your math or don’t know where to start, I’d recommend 3D Math Primer for Graphics and Game Development. I read it and found that it covers all the basics pretty well. I haven’t read all that many other books for comparison, but it’ll definitely will give you a good foundation to build on as well as reference for many common math operations for game development.
Physics – You should be very familiar with all the projectile equations. If you can’t either derive or remember d = v0 * t + 0.5 * a * t^2, you’ll be in trouble when you interview or take a programming test. Any problem that involves a projectile with gravity should be easy for you to solve. Whether the unknown is gravity, launch angle, y velocity, xz velocity, time, distance or any combinations that are solvable, you should have no problems determining the solution. You should also be familiar with momentum and kinetic energy for elastic and inelastic collisions. Drag and friction should be concepts you understand also.
C++ - Although some places still use C over C++, C++ is pretty much commonly accepted as the standard for game programming. Knowledge of C++ is very important because if used poorly, you can write very suboptimal code. Firstly, you should know what a virtual function is, and how to use it. It’s also important that you understand how the virtual function table works, so you understand the extra steps that can decrease performance that take place when you call a virtual function (each object has a virtual function table pointer hidden from you in its structure data [where it is located depends on the compiler and this has important ramifications when pointer casting], and to call a virtual function, you need to follow that pointer to the table, and then jump to the function pointer contained within, which can hurt caching). Knowing how to use templates and operator overloading efficiently is important too. Good object oriented design is the most important thing you should know about C++. All too often class hierarchies are deep and convoluted, so you end up having to do horrible things like virtual inheritance, or all your classes have a lot of wasted memory for variables they didn’t need.
AI – I took the standard AI class that University of Michigan offered, and absolutely none of it was applicable to game AI. A lot of the algorithms taught are intractable, or just impractical for games. As long as you know what a finite state machine is, you should be fine. Most games use finite state machines, and the ones that don’t, use simple rule based systems. “Black and White” (and its sequel) is the only exception I can think of that used something different (neural networks), but many gamers weren’t satisfied with the results. If you are looking for books, I’d recommend AI Game Programming Wisdom 3. It has two particularly outstanding articles in it, one about fun game AI design and another about behavior compositing. Seriously, although books may be helpful, the best way to learn about game AI is by doing it.
Graphics – This is an important area. If graphics is your main area of interest, then you should know a lot more that what is covered here, but whatever your desired position in the industry is, you should know these basics. You need to know what a render state is and what the common ones (cull, z write, z test, etc) are. What is the standard lighting equation? (It’s I = ka*Ia + Ii*(kd*(L dot N) + ks*(R dot V)^n) in case you were wondering) How does texture mapping work? What’s the difference between texture wrapping and clamping? How do you efficiently render a bunch of procedural geometry? (Organize your geometry by render states, batch it up in the fastest primitives for your hardware and send it off to the graphics card) You need to know how skinning works. If you’re interested in a book, I read 3D Computer Graphics by Watt. It’s not game specific, so it covers a lot of techniques that are impractical for games. But, I think the general overview is helpful, and as game hardware gets more advanced, the techniques presented that seem impractical now, might become the norm.
Tools Development – C# seems to be gaining a lot of momentum in the games industry, so it would be good to familiarize yourself with it. C# presents many advantages to speed up tools development. Many people have said tools can make or break next gen games. I agree with this. The more tools you have, the less time the team spends wasting time doing easily automated tasks. Maybe when you have a team of 10 artists, spending a man year of programmer work to create a tool that saves artists 15 minutes a day won’t pay off, but if you have 50 artists, then it is definitely worth your while. C# allows rapid creation of GUIs, and unlike some other ways to simplify creating GUIs, the GUIs are easy to understand and use since they are the standard Windows components and allow you to easily set up all the keyboard shortcuts like standard Windows applications. The Form Designer works really well in Visual Studio, and C#’s metadata and event driven design makes development a breeze for tools. It’s also nice to have at least some understanding of MFC also in case the developers you interview with are behind the times.
If you are interested in learning a lot about how the technology works (which will in turn allow you to write better C# code), I’d highly recommend Applied Microsoft .NET Framework Programming. I read it while on vacation, and I just couldn’t put it down. It seriously was a page turner. I read it cover to cover over the course of a few days because I was so excited to learn the topic of the next chapter. Keep in mind though, this book doesn’t teach you about the various Framework classes, and what they do. It instead covers the core mechanics of the language and how it works. It isn’t specific to C# either. It tells you what you can do in VB.NET that you can’t in C# as well as provides examples in MSIL (Microsoft Intermediate Language – the byte code that all .NET languages compile into) for things that may not be supported by any .NET languages yet.)
Operating Systems – Although this seems relatively unrelated to game development, I’m really glad I took Operating Systems in college because I frequently use knowledge that I learned in this class. knowledge about operating systems is very important since it handles a lot of important behind the scenes work for the programs. Especially with the multicore next gen consoles and dual core PCs, multithreading knowledge is essential. Virtual memory is definitely a useful thing to know. Knowledge about file systems, kernel to user transitions and paging is more useful for PC game development, but consoles are rapidly becoming more like PCs with every subsequent generation, so it’ll never hurt to know these things.
Compilers – Although it may not be important to know how to write a parser, it’s important to know how your code is converted into assembly, so you can understand how to write more optimal code. You definitely should be familiar with the four stages that take place to convert your program to an executable: preprocess, compile, assemble and link. How are constants treated by the compiler? A good understanding of macros and how to simplify common operations with them is important. Knowledge of calling conventions for the compiler you are using because passing over a certain amount of function parameters may cause them to be pushed on the stack instead of reserved registers. Calling convention is also useful for when you are writing a function in assembly.
So, this is just a starting point for the diverse array of knowledge you should have as a game programmer. There’s always more you should learn and the level that you should be familiar with each area depends on the type of task you are doing. It can never hurt to know more than you’ll actually use. If you have any questions about what you should learn, or getting into the industry, feel free to post, and I’ll get back to you.
很长时间以来,游戏产业不允许新的血液加入,因为每个职位都要求申请人有2年以上的经验. 但是现在是加入游戏产业的最好的时机. 因为研发队伍的急剧增长, 有经验的人很难找了, 所以越来越多的公司从大学里招人. 不管你上的是什么大学,你都有机会在游戏产业里找到一份工作. 你需要熟悉以下领域.
数学 - 对于视频游戏开发,这个非常重要. 不,你不需要去记如何求一个绕x轴旋转的曲面的表面积. 你需要有很好的线性代数技能. 如果你不知道点乘的公式(a dot b = a.x * b.x + a.y * b.y + a.z *b.z )和它的几何意义( ¦a ¦ * ¦b ¦ * a和b夹角的余弦), 你是不可能获得工作的. 你需要知道如何把一个向量投影到另一个向量上(a到 b的投影 = (a dotb)/ ¦b ¦^2* b) 以及一个平面上. 你需要知道向量积(叉乘)是什么(a x b = [a.y *b.z – a.z * b.y, a.z * b.x – a.x * b.z, a.x * b.y – a.y * b.x]),以及它的几何意义(一个和两个向量都垂直的向量,长度等于原来两向量的长度乘以两向量的夹角的正弦). 我记忆向量积公式的方法是把i,j,k 放在矩阵的第一行,然后是第一个向量,最后一行是第二个向量, 然后计算这个行列式. 如果你不知道什么是行列式或者如何计算一个行列式, 这可不是个好的信号! 你应该知道一个矩阵的逆以及如何计算,你应该知道如何转置一个矩阵. 你应该知道什么是正交矩阵以及求它的逆的简单方法(求它的转置就行了). 熟悉各种坐标空间之间的转换是很重要的. 碰撞检测函数背后的数学原理也很需要学习. 你如何找到一条光线和另一条光线的碰撞点?一个平面呢?一个球面呢? 什么是四元数(quaternions)? 你如何对它们做一些常见的操作? 如果你的数学已经不那么熟了或者不知道如何开始, 我推荐 "3D Math Primer for Graphicsand Game Development".我读过以后发现它很好地覆盖了所有的基础知识. 我没有读过别的书来做比较, 但是这本书肯定会给你打下很好地基础,同时它也是很多游戏开发中常见数学运算的参考资料.
物理 - 你需要对各种抛物体的公式非常熟悉.如果你不能记住或推导出d = v0 * t + 0.5 * a * t^2, 你肯定会在面试或编程测试中遇上麻烦. 你应该能轻松解决任何涉及到抛物体和重力的问题.不论未知量是重力加速度, 发射角, y方向速度, xz方向速度, 时间,距离, 或其他任何可解的组合,你应该能没有任何困难的求出解来.你应该熟悉弹性和非弹性碰撞下的动量和动能变化. 滑动和摩擦力也是你应该理解的概念.
C++ - 虽然一些地方还在用c多过c++,但是C++已经是游戏编程中向被广泛接受的几乎标准的语言. C++的知识是非常重要的.因为如果用的不好, 你会写出非常糟糕的代码.首先,你应该知道什么是虚函数,以及如何使用它. 理解虚函数表是如何工作的也同样重要,这样你就能够理解当你调用虚函数时需要的额外步骤,这些步骤会降低性能(每个对象都有一个隐藏的虚函数表指针[具体在哪取决于编译,并且对指针做类型转换时,this会有变化],这样调用一个虚函数,你需要根据这个指针找到那个函数表,然后跳到它所包含的函数指针所指的函数里,这会降低cache的效果). 知道如何有效地使用模板和操作符重载也很重要. 关于C++,好的OO设计是最重要的. 最常用的一些类层次很深而且很费解,你最后需要做可怕的虚拟继承或者为一些不需要的变量浪费内存.
人工智能 - 我在大学里学习了标准的人工智能课程,但是这些东西没有一点在游戏AI中是可接受的. 教的很多算法很难实现或者对游戏而言不现实. 你知道什么是有穷状态机就够了. 绝大部分游戏使用有穷状态机, 而那些不用这个的游戏,使用的是简单的基于规则的系统. "白与黑"(包括它的续集)是我能想到的唯一的使用了其他东西(神经网络)的例外, 而且很多玩家对它的结果并不满意. 如果你想找本书, 我推荐"AI Game Programming Wisdom 3". 里面有两篇特别优秀的文章,一个是关于有趣的游戏AI设计,另一个是关于行为合成. 严肃的说,虽然书会很有帮助,但是学习游戏AI的最好的方法是实际做一个.
图形学 - 这是一个重要的领域. 如果图形是你的主要感兴趣的方向,那么你应该知道的比这里说的多.但是,不论你想要在这个产业里做什么职位, 你应该知道一些基础. 你需要知道什么是渲染状态以及通常都有哪些渲染状态?(cull, z write, ztest之类的).什么是标准的光照方程?(I =ka*Ia + Ii*(kd*(L dot N) + ks*(R dot V)^n) ). 材质映射是如何工作的?材质的wrapping和clamping有什么区别? 如何高效的渲染程序中一组几何体?(按照渲染状态组织你的几何体,按照你的硬件最快的primitive分批,饭后发给图形卡).你需要知道 skinning 是如何工作的. 如果你对书感兴趣, 我推荐 "3D Computer Graphics". 这个不是专为游戏写的,多以它包括了一些在游戏中不现实的技术.但是,我想一个总体的了解是有帮助的,而且,随着游戏硬件的发展, 那些现在看来不现实的技术会变的普通的.
工具开发 - C# 看来在游戏业界获得了不少地位.所以你也应该让你熟悉一下C#.C#在加快工具的开发上表现出不少优势.很多人说工具可以制造下一代的游戏, 我同意这一点. 拥有的工具越多,团队花在可以被轻易自动化的工作上的时间就越少. 可能你的团队有10个美工, 花程序员的一个人年来开发一个可以给美工每天省15分钟的工具并不值得,但是如果你有50个美工,那这就肯定值得了.C#可以快速的创建GUI,而且和其他一些能简化创建GUI的方法不同, 这些GUI很好理解和使用,因为他们是标准的windows组件,允许你方便的设定快捷键,就像其他Windows程序一样. Visual Studio 里的Form Designer 真的很好用,而且C#的metadata和event驱动的设计使得工具的开发轻而易举.你最好也对mfc有基本的了解,因为可能面试你的开发人员会有点落后与时代.如果你有兴趣学习很多关于这些技术是如何工作的(这会让你写出更好的C#代码),我强烈推荐"Applied Microsoft .NET Framework Programming",我在空闲的时候读这本书,然后我就不能放下了.我一章一章不停的读,因为我是那么激动的像学习下一章的话题了.记住, 这本书不会教你各种framework里的类和这些类是干嘛的.它讲的是这个语言的核心机制,它是如何工作的. 这本书也不是专门为C#写的. 它告诉了你如何用VB.net做一些在C#里不能做的是,它还提供了用MSIL(MicrosoftIntermediate Language, 所有.net语言的编译器都会编译出这种字节码)写的例子,实现一些不被任何一种.net语言支持的功能.
操作系统 - 虽然这个看起来和这个和游戏开发相对而言不是太相关, 但是我很高兴我在大学学习了操作系统的课程,因为我经常会用到从这门课学到的知识. 关于操作系统的知识非常重要,因为它在幕后为程序处理着很多重要的工作.特别是由于下一代的游戏终端和双核PC上的多核特性,多此案成的知识是至关重要的.对虚拟内存的了解当然是很有用的.关于文件系统,内核态和用户态切换,分页的知识对PC游戏开发更为有用, 不过随着一代代的发展,终端也在变的越来越像PC.所以,知道这些东西没有坏处.
编译器 - 虽然知道如何写一个分析器可能并不重要, 但重要的是知道你的代码是如何编程汇编代码的.这样你就能明白如何写出更优化的代码.你显然必须熟悉把你写的程序变为可执行文件的4个步骤:预处理、编译、汇编和链接. 编译器如何处理常量的? 很好的理解宏和知道如何用它来简化一些常用的操作是很重要的. 知道你正在用的编译器的调用约定,因为参数超过一定数目的时候,会导致它们被放在栈上而不是在预留的寄存器里. 调用约定的知识在你用汇编写函数的时候也是有用的.
这些只是一个作为一个游戏程序员,你应该具备的各种知识和技能的入门介绍. 对每个领域,根据你的工作类型,总会有更多的你需要学习的东西. 知道一些实际使用的知识之外的东西总是没有坏处的.
我怀疑这个文章该不会是MS的人在宣传他们的C#.NET吧 !!! ⊙_⊙ !!!