ContentsIndex
Game
Description
The Game module provides types and functions for reading, representing, and analyzing games.
Synopsis
data Game = Game {
gamePlayerHandshakes :: [(RobotID, String)]
gameBoard :: Board
gameRobotConfigs :: [(RobotID, RobotConfiguration)]
gameInitialResponse :: [RobotCommandList]
gameTurns :: [GameTurn]
gameEpilogues :: [(RobotID, Int, [String])]
}
data GameTurn = GameTurn {
gtPackageInfo :: [(RobotID, [PackageInfo])]
gtPlayerCommands :: [(RobotID, String)]
gtServerResponse :: [RobotCommandList]
}
type TurnHistory = ([(RobotID, [PackageInfo])], [RobotCommandList])
readProxyLog :: String -> Game
mergeGames :: Game -> Game -> Game
gameHistory :: Game -> [GameTurn]
gameTurnHistory :: Game -> [TurnHistory]
gameRobotNames :: Game -> [(RobotID, String)]
Documentation
data Game
A Game represents a complete game -- its entire history, as recorded from a player robot(s)'s point of view. Values of type Game are represented in a way that conveniently allows different robots' views of the a game to be merged to allow for a more complete understanding of what happened during the game.
Constructors
Game
gamePlayerHandshakes :: [(RobotID, String)] Handshake the recording robot sent to the server to announce itself. If this is a merged Game, there wil be one handshake per robot that contributed a recording.
gameBoard :: Board Game board that the server sent
gameRobotConfigs :: [(RobotID, RobotConfiguration)] Robot configuration that server sent (one for each robot that contributed a recording)
gameInitialResponse :: [RobotCommandList] Initial reponse from server
gameTurns :: [GameTurn] All the turns of the game
gameEpilogues :: [(RobotID, Int, [String])] Any final information provided by the server after a robot died or the game ended (one entry per robot that contributed a recording). The RobotID identifies the robot that received the epilogue messages. The Int gives the turn on which the robot died or otherwise finished the game. The messages themselves are given in the [String] field.
data GameTurn
Represents a turn of game play.
Constructors
GameTurn
gtPackageInfo :: [(RobotID, [PackageInfo])] Server's list of packages seen by robot player(s) this turn
gtPlayerCommands :: [(RobotID, String)] Commands sent by robot(s) to server
gtServerResponse :: [RobotCommandList] Response from server
type TurnHistory = ([(RobotID, [PackageInfo])], [RobotCommandList])
This type represents everything that is independent of a robot's perspective that the server told us happened during a particular turn. It is essentially a GameTurn without the commands that the robots requested of the server.
readProxyLog :: String -> Game
Reads a game log recorded by RobotProxy and converts it into a Game.
mergeGames :: Game -> Game -> Game
Merges two Game values into a composite Game. Useful for combining Game values that were recorded from the perspectives of competing robots into a single multi-perspective Game.
gameHistory :: Game -> [GameTurn]
Gets all of the turns for the game. We create an artificial Turn 0 based on the initial server response to make analysis easier.
gameTurnHistory :: Game -> [TurnHistory]
Gets all the server information updates, which together represent a history of what happended during the game.
gameRobotNames :: Game -> [(RobotID, String)]
Creates a lookup list from RobotIDs to robot names by reading annotations that have been added to the gamePlayerHandshakes. An annotation takes the form of a slash followed by the robot's name. For example the robot configuration (1, Player) could be annotated as (1, Player/My big bad bot) Note that there is no guarantee that a name annotation exists. Therefore callers should be prepared to empty names.
Produced by Haddock version 0.4