Tuesday, November 2, 2010

Written Gems - Course Litterature post mortem

It has been a while since last time I wrote here. Real Life(tm) aka getting married and other stuff has meant I have been really busy and the time to write 10 page articles are kinda restricted. While I have a couple of articles being partially written I can't vouch for when they will be ready.


Instead I will try to produce a series of shorter less in-depth articles that focus more on individual tricks and tips and less on complexer systems and we'll see how this pans out. So first out today are some book recomendations.

While working at a game development school you quickly discovers the importance of good course literature. While of course you can teach the students everything they need to know yourself it takes a lot of time and effort and since these educations aren't 5 years educations you won't have time to give them all they need.

But if you got good literature as a base it saves a lot of time. Not only has someone sat down and worked really hard to put in a written format what you need to tell the students but they can also study the book interdependently of the lessons when they are looking for now information.

A good book also gives a great base to build a course around. The problem is that there are so much literature out there that are either crap, focused on a purely academic stand point or otherwise simply not targeted to game students. And a lot of the game books are just shameless cash in attempts or written by authors who lack the necessary skills as either a programmer or a writer or just simply out of date.

And some books  while great are more useful after a few years in the industry or simply not build in a way that you can base a course around them. But through the years we have started to build up quite a nice library of books here to use and I will try to go through them during the coming articles. This might not be the best idea from a competitive advantage point as a school as the books are really important. But my main goal is for as many people as possible to become competent programmers and good books really helps here.

So lets start with the basic courses and move our way upwards. (btw I don't use cash links or anything like that so I won't earn a penny if anyone purchases these books, even though blogger has support for this I feel it would only detract from my main goal which is to put these books into the hands of as many people as possible)


C++ Primer (4th Edition) [Paperback]
Stanley B. Lippman
Paperback: 912 pages
Publisher: Addison-Wesley Professional; 4 edition (February 24, 2005)
Language: English
ISBN-10: 0201721481
ISBN-13: 978-0201721485
Amazon link

This is our basic C++ book we use for our introductionary courses, but also refers people back to pretty much every time they have a question about C++ releated things. Picking a course litterature for C++ for this education was really hard since it was years since I read any such base books. But a good friend recommended this one and I am really grateful for it. Despite having spent my last 12 years programming C++ as my job I still found new information in this book that I didn't knew about earlier.

This is however not a "learn to program" style book. It's based on learning C++. This this well into our unique approach here where we run two parallel courses one about how to program and one about how to program in C++.

The book starts out slowly  walking though all the different parts of C++ syntax while quickly focusing on giving the reader enough knowledge to actually be able to program in C++. After that  it starts going in-depth though the language, with amazingly well detailed descriptions of how things work under the hood and why some things works while others don't. Pretty much every area of the C++ language is covered with detailed explanations while never loosing readability. Things like implicit casting and how it conflicts with operator overloading, How virtual functions works behind the hood etc are described in great details telling you what rules the compiler follows so that you easily can write good code that works. If you are pretty new to C++ this is a gold mine. If you are an experienced programmer there are some nice stuff in here but probably not enough to make it worth your while. However I will cover a few books that didn't make it to course litterature but are awesome anyway in later posts.

Conclusion:  This is an awesome learn C++ book with enough in depth information that unless you have been working with C++ actively for a couple of years you will still learn a lot of new stuff here it is also a good reference for more tricky parts of the language.

3D Math Primer for Graphics and Game Development
Fletcher Dunn, Ian Parberry
Paperback: 429 pages
Publisher: Jones & Bartlett Publishers; 1 edition (June 21, 2002)
Language: English
ISBN-10: 1556229119
ISBN-13: 978-1556229114
Amazon Link

The linear algebra for 3D math was a tough course to crack here. The first year we had in an algebra teacher with classic algebra knowledge and sat down with him and discussed what we wanted the students to know. This didn't work out however. Not due to a fault of the teacher the students were excellent at solving linear algebra with pen and paper but had problems transferring this to usable facts in 3D math and we had to spend a lot of time to work on this. For the second year we ditched the classical math texts and run the course completely based on lectures and compendiums. This worked out decently but I felt that with a good book as base we could have gotten further as there is only so much time you have to prepare a lecture. But all the books we looked at was either to academic or required to much prior knowledge until a student that was having some trouble with the course purchased and recommended this book.

