Logical Interactions
Player API
public: String name() |
|
public: Any setup(Map mState s, Set<Tile>Bag<Tile> st) |
// the player is handed the inital map, which is visible to all, |
// plus an initial set of tiles; |
// The method is also called when the referee resumes a |
// game from a game state so that players are guaranteed |
// to know their assets. |
|
|
public: PASS or REPLACE or EXTENSION takeTurn(PublicState s) |
// after receiving the public part of state, a player |
// - passes, |
// - asks the referee to replace its set of tiles, or |
// - requests the extension of the map in the given state with |
// some tile placements |
|
public Any newTiles(Set<Tile>Bag<Tile> st) |
// the player is handed a new set of tiles |
|
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) |
| | | |
| | | |
| | | |
| setup(state,bagOfTiles) | | % the initial map for this game |
| -----------------------------> | | % a set of tiles for this player |
| | | |
. . . |
. . . % repeat for descending age |
. . . |
| | | |
| setup(state,bagOfTiles) | | |
| -----------------------------------------------> | |
| | | |
Playing Turns
|
referee player (p_1) . . . player (p_n) |
| | | |
| take-turn(PublicState) | | % player receives: |
| -----------------------------> | | % - current visible state |
|
ACTION 1: |
| PASS | | |
| <============================ | | % pass on this turn |
| | | |
|
|
ACTION 2: |
| REPLACE | | |
| <============================ | | % replace request |
| | | |
|--+ | | |
. | . . % if legal: |
. | . . % completes turn |
. | . . % otherwise: |
.<-+ . . % kick player out |
|
|
ACTION 3: |
| EXTENSION | | % an extension consists of a |
| <============================ | | - non-empty sequence of |
| | | - tile-coordinate pairs |
|--+ | | |
. | . . % if legal: |
. | . . % referee modifies game state |
. | . . % completes turn |
. | . . % otherwise: |
. | . . % kick player out |
.<-+ . . |
|
|
IF: the player asks for REPLACE or EXTENSIONS, the referee completes the turn: |
|
| | | |
| new-tiles(bagOfTiles) | | % the player is handed |
| -----------------------------> | | % a new set of tiles |
|
|
REPEAT: |
| take-turn(PublicState) | | |
| -----------------------------------------------> | |
| response | | |
| <=============================================== | |
| | | |
. . . |
. . . % repeat until the referee |
. . . % determines that the game is over |
. . . |
Ending 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.