8.15.0.6

10 — Revised!🔗

Due Thursday, 28 November 2024, 11:59:59pm with an automatic extension until Monday, 02 December, 11:59:59pm

Purpose This milestone has three learning goals:

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

Programming Task Modify your server-side software so that certain players are rewarded with bonus points while the winners are determined, not during the game.

The referee awards every player some bonus points for having bought cards that jointly display the following colors:

Whether the player owns a single card that happens to display these colors or several does not matter.

Hint This change concerns the logic not the communication layer, so it is critical to start the work at this presumably well-tested layer. So, get the logical change correct first. Adjust any unit tests for which you know up front that the results change. Then re-run the integration tests, once the server-side components can award the bonus points. Adjust and use your observer to double check that the awards are handed out correctly. After that, tackle the “runnables” task.

Runnables Task for the Last and Final Integration Test Construct two executable programs:
  • xserver, which starts your server, and

  • xclients, which launches a number of clients and points them to a running server.

Both programs are launched with one command-line argument, the localhost port on which to connect to the counterpart.

Both programs consume JSON information from STDIN:

    $ ./xserver PortNumber < ForServer/n-in.json &

    $ ./xclients PortNumber < ForClient/n-in.json  &

(for some natural number n).

Turn the input files for the full-game tests for 9 — Remote (and below) by hand or script into pairs of input files. Put them into the two distinct folders—ForServer (inputs for xserver) and ForClients (inputs for xclients)—to cleanly separate concerns.

The xserver consumes two JSON values, followed by an optional one:
  • the (maximally useful) *Equations; and

  • a Game state.

    Note this revised definition of Player as of this milestone.

        A Player is an object with 3 fields:

         { "cards"  : *Cards,

           "wallet" : *Pebbles,

           "score"  : Natural }

        

         INTERPRETATION A Player instance specifies the pebbles that

          the player owns, the cards it has acquired so far, and its score.

        

  • an optional Bonus specification. If it is missing, no player gets a bonus. Otherwise it is one of the two specified variants.

    A Bonus is one of:

      -- "RWB" (short for United States of America )

         INTERPRETfATION a player whose collective cards display red, white, and

         blue pebbles receive 10 points when the referee determines winners

    

      -- "SEY" (short for Seychelles )

         INTERPRETfATION a player whose collective cards display green, yellow,

         red, white, and blue pebbles receive 5 x 10 points

         when the referee determines winners

It spawns the server program, which turns these two values into internal data representations. Then the server waits for the players to sign up. Once the server has registered players according to the policy specified in 7 — The Clean Up, it hands them in descendant descending-age order to the referee’s testing method, together with the given equations and game state to the referee’s testing method. The latter runs a game and hands the result of running the game back to the server, which renders it as a JSON value to STDOUT: an array containing the array of winners followed by the array of drop-outs.

The timeout per call to a player is set 4.0s. The time out for an entire test suite is set 200s.

The xclients program consumes just one JSON value:

It turns these actor specifications into independently running processes clients. The actors are specified in the exact order in which the referee’s knowledge about them resides in the game state.

If these processes clients are launched without precaution, the test is going to run in a non-deterministic fashion and will yield non-deterministic – and therefore unpredictable and irreproducible – results. To reduce the likelihood of a non-deterministic outcome, the xclients script should ensure that each client completes the sign-up step before it launches the next one wait for a couple of seconds between launching clients.

Well-formed and Valid You may assume that all configuration 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.
Keep in mind though that the JSON sent from clients to servers should not be trusted and for that matter clients may not wish to trust servers either.

The test bed ensures that the server program runs independently of the clients programs. The idea is to spawn the server and the clients as parallel programs to mimic a distributed setting as much as possible using a single machine.

The test bed compares this actual output to the expected output of the test case; it ignores the output of xclients.