When I got it in my hand I was amazed. Here was a book that tried to teach Linear Algebra in almost the exact same way as I wanted to. By focusing on approaching in not only from a purely mathematical stand point but also showing what it all means from a geometric standpoint. It also explains coordinate systems or spaces as they are often called as concept quite well and this is an area where in my experience students often have problems really grasping the basic ideas.

It covers normal vector,matrix math of course and all kinds of operations on vector you would need to know about for 3D math again with geometric explanations of things like the dot product and cross product.I can't vouch for it's sample code since I never used it. But then again sample code is not really relevant you want to learn things not just copy them. It gives a sensible explanation of matrixes using the Affine Transform vs Linear transform to explain things I myself always had been using other terms for but basically derived the same idea independantly.

It contains a good discussion of the different ways to contain an orientation in 3d with advantages and disadvantages and covers quaternions in the process. After that it covers collision detection with a diverse set of geometric primitives working with basic 3d meshes and discussing and showing how the math applies to basic 3d operations like lightning fog and culling. If finishes of with discussing spatial representations for culling and occlusion.

Conclusion : This really is a complete 3d primer from the first step to actually applying it in game. This is an absolute gold mine of information for anyone getting into 3D math and I simply can't recommend this book enough I simply love it.



It seems these posts are gonna be a bit longer than I thought when I started this one so I will have to split it up over a couple of posts to make it manageable. So I will continue in the next posts.

Monday, June 28, 2010

The Wonders of Fixed Point Math - Or how I got XNA to cull thousnands of objects fast

So what is fixed point math ? Well you could say that it's an old technique to approximate decimal numbers on computers without floating point processors.

So why should we care about it then ?

A good questions there are multiple instances where using a fixed point representation can help you considerably. One is if you are running into the problems of the inconsistencies that are at the core of how we handle floating point math on modern computers. Or if you are simply running on a platform where the floating point performance is way to low and you don't need 6-7 decimals of accuracy.

For me while working professionally it has been along time since I had to use fixed point. But then again there has been plenty of cases it has been under serious discussion to resolve issues with floating point inconsistencies and I know of numerous companies that have used them to battle the problems.


Tuesday, May 18, 2010

Auto balancing Decision trees aka Resource Trees II

Just continuing from last time.

So after we called Act on the economy node it checks that it isn't a leaf node and therefore it checks it resources.



Monday, May 10, 2010

Auto balancing Decision trees aka Resource Trees I

Today were gonna talk about a process for decision making that you can use for higher level Ai functions in games. Basically this method can handle purchases, tech level up. In some case even goal selection for a computer opponent. I will discuss this in the context of trying to make an Ai for an RTS game but the same principles will hold for a turn based strategy game and depending on context in a lot of other games too.
So the basic idea here is the following. Computers are really good at managing tree structures we have tons of efficient algorithms that works well with them and we can search in them easily. This however is not just limited to existing algorithms, basically any kinda of data is normally easy to analyze if you can represent it as a tree.

This comes from the fact that when you represent data as a tree you have already performed a divide and conquer on that data to divide it into smaller parts. Those making the code to crunch the data for each node of the tree a lot simpler than if you had to crunch all that data in one piece.


Monday, May 3, 2010

Still alive here

3D:

Shadow Maps
This is pretty much the standards for doing shadows in games nowdays, and the dafacto standard for doing them for movies, Shadow buffers in difference form shadow volumes is image based and can therefore handle alpha masked polygons like a fence, It also allows techniques for blurring or otherwise distorting the shadows.

Percentage Closer Filtering 
A problem with shadow maps is that they easily get pixelized even with the best intentions. Percentage closer filtering is a technique to combat those jaggies and making your shadow edges soft, We will look at different implementations for example randomised kernel rotation with a poisson disc.

Percentage Closer Soft Shadows
In the real world shadows become softer and softer the further they come from the object casting the shadow. This is how to do the same in games using a technique that builds on the Percentage Closer Filtering technique.


Monday, April 12, 2010

Slight hiatus

Due to me getting married and going on my honey moon game school gems will have a short 3 week hiatus until I return.

Wish me luck :)

Monday, April 5, 2010

Code Standards - Why we need them

