CS 677 Operating Systems

Fall 2003

Programming Assignment 1: Renaldo: A simple Multi-player Game

Due: Lecture 10

(for off-campus students - 15 days after viewing Lecture 6)



1 The problem

This project has two purposes: first to get you familiarize with sockets/RPCs/RMIs, processes, threads; second to learn the design of multi-player games.

You can be creative with this project. You are free to use any programming languages (C, C++, Java, etc) and any abstractions such as sockets, RPCs, RMIs, threads, events, etc. that might be needed.

In this project, you need to design a simple multi-player game based on a centralized architecture (in a later assignment, we will make this game fully distributed).

Introduction

In this assignment you will implement a multi-threaded multiplayer game server. Renaldo is a new graduate student in the Computer Science department. Key to Renaldo's survival is obtaining adequate nourishment throughout the course of his tenure at UMass Computer Science. Fortunately for Renaldo, after various talks and functions throughout the department, leftovers are often put out for general consumption.

Example World

Renaldo's world is a 100x100 grid representing a floor plan of the Computer Science department. This grid (see figure) has walls (the shaded blocks in the figure) and a doorway (the darkened block in the figure). New players may enter the game at any time. A new player enters the game through the doorway. If multiple players attempt to enter the game at the same time, these players must wait in line to enter Renaldo's world. Each player is identified in the game by the letter "R" concatenated with a number. For example "R1" is the identifier for the first player to enter the game. Subsequent players are identified by R2, R3, etc. Renaldo maintains a counter representing his energy level. Renaldo may execute an action to move up, down, left or right. Each time Renaldo moves, his energy level is decremented by 1. If Renaldo bumps into a wall, his energy level is decremented by 1 and he makes no forward progress.

As Renaldo navigates through his world, a number of leftovers will randomly appear in unique random locations in the grid. You are to have 3 each of the following food items at all times during the game:

When Renaldo moves to a location containing V, B, P, N, his energy level is increased by 25, 20, 15, and 10 respectively. When Renaldo moves to a location containing a C, he gets an energy boost for 10 moves. When under an energy boost, for each single move, Renaldo moves two positions in any direction, but only has his energy level decremented by 1. Renaldo's energy level is initially 25. If his energy level goes to 0, then "bummer dude" the game ends and the player exits the game. To consume a food item, Renaldo must move onto a location containing the food item.

You are to have 2 each of the following items at all times during the game...

  1. Journal article denoted by J
  2. Tech report denoted by T
  3. Confrence paper denoted by F
When Renaldo moves to a location containing a J, F, or T, he gets 10, 5, or 3 points respectively. Living in this world is Renaldo's advisor. Renaldo's advisor, denoted by A, starts in a randomly selected initial location and moves randomly around the floorplan. A player bumps into another player when an attempt is made to move into a location containing the other player. Being a world class researcher, Renaldo's advisor wants to get optimum performance out of his new student. Whenever Renaldo bumps into his advisor, his energy level is cut in half (rounded down if it is an odd number) but he gets 1 point.

Your tasks

You are to design a game server for Renaldo's world and a client. You are to design a floor plan which includes a doorway. You are to choose an appropriate communication/rpc mechanism for the problem. The command line for the client must include a way to specify the name of the player. An example command line is "renaldoClient -name smith". The server should identify the player along with the host on which the client was run. An example message is "R1: smith joined from machine.cs.umass.edu." You are to design appropriate synchronization methods for handling multiple players waiting at the door as well as updates to game state. In addition, your implementation must include a protocol for communicating relevant statistics such as total accumulated point value, energy level, executed action, position in grid, and the outcome of an action back to the client display. The outcome of an action includes things like bumping into a wall, bumping into the advisor, consuming a food item, and energy level going to 0.

2 Evaluation and Measurement

Deploy a game server with multiple players. They can be setup on the same machine or different machines.

Do a simple experiment study to study the scalability of your game. Measure the response time of user moves with varying number of players. Does the response time degrade with a larger number of players? (since it may not be feasible to have actual players play the game for these measurements, you can write a client that emulates an actual player by making random moves, and measure the resulting response times). If needed, plot a graph showing measured response times to support your conclusions.

3 What you will submit

When you have finished implementing the complete assignment as described above, you will submit your solution in the form of printouts.

Each program must work correctly and be documented. You should hand in:
  1. A seperate (typed) document of approximately two pages describing the overall program design, a description of "how it works", and design tradeoffs considered and made. Also describe possible improvements and extensions to your program (and sketch how they might be made). The writeup should include discussion of communication/RPC mechanism, protocol(s), synchronization/locking, concurrency.
  2. A program listing, neatly formatted, containing in-line documentation.
  3. A seperate description of the tests you ran on your program to convince yourself that it is indeed correct. Also describe any cases for which your program is known not to work correctly.
  4. Performance results.

Let us not waste a lot of trees. So, if any of the above turn out to be large, just save the relevant information in a file, leave it on your EDLAB account and submit the name of the file.

4 Grading policy for all programming assignments

Grading:

Grades for late programs will be lowered 12 points per day late.