See the assignment turn-in page (last modified on 25 February 2003) for instructions on turning in your assignment.
You are not required to make any of the moves 1 through 4 as soon as they are possible.
Play ends when all the cards have been dealt. You win if there's a single pile of cards left.
At the end of the game, the client sends its final card configuration to the server. The server checks the client's configuration for mistakes, and then compares the client's configuration to its own for the game. If the client's configuration is correct and contains no more piles than does the server's configuration, then the client has won, even if the client doesn't have a single pile at the end of the game. Otherwise the client has lost.
/export/home/class/cs-537/p1/accordion.h
.
The structure of the rest of the message depends on the message tag.
where
play
- The play message tag.
A deal message has the format
where
deal
- The deal message tag.
where
ping
- The ping message tag.
where
tableau
- The tableau message tag.
where
result
- The result message tag.
gid
- The game id.
where
error
- The error message tag.
|
|
For example, the jack of hearts has the value 2*100 + 11 = 211.
All values are unsigned and in network-byte order unless otherwise noted..
gives a general idea of the way in which clients and servers interact. More specifically, the interaction between client and server can be broken up into three phases: set-up, play, and shut-down.
Upon receiving a play message from the connecting client, the server responds with a play message containing the client's game id.
The longest allowable interval between two successive message from the same client is around one minute; if the server does not receive the next message from a client within one minute of receiving the previous message, the server assumes the client is gone and ends the game with an error message.
Similarly, if the client fails to receive the server's response to a message within one minute, the client should consider the server gone and end the game with an error message.
A playing client can keep its game alive without using a deal message by sending a ping message to the server. The server responds by sending a ping message back, and the client has approximately one more minute to send another message. A client can send at most 10 consecutive ping messages during its turn. If the client fails to send a non-ping message after 10 consecutive ping messages, the server ends the game with an error message.
The receiver of an error message should assume the connection over which the message arrived has been closed (this means the receiver should not try to send an error message back when it receives a faulty error message). The receiver should print the error string (if any) to std-err and close the connection. What happens next depends on the receiver; a client should probably halt, a server should clean-up the connection and continue.
Error messages can be sent at any time, even at times when no error has been detected by the sender. The receiver's response to an error message, however, should always be as described in the previous paragraph.
Erroneous behavior includes receiving undefined messages, receiving incorrectly formatted messages, receiving messages with bad values, receiving messages out of expected order, failure to interact within a reasonable amount of time, and unexpected connection terminations.
-h
and -p
command-line options to specify the
server's host IP address and listening-port number, respectively. The server
should support the -p
command-line option to pick specific listening-port
number.
Your client should play the game itself; it should not prompt the user for moves. And remember, you're supposed to be learning about clients and servers, not about Accordion; just have the client make random moves. After you get everything working, you can go back and soup up your game-playing algorithm.
This page last modified on 12 March 2003.