It might be a bit far fetched to call this a gem, at the same time for those who have never worked in a team before or are trying to organize one this might be life saving. I also feel that I need to add some more articles that cater more to the beginning programmer, while these sorts of articles won't become the standard for the site they will appear from time to time.

So what is important about code standards you may ask ? There are two main cases, one is when working with other people and the other is when you are working with code you haven't touched in a along time. The problem with a lot of code you find on the net and tutorials are that they are inconsistent in how the code looks or hard to read, obviously that lats part is subjective when you are used to it any way of coding might be easy to read. But when you are working with code you haven't touched in a long time you are unlikely to remember all the details of that code so any code standard that makes the code easier to read and understand helps.


Sunday, March 28, 2010

Influence Maps II - Practical Applications

Now it is time to look at how we can use influence mapping in a practical application showing how we can use a simple influence mapping based scheme to create an AI that reacts surprisingly realistic and intelligent as long as it works within certain perimeters and you aren't trying to control it too precisely. This test as I have implemented it will only be using the basic Influence map but we will discuss interesting possibilities of using the other maps too. I am also sure that you by yourself will imagine a ton of ways to use the maps and even create new maps after these two articles. But for now we look at creative ways to use what we have learned so far.

What we are going to be looking on is what we used early on as an experimental Ai for Ground Control 2 it actually become the basis for that AI though heavily modified, partially because it did defeat our project lead 1 on 1 but mostly because the single player team needed a lot more control to create interesting single player missions. But within it's limitations it performed admirably and as I mentioned did become the basis of the AI.


Monday, March 22, 2010

Influence Maps I

In artificial intelligence one of the biggest problems is how to convert a complex world into a set of data that the AI can actually understand and work on. The real world or even a game world is infinitely complex and different techniques to compress that infinite data set into a usable format is a classic problem in ai research. Thankfully for games we don't have the trouble of having to interpret the image from a camera to create a 3dimensional world to move around in.

We have the advantage of having access to extremely detailed data of everything in the game. But the amount of data we have access to makes any sort of planning by the means of calculations impossible. The world is simply to complex, so in order to be able to work with it we have to employ a series of different algorithms the one we are going to look at today is called influence mapping and it's a way to resolve the actual strength relation ship on a map and helps to base tactical decisions on this. It has nothing to do with purchase planning or high level strategical decisions It's simply a analysis tool to create an accurate and usable view of the world.

Influence maps are based around the concept that objects in the game influences the strength relationships between the players and this influence spreads from their current position outwards throughout the map. If you add in all the influence of all the objects then you would get a view of the relative strength relationships for that part of the map. You should also be able to detect the actual front lines between the different sides with it too. As we will show later on we are able to calculate a lot of different data from the influence maps but for now I think it is time to go back to explaining how this all works. But as a tease in the end of this we will discuss how to create a simple army level opponent behaviour by only using influence maps. There will be limits to it of course but it is still pretty cool.


Monday, March 15, 2010

Trivial navigation mesh generation II

This one better not turn out as long as the last one or I will have to split this out over even more articles. The reason I allowed the last article to become so long is because I wanted to leave you with enough meat to implement it so that if you wished you could have it done by this post and then start refining it.

The meaning of Updating

The reason I always refers to updating is because you can’t just set a triangle to being blocked or unblocked. Well you can do that but what if the same triangle gets blocked by more than one obstacle for example and then that obstacle is destroyed. If you just set the triangle to unblocked you will be able to drive through one of the objects. And if you don't then you can't make objects that you can destroy dynamically at all.

Monday, March 8, 2010

Trivial navigation mesh generation I

This is going to be a intermediate level lecture so before you read this lessons there are a couple of things I'm going to assume that you have prior knowledge of.
  • A*
  • The different search space representations for it and how to use it on them.
  • 2D Line vs 2D Line intersection
  • 2D Triangle vs 2D Triangle Intersection
  • 2D Triangle inside Triangle tests
  • 2D Point inside Triangle test
That's it so it's not a too hefty list basically it means you understand A* and that it is a graph based algorithm and that the natures of the graph might change, and basic linear algebra knowledge or well access to a basic 2D intersection library. I'm sorry I can't touch on everything but I have to try to keep the articles short and focused on the target. I will spread the difficulty level around quite a bit but at the moment I am mostly looking at the things we teach at the beginning of the second year at TheGameAssembly but there will appear articles targeted to beginners too and some like the last series that can be enjoyed booth by beginners and intermediate students.


