bishbosh-0.1.4.0: Plays chess.
Safe HaskellNone
LanguageHaskell2010

BishBosh.Model.GameTree

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 BareGameTree = Tree Game Source #

Each node defines the state of the game.

type MoveFrequency = MoveFrequency Move Source #

Focus the underlying type.

Data-types

data GameTree Source #

Wrap a BareGameTree.

Instances

Instances details
Show GameTree Source # 
Instance details

Defined in BishBosh.Model.GameTree

Default GameTree Source # 
Instance details

Defined in BishBosh.Model.GameTree

Methods

def :: GameTree #

Prunable GameTree Source # 
Instance details

Defined in BishBosh.Model.GameTree

ShowNotation GameTree Source # 
Instance details

Defined in BishBosh.Model.GameTree

Functions

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.

countPositions :: Depth -> NPositions Source #

Counts the number of possible positions in chess, down to the specified depth. N.B.: some of these may be transpositions.

traceRoute Source #

Arguments

:: GameTree 
-> [Turn]

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

-> Maybe [Game]

Returns Nothing on match-failure.

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

sortGameTree :: Maybe CaptureMoveSortAlgorithm -> EvaluateRank -> MoveFrequency -> Transformation Source #

  • 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 from each position is sorted by; 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 :: GameTree -> MoveFrequency Source #

  • Count the instances of each move in the specified tree.
  • CAVEAT: assumes that root game hasn't any pre-applied moves; which might occur in a test-case.
  • 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

fromGame :: Game -> GameTree Source #

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