8 — The Observer
Due Thursday, 09 November 2023, 11:59:59pm
Delivery Place the product of this week’s milestone into your git repo as follows:
for the Programming Task, place observer.PP into Q/Referee/;
for the Design Task, place remote.md into Planning/
for the Testing task, place xgames-with-observer and Tests/ into a top-level repo directory named 8
Programming Task Implement an observer component with which dev ops can watch and inspect a game from a referee’s perspective.
it saves the states it receives as PNG files in a directory called Tmp/, using the names "0.png", "1.png", and so on.
The Tmp/ directory should be created at the place where the program is run, in this case, the test script (xgames-with-observer).
- it displays the states it receives as images in a graphical user interface (GUI). This GUI must support at least three interaction capabilities:
A next functionality shows the next state of the game, if it is available.
A previous functionality shows the previous state of the game, if it is available.
A save functionality saves the current state as an instance of JState in a file of the user’s choice.
Protocol The observer must support at least two pieces of functionality:
(1) a receive-a-state functionality, which consumes a state; and (2) a game-over
functionality, which alerts the observer that no more states will become
available. The referee will use the first method to inform the observer of a
change in state before a turn is completed and at the very end of the game
(why?). The second piece of functionality is used as the referee shuts
down.—
Design Task The time has come to prepare for turning your monolithic software system into a distributed one. Imagine your referee managing a game with all the players from your peers in class or your player participating in a game that one of your peers organizes.
Read up on the remote-proxy design pattern.
Then design a protocol for gathering players, launch a game, and reporting the result. Use Logical Interactions as a starting point. Your document should combine English, schematic JSON data definitions (if needed), and sequence diagrams (if needed) to specify a remote-proxy protocol that you and your peers can implement.
Keep in mind our Q.Com, a Plan while you work on a design task.
Testing Task Create a test harness named xgames-with-observer. The harness consumes its JSON input from STDIN and produces its results to STDOUT. Create ten tests ([0-9]-{in,out}.json) and place them in the specified Tests/ folder.
The inputs of xgames-with-observer consist of a JState followed by an array of
JActorSpecA. Functionally, xgames-with-observer performs the same computation and
produces the same kind of output as the test harness of 7 —
If the harness is run with the command-line flag "–show", the game observer is attached to the referee; otherwise the referee runs in the usual black-box mode.
$ xvfb-run ./xgame-with-observer ...
Your referee should inform all winners first before informing losers. Both inform-steps must proceed in turn order.
A test case always consists of given inputs and expected outputs. For this
course, a test consists of a pair of files: n-in.json, the input file, and
n-out.json, the expected output file, where n is an integer between 0
and the requested number of tests (exclusive).—
- "non-adjacent-coordinate" |
INTERPRETATION Denotes a player that in response to being granted a turn, |
requests the placement of a tile that is not adjacent to a placed tile. |
- "tile-not-owned" |
INTERPRETATION Denotes a player that in response to being granted a turn, |
requests the placement of a tile that it does not own. |
- "not-a-line" |
INTERPRETATION Denotes a player that in response to being granted a turn, |
requests placements that are not in one line (row, column). |
- "bad-ask-for-tiles" |
INTERPRETATION Denotes a player that in response to being granted a turn, |
requests a tile replacement but it owns more tiles than the referee has left. |
- "no-fit" |
INTERPRETATION Denotes a player that in response to being granted a turn, |
requests the placement of a tile that does not match its adjacent tiles. |