How does Lazy Larry think?
Larry's electronics and hardware is controlled by a state machine. There are five distinct states-- Waiting to Start, Waiting for User Clap, Waiting for User Poke, Waiting for Pick-up, Waiting for Put-down, and lastly a random generator state that chooses Larry's next action. Once Larry has chosen his next action, the user must give him the proper response in order for Larry to pick his next action. If the user gives Larry the wrong response, Larry will not go into his next state and will request the action from the user again. Larry can be quite demanding!
Additionally, there are three timers that will trigger different actions--the first, is a request timer. If the user doesn't attempt to respond to Larry after he requests an action, the request timer will expire and Larry will repeat his request. If the request timer continues to expire, the action timer expires and Larry goes to sleep. The only way to wake him back up is to press the restart button. Once the game has ended, the game timer will expire and Larry will either do a happy dance or sadly throw his arms down depending on the score of the user.
Additionally, there are three timers that will trigger different actions--the first, is a request timer. If the user doesn't attempt to respond to Larry after he requests an action, the request timer will expire and Larry will repeat his request. If the request timer continues to expire, the action timer expires and Larry goes to sleep. The only way to wake him back up is to press the restart button. Once the game has ended, the game timer will expire and Larry will either do a happy dance or sadly throw his arms down depending on the score of the user.
PseudoCode for Larry's State Machine
lazylarrypseudocodedraft.doc | |
File Size: | 145 kb |
File Type: | doc |
Source Code Listing
|
Header File Listing
|