Program 8
The last program will be a project due in three installments. The project
will be to build a commodity trading game as described
here..
You need to complete the basic commodity trading game that will allow
the players to bid and sell, ignoring the 30-day loan option,
and implement an end-of-game by timeout. For the sake of argument, assume
that all games last exactly 5 minutes, but you are free to choose what you
want to use.
However, you are also free to do more with the game.
Structure
The server would be responsible for signing up players - getting a name,
establishing the starting conditions and setting up communications.
The server handles the accounts of the players
(what they have in commodities and cash) the transmission of
messages between different sub-servers and anything else that
seems to require global oversight.
The client would mostly just process information, display it on the
screen, and get commands from the user to pass to the sub-server.
Extras
Scheduling
The project is going to be submitted in stages.
- November 18 - The client and server should be able to connect
and exchange basic info. The server should be able to initialize
a client and exchange information between the server, the sub-servers
and the clients. For now, the clients can be fairly dumb, possibly
sending only a few hard-coded bid or sell transactions.
- December 2 - You should be able to play a rudimentary game with
the client actively involved.
- December 4 - Final project due. Extra points awarded for
adding nifty features up to 20% of the project weight.
If you choose not to finish the project, you will be graded on the basis
of what you turned in for earlier milestones.
Architecture
The server should use TCP (stream sockets) to communicate with the
clients. Each new client must create a child to handle the
communication with that client. The child processes and the parent
server can communicate with any reasonable means, but pipes are probably
the easiest.
The client has to use UDP to broadcast to find a server, but all other
communications will be done with TCP. If you had multiple servers, you
could do fancy things, like multiple markets simultaneously, or you could
choose the game based on some parameter like difficulty or who the other
players are. Multiple servers is not a requirement.
The server and the child servers will have to deal with multiple I/O streams
operating asynchronously - i.e. not scheduled. Use the select function
to manage the sockets and pipes. Instead of using pipes, you can use
sockets for the server-to-sub-server communication, but you should use
Unix sockets rather than internet sockets.
Turn in your source code and the output from the client side showing that
it can initialize and interact minimally with the server side.