On this page:
Player API
Sequences
8.3.0.10

Logical Interactions 2

Matthias Felleisen

Player API

    

    start: Boolean -> Map

    // is this player participating in the tournament that is about to start up

    

    end : Boolean -> Void

    // did this player win the tournament?

Sequences

The interaction between players and the manager is governed by the following interaction diagrams.

Starting a Tournament

    

    manager <---------------------- player (p_1) . . . player (p_n)

      |                                |                 | % for n <= MAX_PLAYERS

      |                                |                 |

      |                                |                 |

      |                                |                 |  

      |     start(Boolean)             |                 | % true means the tournament

      | -----------------------------> |                 | % is about to start

      |     Map                        |                 |

      | <============================  |                 | % player submits a map

      .                                .                 . % in response

      .                                .                 .

      .                                .                 .

      |     start(Boolean)             |                 |

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

      |                                |                 |

      |     Map                        |                 |

      | <=============================================== |

Running a Tournament

    

    manager                         player (p_1) . . . player (p_n)

      |                                |                 |

      |  new(map, players[])           |                 |

      | -----------------> referee     |                 |  

      |                      |         |                 |

      .                      .         .                 .

      .                      .         .                 . % play a game

      .                      .         .                 . % (see below)

      .                      .         .                 .

      .                      .         .                 .

      |                      |         |                 | % the ranking

      | ranking, players[]   |         |                 | % & cheaters

      | <=================== |         |                 |

      .                     ___        .                 .

      .                                .                 .

      .                                .                 . % as long as

      .                                .                 . % one game can

      .                                .                 . % be played

      .                                .                 .

      |                                |                 |

      |  new(players[])                |                 |

      | -----------------> referee     |                 |  

      |                      |         |                 |

      .                      .         .                 .

      .                      .         .                 . % play last game

      .                      .         .                 .

      .                      .         .                 .

      |                      |         |                 |

      |                      |         |                 | % the ranking

      | ranking, players[]   |         |                 | % the "cheaters"

      | <=================== |         |                 |

      .                     ___        .                 .

      |                                |                 |

      |                                |                 |

Terminating a Tournament

    

    manager                        player (p_1) . . . player (p_n)

      |                                |                 |

      |                                |                 |

      |     end(Boolean)               |                 |

      | -----------------------------> |                 | % true means "winner"

      |                                |                 | % false means "loser"

      .                                .                 .

      .                                .                 .

      .                                .                 .

      .                                .                 .

      |     end(Boolean)               |                 |

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

      |                                |                 |

      |                                |                 |

Convention The % parts on the right are interpretive comments. ~~ A missing return arrow means that method must successfully return void.

Termination of Interactions An interaction between the manager and any player is discontinued if the player
  • 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.