Using a Game Engine for AI Research

Alex J. Champandard on September 7, 2007

anthony asks “I’m an aspiring AI Programmer, I’ve written a few small games for college projects and I’ll be doing my MSc thesis soon enough.

I was wondering if you thought it would be a better idea to write my own small game (e.g. a simple variant on CTF in 2D) for testing out various AI techniques or to use an existing game (Doom3, Unreal etc) instead.”

Good Practices

That’s a great question. Before I discuss engines in more detail, here’s some advice for your research in general:

  1. Write the bulk of your AI code as a separate library to be engine independent.

  2. Use console-based automated tests to prototype all your functionality.

  3. Integrate working features into whichever engine you feel most comfortable with.

The idea is that you shouldn’t be too dependent on any engine. You don’t have to develop in fully test-driven style, but using a simple text-based application with multiple little tests is a great workflow for helping you prototype ideas.

As for the engines, ultimately it’ll depend on how comfortable you are with the codebase and the tools you choose. Your experience of the C++ language and with large game projects should affect your decision.

Existing Game Engines

Most game engines are not easy to extend, despite what their marketing department tells you! It takes whole teams of professionals to reuse a game engine and make a just a simple derivative. The further you diverge from what the engine was intended to do, the harder it is to change.

With that in mind, here’s some advice to help you focus on your AI research and be more productive:

  • Go for open source game engines if possible (e.g. Quake 3). Having the whole code available is a huge help when trying to understand the codebase, and it also removes any limitations.

  • Use older engines that were developed a few years ago (e.g. Quake 2). You don’t need the graphical bells and whistles of modern engines, and you’ll get a faster simulation because of it.

  • Also, consider picking an engine that’s most similar to what you want to do (or design your demo to match what’s possible with the game engine).

There certainly are many advantages of working with a real commercial codebase, warts and all.

  1. It’s one of the greatest skills to be able to understand and learn from large codebases and poorly documented source!

  2. Working on AI in 3D environments is an important skill to have if you want to move into industry later.

  3. Using game engine makes for a better demo, so it’ll be easier for you to convince game developers of the applicability of your ideas.

In essence, using an existing game engine is the best way to go if you’re technically comfortable with using one.

Custom Engine

It’s probably not wise to attempt to rebuild a 3D environment yourself. It’ll take a lot of work to find models, animations, textures, etc. However, as you said, a 2D environment is very sensible.

To to that, you can use an open source engine which will allow you to create a simple vector-based renderer:

I’d recommend this approach if you’re not too confident with fully blown game engines, or you don’t want the benefits of a 3D demo, then this approach is for you.

If you have any advice for Anthony post it in the comments!

Discussion 2 Comments

teamonkey on September 10th, 2007

I'm very surprised that there isn't some kind of framework floating about specifically for this purpose. Not so much a game engine, but something very modular and extendable designed for prototyping and experimenting with AI. Not something you'd release a commercial game in, but a rapid development tool that would let you refine a technique for personal learning or until it was ready to put into a game. I've got a list of things that I'd like to put in to my AI prototyping engine, but it's a matter of finding the time. One dead-end that I tried was modding, and you're right when you say that existing game engines are not easy to extend: even games that are designed for modding become difficult to manage when you want to add non-standard behaviour. HL2 looks like a good choice for modding, until you realise that the AI facilities provided are really basic. Kudos to the HL2 designers for providing the illusion of intelligence while having to work with such a limited framework.

Kessel on February 21st, 2008

Hi, this is maybe another interesting engine for rts game ai research:

If you'd like to add a comment or question on this page, simply log-in to the site. You can create an account from the sign-up page if necessary... It takes less than a minute!