CS30 -- Introduction to Computer Science II
Fall, 2006
Project 1: MazeWar
Deliverable 3

(updated 11/8/2006)


This is the third installment of your first project.  You will enjoy these project deliverables if you stay on top of the work.  Do not wait until the last minute to work on the project deliverables.  You will suffer in many ways if you do.

In this project, you will be implementing a rational reconstruction of the historic Maze War game.  It was generally described in the specifications for your first project deliverable.

Deliverable 3:  Networking the server and client

This week, you'll need to partially dismantle the program you have written so far.  You one program will become two -- a client and a server.  The server eventually will interact with multiple rats, but for this deliverable it need only interact with one.

The client code will contain the display functionality that you have developed to this point.  It will also contain the keyboard control code.  The user will interact with the game through the client code.  From the user's perspective, nothing should change between Deliverable 2 and this deliverable.

However, the location of the rat is controlled and managed by the server.  The client sends a movement command (including turns) to the server and the server determines if the movement can take place or not, and then reports back to the client the rat's new location and orientation.

Initialization.  The server program should be started first with a given maze definition file as argument, and should begin listening for a rat's connection request.  Once the request is received, the server saves the newly created Socket and sends initial information to the rat.  This initial information consists of the maze specification, followed by a randomly selected initial position and orientation.  At this point, the server may wait for commands from the client.  Each command received from the client should generate a response from the server to the client; the response contains the rat's new location and orientation.

[For the next deliverable, the server will not be able to wait for input from the client.  It will have to be in an infinite loop interacting with each rat.  For each rat, it will check to see if there are any movement requests pending and process any that exist.  Then it will check to see if any other rats are within view of this rat and send such inforation (location and orientation) to the rat.  It will also need to check if the rat has been shot.  All of this must be repeatedly done for each rat in the maze.  FYI.]

The client program is started with the command-line argument of the server host.  The Maze War port number should be hard-coded as a static final variable in both the server and client software.  The client requests a connection with the server, receives the maze information, its location and orientation, and enters the user interaction loop.  This loop consists of reading input from the user, sending the appropriate message to the server, receiving the server's response, and displaying the new view of the maze.  Note, the client should still toggle between first-person and overhead views.

Before you begin, it is still important that you spend time thinking about your design.  For example, what types of information and in what form needs to be sent between the server and client.  You'll need to come up with a protocol that provides a consistent scheme sending this information back and forth.  Again, you should not be afraid to scrap your working code entirely if it will improve the elegance or efficiency of your final deliverable.  Also, you should be applying the techniques we learned in CS010 and those we talked about at the beginning of the semester to your design and your coding. 

Objectives
1.  Gain first-hand experience using sockets for networking
2.  Continue exercising design skills as you implement the client/server model
3.  Have fun

Submission Instructions:
On your machine where you are doing your homework, create a folder called <your email name> followed by "P1.3".  For example, someone with email address "cjones" would create a folder called "cjonesP1.3".  Inside that folder, place whatever Java files are necessary for your Programming Projects in the same folder.  Finally, either tar or zip the folder so that when extracted, the folder "<emailname>P1.3" will be created.  Finally, submit via Eureka.