IMGD 400X (B 08)
Homework Assignment #3
Due by Web Turn-In: Midnight, Wednesday, November 5
(See general homework instructions for turn-in details.)
The purpose of this assignment is to gain experience formalizing an AI behavior as a finite state machine. Imagine that you are an AI developer in a game company and one of the designers gives you the textual tank behavior specification below and wants you to implement it.
Here are the basic steps and work products you should go through:
Feel free to use a global state (as in Buckland's state machine implementation). However, at this level of design, don't worry about whether game environment information is stored in state instances or game entities (singleton state implementation).
- Create a table that lists all of the states and their properties and actions.
- an example property might be the vector from the tank to the player
- an example action might be to run an animation
- assume that animations are run on a separate thread (asynchronously), i.e., if a game state starts an animation, it may need a condition to test when the animation has finished
- Create a table of game conditions that will be used to transition between states.
- define convenient abbreviations to use when labeling transitions
- Draw a diagram that includes the states and their transitions.
- the drawing tools in PowerPoint are probably sufficient for the job (use "connectors" to make it easier)
- or you may also wish to use a more sophisticated tool, like Visio.
Finally, don't be surprised if you discover during the formalization process that the textual behavior specification below is incomplete (that's typical and part of the goal of formalization). Make reasonable decisions on the incomplete cases and document them.
Tank Behavior Specification
- The tank becomes active when the level is initialized.
- It will wander
about the "patrol zone" portion of the level. In this state, the
turret is always pointing the same direction as the direction of
- The tank will engage in combat with the player when
- (a) the player enters into the field of view of the turret, or
- (b) the player fires a weapon.
- When in combat, the tank's turret will track the player and fire at a fixed rate. The tank body will also turn towards the player, but the turret can turn faster.
- If the player is out of view behind a non-destructible object (like a rock), the tank will cease fire but continue to track the location where the player was last seen.
- If the player is behind a destructible object (like a Jeep), the tank will reorient its fire to destroy the obstacle, i.e., it will shoot at the object rather than the player.
- The tank's main gun cannot fire closer than 50 meters, so the tank will try to maintain at least this distance to its target.
- If the player comes within 50 meters of the tank, its machine gun will fire in bursts. The machine gun will not attempt to destroy obstacles.
- If the player gets closer than 10 meters, the tank will cease trying to move to main gun distance and will instead drive toward the player to crush him. All firing ceases while this is happening, but begins again if the player evades.
- If the player hits the tank with a RPG or hand-thrown grenade, it will cease firing while an explosion animation is shown.
- If the tank's health is less than 25%, it will begin emitting smoke and the main gun will cease functioning, leaving only the machine gun.
- If the player's health is reduced to zero, the tank heads back towards the patrol zone.
- If the tank's health is reduced to zero, it explodes in a fireball.
What to Turn In
- State property and action table.
- Game transition table.
- State transition diagram.
Please post any questions to the myWPI forum for the course.
- 4 points - Correct and complete implementation of specification
- 1 point deduction for each incorrect behavior
- 1 point deduction for each missing behavior
- 1 point - Software engineering quality (clear organization, layout, naming conventions).
Acknowledgement: I would like to thank Robin Burke for allowing the reuse of this assignment.