|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--GameRules
An object of this class describes the rules for a particular variation of movable tic-tac-toe, specifically, the moves that are possible from a given state, and whether a given state is a win for one of the players.
Constructor Summary | |
GameRules(int[][] ml)
Constructs a GameRules object in which legal moves are defined by the given array of 4-tuples. |
|
GameRules(java.lang.String game_id)
Constructs a GameRules object for a game whose legal moves are stored in the file game_id.rules. |
Method Summary | |
boolean |
isLegal(GameState gs,
Move move)
Tests whether the given game state and the move from it are legal according to the game rules. |
int |
isWin(GameState gs)
Returns +1 if player +1 has won in the given game state, -1 if player -1 has won, and 0 if no one has won. |
Move[] |
legalMoves(GameState gs)
Returns an array of all possible legal moves from the given game state. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public GameRules(int[][] ml)
public GameRules(java.lang.String game_id) throws java.lang.IllegalArgumentException, java.io.IOException
Method Detail |
public Move[] legalMoves(GameState gs)
gs
- given game statepublic int isWin(GameState gs)
gs
- game state to be checkedpublic boolean isLegal(GameState gs, Move move)
gs
- game state to be checkedmove
- move to be checked
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |