On this page:
Player API
Sequences
8.14.0.4

Logical Interactions🔗

Player API🔗

    public: String name()

    

    public: Void setup(Equations e)

    // the player is handed the set of equations, which is visible to all,

    

    public: EitherPebbleOrExchanges requestPebbleortrades(TurnState s)

    // after receiving the turn state, a player requests one of:

    // - requests a pebble, or

    // - a possibly empty sequence of exchanges of pebbles

    

    public: SequenceOf<Card> requestCards(TurnState s)

    // after receiving the turn state, a player requests

    // - a possible empty sequence of card purchases

    

    public: Void 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(equations)           |                 | % the table of equations

      | -----------------------------> |                 |

      |                                |                 |

      .                                .                 .

      .                                .                 . % repeat for descending age

      .                                .                 .

      |                                |                 |

      |     setup(equations)           |                 |

      | -----------------------------------------------> |

      |                                |                 |

Playing Turns

            

    referee                         player (p_1) . . . player (p_n)

      |                                |                 |

      |                                |                 | % call only if game

      |                                |                 | % is not finished

      |   requestPebbleortrades(       |                 | % player receives:

      | -----------------------------> |                 | % - turn state            

      |             TurnState)         |                 |

      |                                |                 |

      |                                |                 |

      |     EitherPebbleOrExchanges    |                 | % requests a pebble

      | <============================  |                 | % or

      |                                |                 | % an exchange of pebbles

      |                                |                 |

      |                                |                 |

      |                                |                 |

      |--+                             |                 |

      .  |                             .                 . % if legal:

      .  |                             .                 . % referee modifies game state

      .  |                             .                 . % completes turn

      .  |                             .                 . % otherwise:

      .  |                             .                 . % kick player out

      .<-+                             .                 . % completes turn

    

      IF LEGAL:

      |                                |                 |

      |   requestCards(TurnState)      |                 | % player receives:

      | -----------------------------> |                 | % - turn state

      |                                |                 | % with a revised

      |                                |                 | % wallet of pebbles

      |                                |                 |

      |                                |                 |

      |   SequenceOf<Card>             |                 |

      | <============================= |                 | % purchases cards

      |--+                             |                 |

      .  |                             .                 . % if legal:

      .  |                             .                 . % referee modifies game state

      .  |                             .                 . % completes turn

      .  |                             .                 . % otherwise:

      .  |                             .                 . % kick player out

      .<-+                             .                 . % completes turn

      

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.

Termination of Interactions An interaction between the referee and any player is discontinued if the player
  • breaks the rules (a “business logic” bug)

  • raises an exception (a safety bug)

  • takes too long for a computation (a DoS bug).

We do not worry about a player that exploits shared-memory allocation of data representation. These terminations are not specified in the sequence diagram.

Naturally, if a referee has to eliminate the last player, the game is over.