4 — The Game State

Due Wednesday, 20 October 2021, 11:59:59pm

Delivery Place the product of this week’s milestone into your repo as follows:

Since Python’s naming system is badly designed and its convention interfere with the specified name, Pythonistas may substitute _ for - in these file names.

All previous comments on code files apply.

Programming Task Design and implement two game state data representations: one for referees and one for players. An external representation of the second one will make up the key piece of information that flows from the referee to the players every time a referee grants a player a turn. The difference is spelled out explicitly in The Game: Trains.

The data representations should come with these pieces of functionality, assuming that the per-game map is available (as an explicit or implicit parameter):
  • given a player game state, determine all connections that can still be acquired;

  • given a referee game state, and a connection, decide whether it is legal to acquire this connection for the currently active player;

  • given a referee game state, produce a player game state that represents the knowledge of the currently active player.

The phrase “piece of functionality” may not directly translate into “one function” or “one method” in your chosen language.

The player will also communicate with the tournament manager. See Trains.Com, a Plan. You do not need to address this aspect yet.

Design Task The player components must communicate with the referee, which manages and arbitrates the game. This communication involves both function/method calls and orderings of those. (Recall this is called a protocol.) Since outsiders will create AI plauers to this interface, it must be spelled out precisely and in detail. Hint To start your brainstorming—what is a software system? What are the key phases of the game?

An API is a documentation of a logical interface to a code library and its calling conventions.

Design the API for a player component. The document, named player-interface.PPmd should be a module in your language whose body is a wish list (signatures, interpretations, purpose statements).

Two pages should suffice. Less is more.

Keep in mind our Trains.Com, a Plan when you work on designs.

Visualization Task Create a visualization harness named xvisualize. The harness consumes its JSON input—a Mapfrom STDIN, pops up a window, visualizing the given map. The program must close the window after 10s. Create one Map input and place it into Vis/, the specified folder.—As always, the tests are well-formed and valid JSON.