One thing that’s obvious from looking into the AI source code of different game engines is that there are many ways to structure a codebase! Certainly, a sensible engine structure is a basic requirement to build a game, but anything beyond that is a matter of personal preference.
This week’s developer discussion on AiGameDev.com is about how you organize source files when you’re building AI into a game. Regardless what language you use (C++ or Java, and even Python), feel free to share your experiences by posting a comment below.
As games and their engines become bigger, a bunch of files thrown together ad-hoc are more likely to cause problems. Using libraries, or structuring the files within folders helps. Here are some of the tradeoffs:
A library enforces a certain layering and preserves a healthy structure to the codebase. It can help divide responsibilities among programmers if necessary, and facilitates quick automated testing.
On the other hand, it can be a pain to write separate AI code with many static languages like C++ or Java since the AI is very much tied to the game itself. You end up with a choice of type safety with bulky software design patterns like the visitor, or using casts everywhere…
Which do you prefer? Any horror stories to share? This raises the question about where to put the AI library if there is one, or the AI files otherwise…
Game vs. Engine
Nowadays large AAA studios seem to have separate engine and game teams. Even smaller games are sometimes organized around a reusable engine. But there are many possible places to put the artificial intelligence:
Should the AI code be exclusively part of the game project? F.E.A.R.’s SDK includes pretty much the whole of the AI as part of the game code. The engine is kept separate though.
A few years ago, you would take it for granted that some AI code was necessary in the game itself, beyond just engine support. But with advances in data-driven engine, is this still the case?
So, where do you personally draw the line between the engine and the game?
Join the Discussion!
You can either post a comment below by clicking here or leave a message in the forums too. Be sure to share your experiences regardless of the language you use!
Stay tuned for next week’s discussion also to win a copy of BioShock signed by the AI team, courtesy of 2K Boston who have an open position for a Senior AI Programmer.