CMSC 22001: Software Construction Assignment 7: Networking

Due: Mar 25, 2008 @ noon

Adapt the administrator so that remote sites can register players.

Adapt the players so that they can register and play with a remote Scrabble server.

Adapt the administrator to play matches between players, or even a tournament between multiple players.


In this assignment, you must adapt your server and players so they can be run over the network. This should be done by making a proxy player for use in the server and a proxy turn object for use on the client. The proxy player will behave like any other player, as far as the server is concerned, but its strategy will be to consult the network to find out what to do. The proxy turn object will look just like the ordinary turn object, from the point of view of the player, but it will communicate the move back over the network when the player invokes its methods.

In general, each method call will correspond to a pair of messages on the network, one for the method call and one for the method return.

To begin the communication, the client establishes a TCP/IP connection to the server and then sends a registerPlayer message to the server, to which the server replies with a void message (see below for the precise content of all of the messages).

After that initial sequence of messages, the communication follows this state machine:

The hexagonal, gray states indicate places where the server decides what to do next, and the round states are where the client decides. Each edge leaving a state corresponds to a single message. Edges leaving the hexagonal states are sent from the server to the client, and edges leaving the round states are send from the client to the server. The labels on the edges indicate the content of messages; note that each edge's label is on the right-hand side of the edge.

Note that these are slightly different than the contracts specified on the interfaces in assignment 5 (they are generalized to handle tournaments). Adjust the contracts in your code accordingly.

These are the precise specification of the messages on the edges in the above diagram (see the data page for the definitions of the non-terminals and whitespace conventions):
registerPlayer
 = 
(register <string>)
draw
 = 
(draw <tile> ...)
takeTurn
 = 
(take-turn <board> <number>)
placeTile
 = 
(place-tile <coord> <coord> <letter>)
placeBlank
 = 
(place-blank <coord> <coord> <letter>)
donePlace
 = 
(done-place)
exchange
 = 
(exchange-tile <tile> ...)
tiles
 = 
(tiles <tile> ...)
gameOver
 = 
(game-over <number> <wl>)
tournamentOver
 = 
(tournament-over <wl>)
void
 = 
()
Notes: The string in the register player message is the player's name. The tiles in the draw message are the initial tiles in the player's rack. In the takeTurn message, the board is the board at the beginning of the player's turn and the number is the number of tiles left in the bag. In the placeTile and placeBlank messages, the two numbers are the x and y coordinates (respectively), and the letter is the letter the player wishes to place. When exchanging, the player specifies which of their tiles to place. The gameOver message contains the player's score and if they won or lost. The tournamentOver message indicates if they won or lost.

Hints First, develop the programs that can translate method calls into text messages and text messages into method calls (test the parsing!). Second, wire in your existing code and test each half independently by simulating messages from the other half for simple interactions. Finally, wire everything together and play some games.

For now, test your new system on a local machine. Use port 9000 to communicate via TCP/IP.



CMSC 22001: Software Construction