Source Code and Compiled Executable

This was a C++ project I wrote for my AI class at DeVry. It demonstrates steering forces; forces that make an AI agent behave in certain ways. Most of them are fairly basic, but I’ve always found them interesting to play with.

The behaviors implemented are:

Seek – Which moves an agent at full speed towards a target, tending to over shoot it and bounce back at full speed.

Flee – The opposite of seek; the agent moves away from the target at full speed. Because this screen wraps around, the agent tends to hit the screen edge, wrap, and then turn around to get away from the target in the other direction.

Arrive – This is basically Seek with some dampening. The closer the agent gets to the target the more their speed is reduced, until they eventually stop at the target.

Wander – This projects a target in front of the agent and makes them seek it. I Noticed when bringing this back up that they tend to get stuck in the wrap edge of the screen. I have not adjusted for this yet.

Obstacle Avoidance – The agents should go around the black circles (obstacles). The physics simulation in this is not particularly complex (and not highly accurate), and sometimes they do clip the obstacle a little.

The screenshot below gives an idea of how this is setup; one agent Wanders, another uses Arrive towards the mouse cursor, a third Seeks a random point, and the last responds to input to change behavior.

The application uses Direct3D and DirectInput (using a wrapper I wrote), implements a templated state machine, a singleton design pattern (for the core modules that should be static), and a manager design pattern (to keep the agents moving). It is compiled for Windows, using the Win32 API.

Leave a comment