TicTacToeState$

com.phasmidsoftware.gambit.examples.tictactoe.TicTacToe.TicTacToeState$
See theTicTacToeState$ companion object

Trait that extends the type class State with a concrete underlying type of TicTacToe.

Attributes

Companion
object
Graph
Supertypes
trait Ordering[TicTacToe]
trait PartialOrdering[TicTacToe]
trait Equiv[TicTacToe]
trait Serializable
trait Comparator[TicTacToe]
class Object
trait Matchable
class Any
Show all
Known subtypes

Members list

Type members

Inherited classlikes

class OrderingOps(lhs: Ordering.this.T)

Attributes

Inherited from:
Ordering
Supertypes
class Object
trait Matchable
class Any

Value members

Concrete methods

Method to construct an S from a proto-state:

Method to construct an S from a proto-state:

Value parameters

proto

a (Board, TicTacToe) tuple.

Attributes

Returns

a TicTacToe.

def heuristic(s: TicTacToe): Double

How close are we to winning?

How close are we to winning?

Value parameters

s

a state.

Attributes

Returns

the number of our aligned cells - their aligned cells.

def isGoal(s: TicTacToe): Option[Boolean]

Have we reached a result? And, if so, who won?

Have we reached a result? And, if so, who won?

Value parameters

s

a (current) state.

Attributes

Returns

an Option[Boolean]: if None then this state is not a goal state. If Some(b) then: if b is true, we got a definite result, and the winner is determined by examining s in more detail. If b is false, we got a partial result, and we should continue to seek a more definite result.

def isValid(s: TicTacToe): Boolean

In this game, all states are valid.

In this game, all states are valid.

Value parameters

s

a state.

Attributes

Returns

true.

def isWin(s: TicTacToe): 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.

Return all of the possible transitions from the given state.

Return all of the possible transitions from the given state.

CONSIDER refactoring so that we do not discard the state when constructing a Move.

Value parameters

s

a state.

Attributes

Returns

a sequence of Transition[S]

def render(s: TicTacToe): String

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.

def sequence(s: TicTacToe): Int

a significant sequence value that distinguishes this state from others and which can be derived from a P.

a significant sequence value that distinguishes this state from others and which can be derived from a P.

Value parameters

s

parameter from which we may derive the sequence.

Attributes

Inherited methods

def compare(s1: TicTacToe, s2: TicTacToe): Int

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
override def equiv(x: TicTacToe, y: TicTacToe): Boolean

Attributes

Definition Classes
Ordering -> PartialOrdering -> Equiv
Inherited from:
Ordering
def getStates(s: TicTacToe): Seq[TicTacToe]

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
override def gt(x: TicTacToe, y: TicTacToe): Boolean

Attributes

Definition Classes
Ordering -> PartialOrdering
Inherited from:
Ordering
override def gteq(x: TicTacToe, y: TicTacToe): Boolean

Attributes

Definition Classes
Ordering -> PartialOrdering
Inherited from:
Ordering
def isFirstPlayerToMove(s: TicTacToe): Boolean

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
def isReverseOf(other: Ordering[_]): Boolean

Attributes

Inherited from:
Ordering
override def lt(x: TicTacToe, y: TicTacToe): Boolean

Attributes

Definition Classes
Ordering -> PartialOrdering
Inherited from:
Ordering
override def lteq(x: TicTacToe, y: TicTacToe): Boolean

Attributes

Definition Classes
Ordering -> PartialOrdering
Inherited from:
Ordering
def max[U <: TicTacToe](x: U, y: U): U

Attributes

Inherited from:
Ordering
def min[U <: TicTacToe](x: U, y: U): U

Attributes

Inherited from:
Ordering
def on[U](f: U => TicTacToe): Ordering[U]

Attributes

Inherited from:
Ordering
def orElse(other: Ordering[TicTacToe]): Ordering[TicTacToe]

Attributes

Inherited from:
Ordering
def orElseBy[S](f: TicTacToe => S)(implicit ord: Ordering[S]): Ordering[TicTacToe]

Attributes

Inherited from:
Ordering
override def reverse: Ordering[TicTacToe]

Attributes

Definition Classes
Ordering -> PartialOrdering
Inherited from:
Ordering
def reversed(): Comparator[TicTacToe]

Attributes

Inherited from:
Comparator
def thenComparing[U <: Comparable[_ >: U <: <FromJavaObject>]](x$0: Function[_ >: TicTacToe <: <FromJavaObject>, _ <: U]): Comparator[TicTacToe]

Attributes

Inherited from:
Comparator
def thenComparing[U <: <FromJavaObject>](x$0: Function[_ >: TicTacToe <: <FromJavaObject>, _ <: U], x$1: Comparator[_ >: U <: <FromJavaObject>]): Comparator[TicTacToe]

Attributes

Inherited from:
Comparator
def thenComparing(x$0: Comparator[_ >: TicTacToe <: <FromJavaObject>]): Comparator[TicTacToe]

Attributes

Inherited from:
Comparator
def thenComparingDouble(x$0: ToDoubleFunction[_ >: TicTacToe <: <FromJavaObject>]): Comparator[TicTacToe]

Attributes

Inherited from:
Comparator
def thenComparingInt(x$0: ToIntFunction[_ >: TicTacToe <: <FromJavaObject>]): Comparator[TicTacToe]

Attributes

Inherited from:
Comparator
def thenComparingLong(x$0: ToLongFunction[_ >: TicTacToe <: <FromJavaObject>]): Comparator[TicTacToe]

Attributes

Inherited from:
Comparator
def tryCompare(x: TicTacToe, y: TicTacToe): Some[Int]

Attributes

Inherited from:
Ordering

Implicits

Inherited implicits

implicit def mkOrderingOps(lhs: TicTacToe): OrderingOps

Attributes

Inherited from:
Ordering