|
Algorithm Development Kit 1.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectalgs.model.problems.tictactoe.model.TicTacToeState
public class TicTacToeState
The TicTacToe state is determined by a board and the specific logic being used for that board state.
To simplify debugging and dot output, this class supports the IGraphEntity interface.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface algs.debug.IGraphEntity |
|---|
IGraphEntity.Formatter |
| Constructor Summary | |
|---|---|
TicTacToeState(TicTacToeBoard board,
Logic logic)
The game state is dependent upon a tic-tac-toe board, together with the logic being used to govern the game. |
|
| Method Summary | |
|---|---|
TicTacToeBoard |
board()
Expose board state. |
TicTacToeState |
copy()
Copy full state information. |
int |
counter()
Debugging interface for retrieving counter. |
boolean |
equivalent(IGameState gameState)
Determine whether the state is the same by comparing the board state under eight different rotations and reflections. |
void |
incrementCounter()
Debugging interface for incrementing count of games. |
boolean |
isDraw()
Determine if this game state is a draw. |
boolean |
isWin()
Determine if this game state has a winner. |
Logic |
logic()
External state may be found in logic. |
java.lang.String |
nodeLabel()
Note that gameState changes constantly, so we can do nothing more than grab information and cache it here. |
void |
reset(TicTacToeBoard newBoard)
Resets to new game, with new board state and X once again starting. |
java.lang.Object |
storedData()
Return external (optional) state information that may have been stored with this state. |
java.lang.Object |
storedData(java.lang.Object o)
Store external (optional) state information with this TicTacToe state. |
java.lang.String |
toString()
Expose Board state as a string. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public TicTacToeState(TicTacToeBoard board,
Logic logic)
Because tic-tac-toe variations may need to store additional state information with each state, the decision is made to allow the logic to store this additional state. We must ensure that copy() properly deals with logic, then.
board - Board state to uselogic - Logic governing the game. May have additional state information.| Method Detail |
|---|
public TicTacToeState copy()
copy in interface IGameStatepublic TicTacToeBoard board()
public Logic logic()
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean isWin()
IGameState
isWin in interface IGameStatepublic boolean isDraw()
IGameState
isDraw in interface IGameStatepublic void reset(TicTacToeBoard newBoard)
public boolean equivalent(IGameState gameState)
equivalent in interface IGameStategameState - The game state being compared against.public java.lang.Object storedData(java.lang.Object o)
o - object to be storedpublic java.lang.Object storedData()
public void incrementCounter()
IGameState
incrementCounter in interface IGameStatepublic int counter()
IGameState
counter in interface IGameStatepublic java.lang.String nodeLabel()
nodeLabel in interface IGraphEntity
|
Algorithm Development Kit 1.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||