Cat and Mouse Simulation Design
State Transition Diagram
State descriptions for the cat
| State | CatWander |
|---|---|
| Enter | set maximum velocity to wander level switch wander on. |
| Update | if the cat sees a mouse then change state to chase-mouse state |
| Exit | switch wander off |
| Message ID | Action |
| State | ChaseMouse |
|---|---|
| Enter | set maximum velocity to chase level send AFTER_YOU message to mouse after half second delay switch pursuit on and target mouse |
| Update | if the mouse is caught change to kill-mouse state else if the cat cannot see the mouse change state to seek-mouse state |
| Exit | switch pursuit off |
| Message ID | Action |
| State | SeekMouse |
|---|---|
| Enter | set maximum speed to seek level adjust last known mouse position to fit inside cat's world domain switch arrive on and target last known mouse position |
| Update | if cat can see a mouse change state to chase-mouse state if close to last known position change to cat-wander state |
| Exit | switch arrive off |
| Message ID | Action |
| State | KillMouse |
|---|---|
| Enter | set velocity to zero increment number of mice killed send DIE message to the mouse send NEXT_MOUSE message to self with 2 second delaye |
| Update | |
| Exit | |
| Message ID | Action |
| NEXT_MOUSE | if there are mice left change to cat-wander state else reset the simulation to start again |
State descriptions for the mice
| State | MouseGlobal |
|---|---|
| Enter | |
| Update | |
| Exit | |
| Message ID | Action |
| DIE | mark mouse as dead so the cat will not look for it set velocity to zero switch off all steering behaviours remove this mouse from the world after 0.5 seconds |
| State | MouseWander |
|---|---|
| Enter | set maximum speed to wander level switch wander on |
| Update | if mouse can sees the cat change to evade-cat state |
| Exit | switch arrive off |
| Message ID | Action |
| AFTER_YOU | change to evade-cat state |
| State | EvadeCat |
|---|---|
| Enter | set maximum speed to evade level if distance from cat is > 100 switch hide on else switch evade on |
| Update | if mouse cannot be seen by the cat send SAFE_HERE message to self with 1 second delay |
| Exit | switch hide off switch evade off |
| Message ID | Action |
| SAFE_HERE | change to mouse-wander state |