CSG 107: Problem Set 11

Due: Wednesday, April 15, 2009 at 5:00 pm.

Purpose:

The goal of this problem set is to give you experience with designing protocols for distributed programs, using the Universe.ss teachpack.

Finger Exercises:

To be supplied later.

Required Problem:

Note: You must use DrScheme's HtDP Intermediate Student Language with Lambda and the universe.ss teachpack. As always, you must follow the design recipe.

Your task is to write a server and client for a distributed TicTacToe game.

From the point of view of the client, the game looks like this:

  1. When the client starts, he sees a message like "Waiting for opponent" or "Opponent Found".
  2. He then sees a message like "You will play X" or "You will play O".
  3. When it is his turn, the player clicks his mouse in the appropriate square. If the move is accepted, the correct symbol (X or O) appears in the square. If the player attempts to move into an occupied square or when it is not his turn, the move is rejected and suitable message is displayed.
  4. When the opponent moves, the opponent's symbol appears in the appropriate square.
  5. When the game is over, a message like "Win", "Lose", or "Draw" is displayed.

The server is responsible for assigning roles (X or O), checking that moves are legal, and declaring the game over. If one of the players disconnects before the game is over, the other player should be notified.

The client program need only play a single game; if the user wants to play another game he can start up a fresh client. On the other hand, if you would like to give the client program the ability to start another game, that would be fine.

The server should stay alive after both players disconnect, so that it can run a new game for the next two clients to connect.

If a client attempts to connect when a game is in progress, the server should reject the request, and a suitable message should appear to the user.

Ideally, you should arrange for the game to be run on three computers: one for the server and one for each of the players. The Universe teachpack allegedly allows this, but you may run into trouble with firewalls, etc.

Extra Credit Problems:

  1. Extend your server so that it accomodates an unlimited number of concurrent TicTacToe games.
  2. Write an automated client that plays TicTacToe. Rather than wait for the human user to click in a square, it should look at the state of the game and calculate the next move. Super-double-extra credit if your automated client plays perfectly, but only if you got all the required parts right, too.

Last modified: Fri Apr 03 16:18:04 2009