goatee-0.4.0: A monadic take on a 2,500-year-old board game - library.
Safe HaskellNone
LanguageHaskell2010

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

Instances details
Eq RootInfo Source # 
Instance details

Defined in Game.Goatee.Lib.Board

Show RootInfo Source # 
Instance details

Defined in Game.Goatee.Lib.Board

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

Instances

Instances details
Show BoardState Source # 
Instance details

Defined in Game.Goatee.Lib.Board

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

Instances

Instances details
Eq CoordState Source # 
Instance details

Defined in Game.Goatee.Lib.Board

Show CoordState Source # 
Instance details

Defined in Game.Goatee.Lib.Board

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

Instances details
Show Cursor Source # 
Instance details

Defined in Game.Goatee.Lib.Board

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.