Monday, March 1, 2010

Lighting models for games III

Last time we had just made the move to per pixel lighting which made a huge visual difference without changing our formulas even the tiniest bit. You might wonder why I didn't start using it and it's a valid question as the per pixel vs. per normal really doesn't matter for the lighting model. The reason I did so was to shoe the huge difference of applying high quality content can do to the look of an object. No matter how much work we do with our lighting models and formulas it doesn't matter unless we have a skilled artist by our side.


Monday, February 22, 2010

Lighting models for games II

Alright last time there was a lot of dusty theory of light that we had to cover. This time we will get down with the more practical side of modeling the effects of the light and actually look at the visual effects. For these examples I will use a model from one of our projects at TheGameAssembly.

I have to mention now in the case of artists watching this that most of the maps here has not been properly artists tweaked in fact I am working with none final content. Besides this I have tampered around a bit with the maps to make the effects I am trying to show more obvious.

Monday, February 15, 2010

Lighting models for games I

This is going to be the first in a series of lectures focusing on covering some lighting models for games and also the actual physical properties of light and materials they are based upon. We will also work with examples booth from real life and from a simple engine using some art courtesy of the students from TheGameAssembly.

But for this first part we will be focusing our attention on the different properties of light and actually understanding what is happening in the world around us. As in the end this is what we are going to try to simulate in the computer.

Introduction

Hello and welcome to Game School Gems. The goal of this blog is to collect various gems (short and useful techniques) that I have come upon during my 12 years in the game industry. It will be things that I either find important by themselves or things I have noticed an extra need for in my students at TheGameAssembly.

This blog is not intended to be an online game curriculum, there are things I won't touch simply because I can't make a meaningful explanation of them without going over a lot of updates. I feel it would be incorrect to monopolize the blog for half a year to cover linear algebra in depth for example. The focus is on finding gems that are directly usable and can be explained well in below 50 pages(my current max limit for a subject and I hope I can keep it).

In the same way this is not intended as a course literature for TheGameAssembly either, for those of my students that does find their way here you will notice that though you will find the same subjects in my classes the way they are discussed here is in much greater detail. This is because this is meant as an online learning resource, I can't have the same expectations of everyone who reads this one as I have for my students that are excepted to fill in a lot of this information on their own to learn practical problem solving which is one of the basic programming skills.

That however is a different path that can be taken but for now I am just trying to get this knowledge out to as many people as possible so that I in some small can way give back all the things I learned in the industry and also hopefully rising the lower bar for what knowledge we can except when getting job applications.

Basically this is a site for you to learn those gems and in order for you to be able to do so I have gone to great lengths in trying to make the explanations complete but there will always be material for you to fill in.

If anyone wonders who I am here is a short introduction:
My name is Niklas Hansson and I started working in the games industry back in 1997 when Massive Entertainment was founded. Back then I was probably a lot like you guys reading this, I was young and interested in programming and computers, The difference is that back then it was almost impossible to find information about games programming there was some books and some BBS:es but internet was just in it's birth even though #coders on efnet contained alot of really bright people from the demo scene.  I am doing this blog to help other people in the same position i was in back then to make the same transition from a hobbyist to a professional. I worked at massive for 12 years working as the Lead programmer on booth Ground Control II and World In Conflict. I handled the hiring of programmers for massive during my last 5 years there or so, I also worked on the original Ground Control and other projects.

When working with hiring I often met bright young people who sadly hadn't gotten the education they needed to work in the industry this lead me to at last in 2008 to leave my position as Software Development Manager at Massive to help with launcher what was then known as theGameAcademy but turned into TheGameAssembly due to legal reasons. For now I have worked there as a teacher for almost two years learning how to put my practical know-how into knowledge that I can pass onto my students.

So now I finally feel ready to move on to launching this blog to reach an even greater number of people. I have had to make so many people sad that they didn't get their dream job so now I want to help you to make your dream true just as I did.

Well this sounds cheesy but that's the bottom line and that's what this blog is all about. I hope you find it a useful source of information. Also you can suggest topics you are interested in during my Career I have been lucky enough to work within many different disciplines of game development so I can write about most things.  But if you don't send in suggestions the blog will probably mostly be talking about the subjects we handle during the second year of school.

Updates should be released weekly on Mondays.