Logical Interactions
Player API
public: String name() |
|
public: Board proposeBoard0(Natural rows, Natural columns) |
// the player may be asked to propose a game board |
// that comes with a min. # of rows and columns |
|
public: Any setup(Option<State> state0, Coordinate goal) |
// the player is handed the inital state, which is visible to all |
// plus a (private) goal that it must visit next |
// |
// if state0 is NONE, setup is used to tell the player go-home |
// and goal is just a reminder where home is. |
|
public: Pass or Action takeTurn(State s) |
// after receiving the state, a player passes on taking an action |
// or picks |
// -- a row or column index and a direction, |
// -- a degree of rotation for the spare, |
// -- a new place to move to. |
|
public: Any win(Boolean w) |
// the player is informed whether it won or not |
Sequences
The interaction between Racket player components and the Racket admin framework is governed by the set of following interaction diagrams.
Setting Up a Game
|
referee player (p_1) . . . player (p_n) |
| | | |
| | | |
| | | |
| proposeBoard0(N,N) | | % an _optional_ request for a |
| -----------------------------> | | % board of a particular size |
| board | | |
| <=============================================== | |
. . . |
. . . % repeat for ascending age |
. . . % for every player, if at all |
| | | |
| proposeBoard0(N,N) | | |
| -----------------------------------------------> | |
| board | | |
| <=============================================== | |
| | | |
| | | |
| | | |
| setup(state,coordinate) | | % the initial state for this game |
| -----------------------------> | | % the target tile for this player |
| | | |
. . . |
. . . % repeat for ascending age |
. . . |
| | | |
| setup(state,coordinate) | | |
| -----------------------------------------------> | |
| | | |
Playing Turns
|
referee player (p_1) . . . player (p_n) |
| | | |
| takeTurn(state) | | % player receives: |
| -----------------------------> | | % - current state |
|
action 1: |
| PASS | | |
| <============================ | | % pass on this turn |
| | | |
|
action 2: |
| Choice | | % a choice that includes |
| <============================ | | - a row or column index |
| | | - a direction |
| | | - a number of degrees |
| | | - a place to go to |
| | | for the avatar |
+-- | | | |
| . . . % if legal: |
| . . . % referee modifies game state |
+-> . . . % otherwise: |
. . . % kick player out |
. . . |
|
if the player reaches the assigned treasures-target with this turn: |
|
| | | |
| setup(NONE,coordinate) | | % no state; just a reminder |
| -----------------------------> | | % to go home |
|
|
if the player reaches home with this turn, the referee terminates the game: |
|
| | | |
--- |
|
|
|
|
|
| takeTurn(state) | | |
| -----------------------------------------------> | |
| response | | |
| <=============================================== | |
| | | |
. . . |
. . . % repeat until all remaining players |
. . . % reply with PASS in one round |
. . . % or one player has returned to |
. . . % its home after visiting its target |
. . . |
Scoring a Game
|
referee player (p_1) . . . player (p_n) |
| | | |
| | | |
| win(Boolean) | | |
| -----------------------------> | | % true means "winner" |
| | | % false means "loser" |
. . . |
. . . |
. . . |
. . . |
| win(Boolean) | | |
| -----------------------------------------------> | % both winners and |
| | | % losers are informed |
| | | |
Convention The % parts on the right are interpretive comments. ~~
------> are calls |
<====== are returns |
A missing return arrow means that method must successfully return void.
breaks the rules (a “business logic” bug)
raises an exception (a safety bug)
takes too long for a computation (a DoS bug).
Naturally, if a referee has to eliminate the last player, the game is over.