|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--GameState
An object of this class represents the state of the game, including the current board position (accessible using the square method) and whose turn it is (accessible using the turn method). A new game position can be generated using the applyMove method. Squares are indexed by pairs x,y where each is 0, 1 or 2. Players are encoded as +1 or -1, with +1 moving first.
Constructor Summary | |
GameState()
Constructs a new game state with no pieces on the board, and +1's turn. |
|
GameState(int[][] squares,
int turn)
Constructs a new game state with pieces on board as specified by squares; the player whose turn it is is specified by turn. |
Method Summary | |
GameState |
applyMove(Move m)
Constructs and returns a new game state obtained from this game state by applying the given Move object to this GameState. |
boolean |
equals(java.lang.Object o)
Compares the specified object to this game state for equality. |
int |
hashCode()
Returns the hash code for this game position. |
int |
square(int x,
int y)
Returns the contents of square x,y on the current board position. |
java.lang.String |
toLongString(int indentBy)
Produces a multi-line string description of the GameState object indented indentBy spaces. |
java.lang.String |
toString()
Produces a one line string description of the GameState object. |
int |
turn()
Returns the player (+1 or -1) whose turn it is. |
Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public GameState()
public GameState(int[][] squares, int turn)
squares
- squares[x][y] specifies the contents of
the square x,y. +1 or -1 indicates that one of the
players has a piece in this square. 0 indicates that the
square is empty.Method Detail |
public int square(int x, int y)
public int turn()
public GameState applyMove(Move m)
m
- Move to be applied
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- object to be comparedpublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toLongString(int indentBy)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |