![]() |
![]() |
![]() |
![]() |
![]() |
The Demon Game
The example that has been chosen in this tutorial is a simplified version of the "Demon game", which is a well known example in the SDL community, since it is, among other things, used as example in the SDL recommendation.
The SDL definition of the Demon game may be found in SDL/GR form later in this chapter (see "Appendix A: The Definition of the SDL-88 DemonGame" on page 128). The definition of the behavior of the Demon game is probably not the simplest way of describing the game, but it has been selected since it is good for demonstrating the facilities of simulation and validation.
Behavior of the Demon Game
Seen from the environment, the behavior of the system is as follows. The system accepts four different types of signals, Newgame, Endgame, Probe, and Result, where the first two signals are used to start and end a game. Only one game at a time can be played, that is, Newgame signals will be ignored when a game is in progress and Endgame will be ignored if there is no game in progress.
The game in itself is very simple. A "demon", which in the system is represented by the process Demon, changes the status of the system every now and then between winning and losing. This is represented by the states Winning and Losing in the process Game. The user is to guess when the status is winning. If the user probes (outputs the signal Probe), when the status is winning, he wins one point. If the user probes when the status is losing he loses one point. The system responds to a Probe signal by either a Win or a Lose signal. To see the current score the user can issue a Result signal, which will be answered by a Score signal containing an integer parameter giving the current score.
http://www.ibm.com/rational |
![]() |
![]() |
![]() |
![]() |