goatee-0.1.0: A monadic take on a 2,500-year-old board game - library.

Safe HaskellNone

Game.Goatee.Sgf.Board

Description

Data structures that wrap and provide a higher-level interface to the SGF game tree, including a zipper that navigates the tree and provides the current board state.

Synopsis

Documentation

data RootInfo Source

Properties that are specified in the root nodes of game trees.

Instances

Eq RootInfo 
Show RootInfo 

data GameInfo Source

Properties that are specified in game info nodes.

Constructors

GameInfo 

Fields

gameInfoRootInfo :: RootInfo
 
gameInfoBlackName :: Maybe String
 
gameInfoBlackTeamName :: Maybe String
 
gameInfoBlackRank :: Maybe String
 
gameInfoWhiteName :: Maybe String
 
gameInfoWhiteTeamName :: Maybe String
 
gameInfoWhiteRank :: Maybe String
 
gameInfoRuleset :: Maybe Ruleset
 
gameInfoBasicTimeSeconds :: Maybe Rational
 
gameInfoOvertime :: Maybe String
 
gameInfoResult :: Maybe GameResult
 
gameInfoGameName :: Maybe String
 
gameInfoGameComment :: Maybe String
 
gameInfoOpeningComment :: Maybe String
 
gameInfoEvent :: Maybe String
 
gameInfoRound :: Maybe String
 
gameInfoPlace :: Maybe String
 
gameInfoDatesPlayed :: Maybe String
 
gameInfoSource :: Maybe String
 
gameInfoCopyright :: Maybe String
 
gameInfoAnnotatorName :: Maybe String
 
gameInfoEntererName :: Maybe String
 

Instances

Show GameInfo 

emptyGameInfo :: RootInfo -> GameInfoSource

Builds a GameInfo with the given RootInfo and no extra data.

internalIsGameInfoNode :: Node -> BoolSource

Returns whether a node contains any game info properties.

gameInfoToProperties :: GameInfo -> [Property]Source

Converts a GameInfo into a list of Propertys that can be used to reconstruct the GameInfo.

data BoardState Source

An object that corresponds to a node in some game tree, and represents the state of the game at that node, including board position, player turn and captures, and also board annotations.

Constructors

BoardState 

Fields

boardCoordStates :: [[CoordState]]

The state of individual points on the board. Stored in row-major order. Point (x, y) can be accessed via !! y !! x (but prefer boardCoordState).

boardHasInvisible :: Bool

Whether any of the board's CoordStates are invisible. This is an optimization to make it more efficient to set the board to all visible.

boardHasDimmed :: Bool

Whether any of the board's CoordStates are dimmed. This is an optimization to make it more efficient to clear all dimming from the board.

boardArrows :: ArrowList
 
boardLines :: LineList
 
boardLabels :: LabelList
 
boardMoveNumber :: Integer
 
boardPlayerTurn :: Color
 
boardBlackCaptures :: Int
 
boardWhiteCaptures :: Int
 
boardGameInfo :: GameInfo
 

Instances

Show BoardState 

boardWidth :: BoardState -> IntSource

Returns the width of the board, in stones.

boardHeight :: BoardState -> IntSource

Returns the height of the board, in stones.

data CoordState Source

Used by BoardState to represent the state of a single point on the board. Records whether a stone is present, as well as annotations and visibility properties.

Constructors

CoordState 

Fields

coordStar :: Bool

Whether this point is a star point.

coordStone :: Maybe Color
 
coordMark :: Maybe Mark
 
coordVisible :: Bool
 
coordDimmed :: Bool
 

Instances

Show CoordState 

boardCoordState :: Coord -> BoardState -> CoordStateSource

Returns the CoordState for a coordinate on a board.

mapBoardCoords :: (Int -> Int -> CoordState -> a) -> BoardState -> [[a]]Source

Maps a function over each CoordState in a BoardState, returning a list-of-lists with the function's values. The function is called like fn y x coordState.

isValidMove :: BoardState -> Color -> Coord -> BoolSource

Returns whether it is legal to place a stone of the given color at a point on a board. Accepts out-of-bound coordinates and returns false.

isCurrentValidMove :: BoardState -> Coord -> BoolSource

Returns whether it is legal for the current player to place a stone at a point on a board. Accepts out-of-bound coordinates and returns false.

data Cursor Source

A pointer to a node in a game tree that also holds information about the current state of the game at that node.

Constructors

Cursor 

Fields

cursorParent :: Maybe Cursor

The cursor for the node above this cursor's node in the game tree. The node of the parent cursor is the parent of the cursor's node.

This is Nothing iff the cursor's node has no parent.

cursorChildIndex :: Int

The index of this cursor's node in its parent's child list. When the cursor's node has no parent, the value in this field is not specified.

cursorNode :: Node

The game tree node about which the cursor stores information.

cursorBoard :: BoardState

The complete board state for the current node.

Instances

Show Cursor 

rootCursor :: Node -> CursorSource

Returns a cursor for a root node.

cursorVariations :: VariationModeSource -> Cursor -> [(Coord, Color)]Source

Returns the variations to display for a cursor. The returned list contains the location and color of B and W properties in variation nodes. Variation nodes are either children of the current node, or siblings of the current node, depending on the variation mode source.