AiGameDev.com

“Join leading experts and industry veterans in Paris on June 23-24 for the largest independent conference about artifical intelligence in video games.” — Alex

membership

The Premium Membership area at AiGameDev.com is the best place to stay on the cutting edge of artificial intelligence in video games.
Find out more!

sponsors

categories


subscribe

Search


related articles

Sponsors

SpirOps

PathEngine


Building AI for a Simulation Game from the Ground Up

Alex J. Champandard
October 24, 2007

Do you ever ponder about the best way to create artificial intelligence for games? Well, me too! After years of industry experience and research, it still fascinates me. But one thing is certain, it requires lots of practice…

This article launches a series of tutorials, every Wednesday on AiGameDev.com, building game AI from the ground up. The plan is to focus on incremental improvements with tangible benefits at each step. Of course, over the months, it’ll hopefully turn into a showcase of current game AI techniques.

Dog Behaviors

Figure 1: Different dog behaviors.

The simulation game involves dogs interacting together, though the design is pretty open at this stage, as it’ll be refined incrementally based on your contributions! (Be sure to join the discussion each week by leaving a comment.) This week in particular, you’ll find out what’s in place already and what the plan of attack is.

Building Blocks

Before creating the AI, you’ll need the basic ingredients of a game first! This tutorial relies on simple assets and a game engine.

Models & Animations

It’s tough to find good models and animations online, so often the best solution (if you want things to look good in the end) is to buy “stock” assets. In this case, the models look fine despite being low-poly, but they reveal a few glitches when animated. The animations won’t win any awards, but they’re better than programmer art.

Specifically, the animations available are:

  • For movement, there are animations for walking, jumpy run, turn left or right, strafe left or right, sneaking and limping.

  • There are also different postures (including transitions) such as lying down, standing on two legs, sitting and sleeping.

  • In terms of interaction, there are animations for picking-up, sniffing, licking, eating/drinking, peeing, pooping, begging and fighting.

  • Other behavioral animations include, high and low jump jump, barking, scratching, chasing tail, growling, and excitement.

No doubt it’ll be necessary to tweak the animations into a AI-friendly format, for example to add missing looping animations, or correct existing ones. Also note that all the animations are modeled at the origin, so there’s no movement in the animation data. (This affects the design.)

Game Engine

While many open-source engines have similar features, the plan here is to use Ogre3D. It provides exporters for the models and animations, and stores them in its own format for easier loading. At runtime, Ogre provides an API to play each animation, control their speed, and blend between different animations. Of course, it’s trivial to move around any entity in space using the scene manager.

Artificial Intelligence

You don’t need anything but a 3D engine and assets to start programming AI. However, this tutorial series will be developed alongside Game::AI++, an open-source library that’s in early development stages. This project will be a good opportunity to iron out the rough edges in the parts of the framework that are already implemented. Rest assured though, re-implementing the ideas in the tutorials won’t require using Game::AI++.

Getting Started

At this stage, all the basic elements of an interactive simulation are already implemented. The game view opens, models are loaded and can be displayed on screen.

Dog sitting, dog lying down.

Screenshot 2: Two inanimate dogs with static skeletons.

The next step is to work on the most basic AI features. Typically, the best place to start is to write the logic to control each actor, in particular:

  1. Moving Around — The 3D engine already supports most kinds of transformations, but these need to be exposed in an AI-friendly way. Specifically, all movement needs to be done relatively to the current position, and the parameters of movement must be easy to tweak.

  2. Playing Animations — Again, the animation system in the engine handles posing the skeleton from keyframes, but there needs to be an easy to use interface for each actor in the game. Options such as playback speed and looping should be easy to specify also.

If you have other suggestions about places to start the implementation, feel free to use the perfection game to help improve this plan of action. Post a comment below.

First Design Ideas

Here’s where you get the chance to think of simple designs that can be achieved with this simple technology. This week, there are some important restrictions:

  • The behaviors must be applicable to individual dogs only.

  • The behaviors should not require reacting to the world.

Anything else goes, so feel free to share your scary ideas about this game! Think along the lines of behaviors that are sequences of different animations and movement.


Bookmark and Share




Comments