Game Server for the ICFP 2002 Programming Contest

	http://icfpcontest.cse.ogi.edu

Author:   Iavor S. Diatchki <diatchki@cse.ogi.edu>
Language: Haskell, with extensions provided by GHC 5.04
Platform: Tested under Linux
Version:  6.1

Please report bugs to icfp-judges@cse.ogi.edu.

INSTALLATION
============

Compilation requires GHC 5.04, available from http://www.haskell.org/ghc/

Use make to compile it. Install by copying Simulator to /usr/local/bin or
whatever.

USAGE
=====

Simulator <flags>
  where flags are:
 -p NUM   --port=NUM      port to listen on (default: 20005)

  -n NUM   --new=NUM       new game every NUM players 
  -o NUM   --one=NUM       one game with NUM players
	(-n and -o are mutually exclusive, if neither one is present,
	 Simulator runs a continuous game)

  -m FILE  --map=FILE      the map to use for the game
  -k FILE  --packs=FILE    locations of packages
  -f NUM   --fuel=NUM      fuel for each player (default: 5000)
  -c NUM   --capacity=NUM  capacity for each player (default: 50)

In continuous games, the game starts immediately. Clients can join the game
at any time.

In single games and many games (-n NUM and -o NUM), the games don't
start until the right number of clients have connected.

THE GAME AND THE GAME PROTOCOL
==============================

The game and the protocol are described in doc.html, also available from

	http://icfpcontest.cse.ogi.edu/task.html

STRUCTURE OF THE SOURCE CODE
============================

Files:

Board.hs	-- interesting
Game.hs		-- interesting
Main.hs		-- definitely boring, command line parsing
Observer.hs	-- boring
Pack.hs		-- not very interesting
Pos.hs		-- boring
Robo.hs		-- interesting
Server.hs	-- maybe interesting, main loop of the simulator
Utils.hs	-- some useful bits

Programming style:

The program uses an approach based on mutable objects.

LOG FILE FORMAT
===============

The Simulator produces logs of the games. For continuous games and single games,
the log appears on stdout. For many games (-n NUM), a separate log file for
each game is written in the current directory.

Logs may contain comment lines starting with a #. Apart from the
comment lines the log files are structured as follows:

1. The log files start with the map, in the format described in doc.html
   section The game protocol, Initialization, also available from

	http://icfpcontest.cse.ogi.edu/task.html#initialization

2. Then follows one line, giving the destinations of packages. (This is intended
   to aid graphical presentations of the games.). Example:

	[(9,17),(14,3),(3,5)]

   In this scenario, packages should be delivered to three different locations.

3. For each step in the simulation, there are four lines:

     a. The current position of the robots. Example:

		[(1,(10,15)),(2,(9,3))]

        The robot with id 1 is located at (10,15) and the robot with id 2 is
	located at (9,3).

     b. The current position of packages. Example:

		[((6,17),20),((16,3),10)]

        There are 20 packages at (6,17) and 10 packages at (16,3).

     c. The commands received from the robots. Example:

		[(4,1,Drop [8,3,4,5]),(5,1,Move W)]

        The robot with id 4 sent the command "Drop 8 3 4 5" with bid 1.
	(The Pick command uses the same syntax.) Robot 5 sent the command
	"Move W" with bid 1.

	The data type for commands is Cmd, defined in Robo.hs.

     d.	"Extraordinary events". Example:

		[(2,[WasPushed]),(1,[GoodPush])]

	Robot 1 pushed robot 2.

		[(2,[]),(1,[Died "Bad reply: kjslkdjf" 0 4999])]

	Nothing extraordinary happened with robot 2, while robot 1 send an
	illegal command and was killed, having earned 0 points and having
	4999 units of money left.

	The data type for extraordinary events is Event, defined in Robo.hs

OBSERVERS
=========

Special clients called observers can connect to games to get a
real-time view of the game. When they connect to the server they
should send the line Observer. They shouldn't send anything else to the
server after that. They will receive information about the progress of
the games in the same format as the log files.

In single games and many games mode (-n NUM and -o NUM), observers count as
players, so they must connect at the beginning of the game. In continuous
games, observer can connect at any time and view the progress of the game
from that point.
