State
Type class for a State. A State is a position in a game or other situation which requires heuristically-directed tree search. For example, a State might describe a board position in Tic-tac-toe or Chess.
NOTE that State depends on Transition. CONSIDER eliminating Transition such that all logic is defined by State.
Type parameters
- P
-
a proto-state, that's to say a type such that a P, S tuple can be converted into a new S.
- S
-
the underlying type on which the state is based.
Attributes
- Graph
-
- Supertypes
-
trait Ordering[S]trait PartialOrdering[S]trait Equiv[S]trait Serializabletrait Comparator[S]class Objecttrait Matchableclass AnyShow all
- Known subtypes
Members list
Type members
Inherited classlikes
Attributes
- Inherited from:
- Ordering
- Supertypes
-
class Objecttrait Matchableclass Any
Value members
Abstract methods
Abstract method to construct an S from a P and an S.
Abstract method to construct an S from a P and an S.
Value parameters
- proto
-
a (P, S) tuple.
Attributes
- Returns
-
an S.
Abstract method to determine an estimate of an S's efficacy in reaching a goal.
Abstract method to determine an estimate of an S's efficacy in reaching a goal.
Value parameters
- s
-
an S.
Attributes
- Returns
-
a Double (in a domain appropriate to the type S where a higher value is always believed to be closer to a goal).
Abstract method to determine if state s is a goal state. In some games, the goal is to win. In other games, for example, contract bridge, the goal is to achieve some measurable state, such as a certain number of tricks.
Abstract method to determine if state s is a goal state. In some games, the goal is to win. In other games, for example, contract bridge, the goal is to achieve some measurable state, such as a certain number of tricks.
Value parameters
- s
-
an S.
Attributes
- Returns
-
an Option of Boolean: if None then this state is not a goal state. If Some(true), then s achieves a goal. If Some(false), then such a goal is impossible to achieve.
Abstract method to determine if an S is valid.
Abstract method to determine if an S is valid.
Value parameters
- s
-
an S.
Attributes
- Returns
-
a Boolean.
Method to determine if s is a winning state. NOTE: it makes no sense to invoke isWin unless the result of isGoal is Some(true).
Method to determine if s is a winning state. NOTE: it makes no sense to invoke isWin unless the result of isGoal is Some(true).
Value parameters
- s
-
an S
Attributes
- Returns
-
true if s is a win, else false.
Abstract method to determine the possible moves from the given S.
Abstract method to determine the possible moves from the given S.
Value parameters
- s
-
an S.
Attributes
- Returns
-
a sequence of Transition[S]
Method to render a State as a String.
Method to render a State as a String.
Value parameters
- s
-
the State to render.
Attributes
- Returns
-
a String representation of s.
A significant sequence value that distinguishes this state from others. Typically the number of moves made so far (0 for the starting state). Used to determine whose turn it is via isFirstPlayerToMove.
A significant sequence value that distinguishes this state from others. Typically the number of moves made so far (0 for the starting state). Used to determine whose turn it is via isFirstPlayerToMove.
Value parameters
- s
-
the state.
Attributes
Concrete methods
Method to determine the ordering of two States. It is based on the heuristic.
Method to determine the ordering of two States. It is based on the heuristic.
Value parameters
- s1
-
first S.
- s2
-
second S.
Attributes
- Returns
-
<0 if s1 < s2, >0 if s1 > s2, else 0.
Concrete method to get the possible states to follow the given state s. The resulting sequence is in no particular order.
Concrete method to get the possible states to follow the given state s. The resulting sequence is in no particular order.
Value parameters
- s
-
an S.
Attributes
- Returns
-
a sequence of S instances which are the possible states to follow s.
Returns true if it is the first player's turn to move from state s.
Returns true if it is the first player's turn to move from state s.
To be completely unambiguous: the first player is the one who makes the very first move of the game. isFirstPlayerToMove(s) returns true when it is that player's turn again — e.g., for a two-player game, when an even number of moves have been made (sequence 0, 2, 4, ...).
It returns false when it is the second (or any subsequent) player's turn — i.e., when an odd number of moves have been made (sequence 1, 3, 5, ...).
Example (TicTacToe): empty board (sequence=0) → true (X moves first) after X plays (sequence=1) → false (O moves next) after O plays (sequence=2) → true (X moves next)
For games with more than two players, override this method as needed.
Value parameters
- s
-
the current state.
Attributes
- Returns
-
true if the first player is to move, false otherwise.
Inherited methods
Attributes
- Definition Classes
-
Ordering -> PartialOrdering -> Equiv
- Inherited from:
- Ordering
Attributes
- Definition Classes
-
Ordering -> PartialOrdering
- Inherited from:
- Ordering
Attributes
- Definition Classes
-
Ordering -> PartialOrdering
- Inherited from:
- Ordering
Attributes
- Inherited from:
- Ordering
Attributes
- Definition Classes
-
Ordering -> PartialOrdering
- Inherited from:
- Ordering
Attributes
- Definition Classes
-
Ordering -> PartialOrdering
- Inherited from:
- Ordering
Attributes
- Inherited from:
- Ordering
Attributes
- Inherited from:
- Ordering
Attributes
- Inherited from:
- Ordering
Attributes
- Inherited from:
- Ordering
Attributes
- Inherited from:
- Ordering
Attributes
- Definition Classes
-
Ordering -> PartialOrdering
- Inherited from:
- Ordering
Attributes
- Inherited from:
- Comparator
Attributes
- Inherited from:
- Comparator
Attributes
- Inherited from:
- Comparator
Attributes
- Inherited from:
- Comparator
Attributes
- Inherited from:
- Comparator
Attributes
- Inherited from:
- Comparator
Attributes
- Inherited from:
- Comparator
Attributes
- Inherited from:
- Ordering
Implicits
Inherited implicits
Attributes
- Inherited from:
- Ordering