bishbosh-0.0.0.3: Plays chess.

Safe HaskellNone
LanguageHaskell2010

BishBosh.Model.GameTree

Contents

Description

AUTHOR
Dr. Alistair Ward
DESCRIPTION
  • Defines chess as a constant tree of all possible moves.
  • Because of the conceptually infinite size of this data-structure, care must be taken not to attempt to call show, '(==)', ...

Synopsis

Types

Type-synonyms

type MoveFrequency x y = MoveFrequency (Move x y) Source #

Focus the underlying type.

Data-types

data GameTree x y Source #

Wrap a BareGameTree.

Instances

(Show y, Show x, Ord y, Ord x, Enum y, Enum x) => Show (GameTree x y) Source # 

Methods

showsPrec :: Int -> GameTree x y -> ShowS #

show :: GameTree x y -> String #

showList :: [GameTree x y] -> ShowS #

(Enum x, Enum y, Ord x, Ord y, Show x, Show y) => Default (GameTree x y) Source # 

Methods

def :: GameTree x y #

Prunable (GameTree x y) Source # 

Methods

prune :: Depth -> GameTree x y -> GameTree x y Source #

(Enum x, Enum y) => ShowNotation (GameTree x y) Source # 

Function

countGames :: Depth -> NGames Source #

  • Counts the number of game-states in the constant game of chess, at the specified depth, including any which terminated earlier.
  • N.B.: some of the game-states may have identical positions, reached by different sequences of moves.

countMoves :: Depth -> NGames Source #

Counts the number of possible plies in chess, down to the specified depth.

traceRoute Source #

Arguments

:: (Eq x, Eq y) 
=> GameTree x y 
-> [Turn x y]

The data against which, nodes from the tree should be matched.

-> Maybe [Game x y]

Returns Nothing on match-failure.

Trace the route down the tree which matches the specified list of turns.

sortGameTree Source #

Arguments

:: (Integral x, Integral y, Num rankValue, Ord rankValue) 
=> Bool

preferMovesTowardsCentre.

-> Maybe CaptureMoveSortAlgorithm 
-> EvaluateRank rankValue 
-> MoveFrequency x y 
-> Transformation x y 
  • Independently sorts the forest of moves at each node of the tree, without regard to runtime-data.
  • Depending on preferences, the list of moves available to each game is sequentially sorted by: those which reduce the radius from the centre of the board. either those which capture a valuable piece using a cheap piece, or those which win extended battles at a specific location.
  • The above sort-algorithms are stable & can therefore be applied independently.

toMoveFrequency :: (Ord x, Ord y) => GameTree x y -> MoveFrequency x y Source #

  • Count the instances of each move in the specified tree, including any pre-applied to the apex game.
  • CAVEAT: ambiguity remains regarding the move-type (especially any piece taken).
  • CAVEAT: a node is counted as just one instance of the move, rather than the number of games which passed through that node. Had the move-frequency been derived from a list of games, a different distribution would result, but then early moves would appear popular rather than just the consequence of limited choice.

Constructor

fromBareGameTree :: BareGameTree x y -> GameTree x y Source #

Constructor.

fromGame :: (Enum x, Enum y, Ord x, Ord y, Show x, Show y) => Game x y -> GameTree x y Source #

Constructs a game-tree with the specified game at its root.