CS/IMGD 4100 (C 16)
Homework Assignment #3
Due by Web Turn-In: 11:59pm, Sunday, January 24
(See general homework instructions for turn-in details.)
The purpose of this assignment is to gain experience formalizing a modestly complicated AI behavior as a finite state machine. Imagine that you are an AI developer in a game company and one of the designers has given you the textual tank behavior specification below. Your job is to formalize the behavior as a state machine clearly enough so that your documentation could be handed off to a low-level programmer to implement (who may be you!).
Here are the basic steps and work products you should go through:
If you decide to use a hierarchical state state machine (which is optional), then you will have "bubbles inside of bubbles" in your diagram and there will be a separate pair of tables (for part 1 and part 2 above) for each nested state machine.
- Create a table that describes each state, the game properties it references, and the actions that occur in that state. (Buckland does not have an example of this kind of table.)
- an example property might be the vector from the tank to the player
- an example action might be to run an explosion animation or to turn on steering toward a particular target
- 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 conditions (boolean functions) that will be used to control transition between states. (See example of Table 2.1 on page 47 in Buckland.)
- describe each condition in words or pseudo-code
- define short (but understandable) abbreviations for each condition
to use when labeling transitions in diagram (e.g., "low_health")
- Draw a "bubble and arrow" diagram for the finite state machine.
- 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.
- don't forget to indicate the initial state
Remember, this is a detailed design document, not an implementation. At this level of design, don't worry about variable names, which information is stored in state instances vs. game entities (singleton state implementation), etc.
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
(NB: Do not make a state machine with just three states!)
- 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 (also mounted on the turret) 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 (i.e., if the player gets more than 10 meters away again).
- 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 conditions table.
- State transition diagram.
Please post any questions to the myWPI forum for the course.
- 4 points - Correct and complete implementation of specification
- 0.5 point deduction for each incorrect behavior
- 0.5 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.