Connect4State
State[Connect4, Connect4] typeclass instance for Connect4.
P = S = Connect4: the proto-state and state are the same type. construct takes (newState, previousState) and returns newState.
Attributes
- Graph
-
- Supertypes
- Self type
-
Connect4State.type
Members list
Type members
Inherited classlikes
Attributes
- Inherited from:
- Ordering
- Supertypes
-
class Objecttrait Matchableclass Any
Value members
Concrete 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.
Heuristic from the perspective of the player who just moved (s.player). Positive = good for the player who just moved.
Heuristic from the perspective of the player who just moved (s.player). Positive = good for the player who just moved.
Terminal positions: s.player just won → Double.MaxValue s.player just lost → Double.MinValue draw → 0.0
Non-terminal: score for the player who just moved minus score for the opponent, plus center column bonus.
Attributes
Goal detection: Some(true) — there is a winner Some(false) — board is full, with no winner (draw) None — game is still in progress
Goal detection: Some(true) — there is a winner Some(false) — board is full, with no winner (draw) None — game is still in progress
Attributes
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.
Legal moves: one Transition per open column.
Legal moves: one Transition per open column.
Attributes
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
Inherited 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.
- Inherited from:
- State
Attributes
- Definition Classes
-
Ordering -> PartialOrdering -> Equiv
- Inherited from:
- Ordering
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.
- Inherited from:
- State
Attributes
- Definition Classes
-
Ordering -> PartialOrdering
- Inherited from:
- Ordering
Attributes
- Definition Classes
-
Ordering -> PartialOrdering
- Inherited from:
- Ordering
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 from:
- State
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
- 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:
- Ordering
Givens
Givens
Implicits
Inherited implicits
Attributes
- Inherited from:
- Ordering