Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
Game Server for the ICFP 2002 Programming Contest http://icfpcontest.cse.ogi.edu Author: Iavor S. Diatchki Language: Haskell, with extensions provided by GHC 5.04 Platform: Tested under Linux Version: 6.3 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 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 -r NUM:(NUM,NUM):CMD --robo=NUM:(NUM,NUM):CMD a player to be started by the Simulator, with uid:initial_pos:command. This flag can be repeated. (-n, -o and -r 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) -v --verbose produce an extra verbose log of the game(s) -q --quiet be extra quiet (-q and -v are mutually exclusive) -i (NUM,NUM) --init=(NUM,NUM) set the default initial position default: (1,1) -j [(NUM,NUM)] --inits=[(NUM,NUM)] set the first initial positions -t NUM --timeout=NUM set timeout in millisecs default: no timeout 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 Event.hs -- interesting Game.hs -- interesting Main.hs -- definitely boring, command line parsing Observer.hs -- boring Opts.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 depend on the verbosity flag given to the server. There are three verbosity levels: 1. quiet (-q) no logging info 2. usual mode (no special flag) this should contain enough information to reproduce all interesting stuff 3. verbose (-v) produce even more info, for tools which do not want to keep their own state. The log file have the following structure: 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 Note that maps may contains lines starting with a #. These *are* part of the map and should not be treated as comment lines. 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. Some information is send for each turn: 3.1. With -v there are 4 lines/turn as described in a,b,c,d bellow. 3.2. Without -v there are 2 lines/turn, as described in c,d bellow. 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. Events (what happened to the robots). Example: [(2,[WasPushed]),(1,[GoodPush])] Robot 1 pushed robot 2. [(2,[Moved E]),(1,[Died "Bad reply: kjslkdjf" 0 4999])] Robot 2 moved east, 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 events is Event, defined in Event.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.