CSPP 51090 & CMSC 22001: Software Construction Assignment 8

Due: May 25, 2004

Adapt the administrator so that remote sites can register players. [4pts]

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

Adapt the administrator to play matches between players, or even a tournament between multiple players [2pts].

For this assignment, I have revised the sequence contracts for the player to support tournaments and matches. A single player must now be able to play multiple games. Here are the new sequence contracts (the only changes are an extra * around the player's contract and the removal of the getName calls):

Administrator:  registerPlayer* . playGame
Player:  (draw . (takeTurn | inform)*)*
Turn:  exchangeTiles | ((placeTile | placeBlank)+ . donePlace)

For now, test your new system on a local machine. Use port 9000 to communicate via TCP sockets. The specification for the interactions protocol for remote servers and players consists of two parts:

  1. The message sequences (each has a request and a response):
    exchangeTiles
     = 
    (exchange-tile <tile> ...)
    (<tile> ...)
    placeTile
     = 
    (place-tile <coord> <coord> <letter>)
    ()
    placeBlank
     = 
    (place-blank <coord> <coord> <letter>)
    ()
    donePlace
     = 
    (done-place)
    (<tile> ...)
    draw
     = 
    (draw <tile> ...)
    ()
    takeTurn
     = 
    (take-turn <board> <number>)
    ()
    inform
     = 
    (inform <string>)
    ()
    registerPlayer
     = 
    (register <string>)
    ()
  2. The format for various data to be communicated:
    <board>
     = 
    ((<cell> ...15) ...15)
    <cell>
     = 
    (<letter> bl)
    (<letter> nb)
    -
    <boolean>
     = 
    true
    false
    <string>
     = 
    a sequence of keyboard characters, with the exception of ", surrounded by "s
    <coord>
     = 
    0
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    <number>
     = 
    a sequence of digits (0-9)
    <tile>
     = 
    <letter>
    _
    <letter>
     = 
    a
    b
    c
    d
    e
    f
    g
    h
    i
    j
    k
    l
    m
    n
    o
    p
    q
    r
    s
    t
    u
    v
    w
    x
    y
    z
Things in the purple fixed width font are literal characters that pass across the network, things in green italics with <> around them refer to other parts of the specification, and things in orange are meta-notation describing parts of the communication. Ellipses stand for repeated elements and ellipses with numbers mean to repeat that number of times (exactly).

Multiple lines in the second table correspond to different alternatives. For example, a <tile> can be either a <letter> or the underscore character. A cell with a bl corresponds to a blank, a cell with a nb corresponds to a non-blank, and a cell with a hyphen corresponds to an unplayed square. The string passed during registration should be the players name.

Whitespace The parenthesis characters and strings are considered self-delimiting, meaning they do not require surrounding whitespace to separate them from other elements in a message. All other items in a message must be separated by at least one space (or tab or newline) from the surrounding text. For example, this: (draw abcdef_) is illegal, since there are no spaces around the tiles in the argument to draw. On the other hand, both (     draw  a  b  c  d  e  f  _     ) and (draw a b c d e f _) are legal.

The message sequences are subject to the same contracts as the administrator, player, and turn interfaces (as above). Your clients and server must adhere to this protocol so that they can interact with the respective components from other teams.

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.



CSPP 51090 & CMSC 22001: Software Construction