# Data.GameTree

- Package
- purescript-gametree
- Repository
- sharkdp/purescript-gametree

This module defines a type class for nodes in a tree of game states (two-player zero-sum games) and provides algorithms to search the game trees for optimal strategies.

### #Score Source

`data Score`

The (heuristic) value of a node in the game tree. `Lose`

and `Win`

can
be thought of as *-infinity* and *+infinity*.

Mathematically, `Score`

is analogous to the extended real number line,
which is a totally ordered set (see `Ord`

instance). `Score`

is not a
`Semiring`

, but supports negation (`negateScore`

).

See: https://en.wikipedia.org/wiki/Extended_real_number_line

#### Constructors

#### Instances

### #Node Source

`class Node a where`

A node in a game tree, typically representing a given game state.
`isTerminal`

returns `true`

if the node refers to a game state that is
either a win, a lose, or a draw. The `score`

of a node is the (heuristic)
value of the given node and is always defined from the viewpoint of
the 'first' player (the one that calls the search algorithm). Finally,
`children`

returns a list of game states that can be reached through valid
moves.

Law:

```
isTerminal n == null (children n)
```

#### Members

### #isTerminalDefault Source

`isTerminalDefault :: forall a. Node a => a -> Boolean`

A default implementation for `isTerminal`

.

- Modules
- Data.
GameTree