public interface State extends Copyable
Modifier and Type | Interface and Description |
---|---|
static interface |
State.ActionIterator
An iterator over the actions available from a state in an undefined order.
|
static class |
State.ActionIteratorFromIterable
Adapter class to convert an Iterable
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
actionToString(long action) |
State |
copy() |
State.ActionIterator |
getActionIterator()
Gets an action iterator for this state.
|
int |
getCurrentPlayer() |
long |
getRandomAction() |
int |
getWinner() |
State |
initializeFrom(Copyable state)
Initialize this state from the information in the provided object.
|
boolean |
isTerminal() |
long |
perform(long action)
Performs the provided action by mutating the state.
|
int |
playerAfter(int player) |
int |
playerBefore(int player) |
State |
setToStartingConditions()
Put this state in the starting condition for the game, the state before
any actions have been taken.
|
void |
undo(long action,
long undoToken)
Undoes the provided action by mutating the state back to the way that it
was.
|
State.ActionIterator getActionIterator()
State.ActionIterator.nextAction()
without breaking the iterator or causing it to lose its place.long getRandomAction()
long perform(long action)
getActionIterator()
to return only legal actions.action
- The action to perform.undo(long, long)
in order to undo this action.void undo(long action, long undoToken)
action
- The action to undo.undoToken
- The undo token returned from
undo(long, long)
when this action was performed.State setToStartingConditions()
State initializeFrom(Copyable state)
state
- The object to initialize this state from.boolean isTerminal()
int getWinner()
int getCurrentPlayer()
int playerAfter(int player)
player
- A player.int playerBefore(int player)
player
- A player.java.lang.String actionToString(long action)
action
- One of this state's actions.