3 — The State
Due Tuesday, 01 October 2024, 11:59:59pm
Purpose This milestone has multiple learning goals:
T to deal with the data-representation aspect of state machines;
T to script an integration test environment (which eventually also supports the communication among components); and
S to reflect on a partnership (self, partner) in an honest manner.
State machines are ubiquitous in software systems. A state-machine component is in some state and, triggered by certain stimuli, transitions from state to state. Many board games are essentially state machines: the game is in a certain state and, when a player is granted a turn, the state changes. Software designers have developed an approach to state machines that helps with testing by cleanly separating concerns: (1) the data representation of states from (2) the transition machinery. This milestone focuses on (1).
Partnership Evals For this milestone, we request an evaluation of your partnership.
Delivery Place the product of this week’s milestone into your git repo as follows:
for the Programming Task, place game-state.PP and turn-state.PP into Bazaar/Referee/game-state.PP and Bazaar/Common/turn-state.PP, respectively;
Some languages demand a specific organization within the file system. In that case, you may place a link to game-state.PP and turn-state.PP into Bazaar/Referee/game-state.PP and Bazaar/Common/turn-state.PP, respectively.
for the Design Task, place player-interface.md into Planning/
for the Testing task, place xeq and [0-2]-{in,out}.json into a top-level repo directory named 3 and [0-2]-{in,out}.json into a Tests/ subdirectory of 3.
If your testing task requires a Makefile place it in 3, too.
Programming Task Design & implement a data representation for the information about the game’s state that the referee must keep to decide whether a player’s requests are legal according to the rules of the game.
This game state comprises the following pieces of varying information: the bank; the cards; all players’ wallets, scores, and reachability; The referee cannot know the entire state of a player. For example, a referee should not know which strategy a player uses to make decisions. and the order in which the players take turns. Consider the chosen set of equations a global constant, because it is chosen once and for the entire duration of the game during the setup phase.
The player whose turn it is next is called the active player.
Assuming that players know nothing about the state of the game—
determining whether a game is over;
extracting the turn state from the referee’s game state representation;
graphical rendering the referee’s game state; and
graphical rendering the turn state data transmitted from the referee to the player.
Design Task In contrast to human players, AI players are not in charge; the referee of the game framework is and it plays the role of arbiter, which is often left to the collective of all players (or a subset of knowledgeable ones).
Here the referee engages the players, informing them of the game’s progress as
needed, and managing turns. When granted a turn, a player responds with a
description of the desired action, but it is the referee that executes them on
behalf of the player on the ground-truth state of affairs—
Design a player interface in the form of a method/function wish list. For each piece of functionality, describe what knowledge it must be able to retrieve from context (if any). Choose the wish list format that you got to know in Fundamentals I and Fundamentals II, depending on which of the languages used in these courses matches your chosen language most closely.
Note, each player component consists of two pieces: the mechanics for executing game actions and a strategy (or several strategies) for pursuing a goal. This task is concerned with mechanics only.
The memo should not exceed a page.
Keep in mind our Bazaar.Com, a Plan while you work on a design task.
Testing Task Create a test harness named xeq. The harness consumes its JSON inputs from STDIN and sends its results to STDOUT. Create three tests and place them in the specified [0-2]-{in,out}.json folder.
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).—
*Equations, which are distinct (as equations);
the active player’s Wallet; and
the current Bank.
Here are the relevant JSON specifications:
*Equations is an array of the shape [Equation, ..., Equation] |
INTERPRETATION The array represents an unordered collection of equations, |
that is, it represents a set. |
CONSTRAINT The set contains no more than 10 elements. |
|
INTERPRETATION The array represents an unordered collection of exchange rules, |
which are like equations but apply only in the left-to-right direction. |
|
The ``unordered collection'' applies only to this milestone, to avoid questions concerning how the JSON should be sent to STDOUT. For the remaining milestones, the order in the array matters. |
Equation is an array of the shape [*Pebbles, *Pebbles]. INTERPRETATION The two arrays of Pebbles represent the two sides of an equation. The order in these arrays does not matter. CONSTRAINT the two *Pebbles in an Equation contain between 1 and 4 items CONSTRAINT the two *Pebbles in an Equation are disjoint
Wallet is a *Pebbles. INTERPRETATION It represents the Pebbles that the player owns.
Bank is a *Pebbles. INTERPRETATION It represents the Pebbles that the bank owns.
*Pebbles is an array of the shape [Pebble, ..., Pebble]. INTERPRETATION Any two *Pebbles are considered equal if they contain the same Pebbles, that is, it represents a set.
Pebble is one of: "red", "white", "blue", "green", "yellow"
} Hint This JSON data exchange representation is not intended to be identical to your data representation (and it is certainly not the one used for the oracle implementation).
Well-formed and Valid You may assume that all inputs to your test harnesses from STDIN are well-formed and valid. A well-formed piece of JSON satisfies the grammar; such a piece is valid if it also satisfies all the side constraints of a schema specification.
Beyond integeration testing, we should eventually move to stress testing. The course will touch on this idea in November or December.
Pedagogy Besides unit tests, multi-component projects also need integration tests. Such tests compose several components and run tests on the composite that exercise functions across the components. This task is a lightweight illustration of this idea.
When a milestone assignment requests an integration test harnesses, you should not
have to modify the core functionality from the previous milestone—
That is, building harnesses for integration tests doesn’t slow you down—
Partner Evaluation
Did you contribute to this partnership in a responsible manner?
Did your partner contribute to this partnership in a responsible manner?
Do you want to continue this partnership?
Subject: Sw Dev partnership evaluation |
|
My name: Foo Bar |
My partner's name: Fumble Mumble |
Our TAHPL: Python 4.312 |
|
LINK TO LAB BOOK REPO |
|
Our partnership is ... |
|
Only the head TA and, if necessary, the instructors will read your responses; nobody else will. At their digression, the instructors may interview partners.
The partnership evaluation is worth 20 points.