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

Safe HaskellNone
LanguageHaskell98

Game.Goatee.Lib.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

emptyGameInfo :: RootInfo -> GameInfo Source

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

internalIsGameInfoNode :: Node -> Bool Source

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.

boardHasCoordMarks :: Bool

Whether any of the board's CoordStates have a Mark set on them. This is an optimization to make it more efficient to clear marks in the common case where there are no marks set.

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

Instances

boardWidth :: BoardState -> Int Source

Returns the width of the board, in stones.

boardHeight :: BoardState -> Int Source

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
 

emptyBoardState :: Int -> Int -> BoardState Source

Creates a BoardState for an empty board of the given width and height.

emptyCoordState :: CoordState Source

A CoordState for an empty point on the board.

boardCoordState :: Coord -> BoardState -> CoordState Source

Returns the CoordState for a coordinate on a board.

boardCoordModify :: BoardState -> Coord -> (CoordState -> CoordState) -> BoardState Source

Modifies a BoardState by updating the CoordState at a single point.

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 -> Bool Source

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 -> Bool Source

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.

Instances

cursorParent :: Cursor -> Maybe Cursor Source

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 :: Cursor -> Int Source

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 :: Cursor -> Node Source

The game tree node about which the cursor stores information.

cursorBoard :: Cursor -> BoardState Source

The complete board state for the current node.

rootCursor :: Node -> Cursor Source

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.