Class DummyState
java.lang.Object
games.dummy.DummyState
- All Implemented Interfaces:
common.State<common.TwoPhaseMoveState.TwoPhaseMove<common.util.board.Position>, DummyState>, common.TwoPhaseMoveState<common.util.board.Position, DummyState>, common.util.Copyable<DummyState>, game.State<common.TwoPhaseMoveState.TwoPhaseMove<common.util.board.Position>, DummyState>, game.TwoPhaseMoveState<common.util.board.Position, DummyState>
public class DummyState
extends Object
implements game.TwoPhaseMoveState<common.util.board.Position, DummyState>
Represents the states of a dummy two-player game that was created purely for
demonstration purposes. The game is played on a board with
5 rows and columns. Each corner square of the board
contains a coin; all the other squares are empty. The players move in
alternating turns. On each turn, a coin must be moved to an 8-adjacent empty
square. The player who moves a coin to the middle square of the board wins
the game.
-
Nested Class Summary
Nested classes/interfaces inherited from interface game.State
game.State.Player, game.State.StatusNested classes/interfaces inherited from interface common.TwoPhaseMoveState
common.TwoPhaseMoveState.TwoPhaseMove<T> -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates aDummyStateobject representing the initial state of the game.DummyState(DummyState other) Creates a deep copy of the specifiedDummyStateobject. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Set<common.TwoPhaseMoveState.TwoPhaseMove<common.util.board.Position>> game.State.PlayerReturns the player who moves next.game.State.StatusReturns the status of the game.booleanReturns whether the game is over.booleanisLegalMove(common.TwoPhaseMoveState.TwoPhaseMove<common.util.board.Position> move) Returns whether it is possible to move a coin from the source position specified to the target position specified.booleanisLegalToMoveFrom(common.util.board.Position from) Returns whether it is possible to move a coin from the source position specified.voidmakeMove(common.TwoPhaseMoveState.TwoPhaseMove<common.util.board.Position> move) Moves a coin from the source position specified to the empty target position specified.toString()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface game.State
isWinner
-
Field Details
-
BOARD_SIZE
public static final int BOARD_SIZEThe size of the game board.- See Also:
-
-
Constructor Details
-
DummyState
public DummyState()Creates aDummyStateobject representing the initial state of the game. -
DummyState
Creates a deep copy of the specifiedDummyStateobject.- Parameters:
other- the object to be copied
-
-
Method Details
-
getNextPlayer
public game.State.Player getNextPlayer()Returns the player who moves next.- Specified by:
getNextPlayerin interfacegame.State<common.TwoPhaseMoveState.TwoPhaseMove<common.util.board.Position>, DummyState>- Returns:
- the player who moves next
-
isGameOver
public boolean isGameOver()Returns whether the game is over.- Specified by:
isGameOverin interfacegame.State<common.TwoPhaseMoveState.TwoPhaseMove<common.util.board.Position>, DummyState>- Returns:
- whether the game is over
-
getStatus
public game.State.Status getStatus()Returns the status of the game.- Specified by:
getStatusin interfacegame.State<common.TwoPhaseMoveState.TwoPhaseMove<common.util.board.Position>, DummyState>- Returns:
- the status of the game
-
isLegalToMoveFrom
public boolean isLegalToMoveFrom(common.util.board.Position from) Returns whether it is possible to move a coin from the source position specified.- Specified by:
isLegalToMoveFromin interfacecommon.TwoPhaseMoveState<common.util.board.Position, DummyState>- Parameters:
from- the source position from which a move is to be made- Returns:
- whether it is possible to move a coin from the source position specified
-
isLegalMove
public boolean isLegalMove(common.TwoPhaseMoveState.TwoPhaseMove<common.util.board.Position> move) Returns whether it is possible to move a coin from the source position specified to the target position specified.- Specified by:
isLegalMovein interfacecommon.State<common.TwoPhaseMoveState.TwoPhaseMove<common.util.board.Position>, DummyState>- Parameters:
move- the move to be made- Returns:
- whether it is possible to move a coin from the source position specified to the target position specified
-
makeMove
public void makeMove(common.TwoPhaseMoveState.TwoPhaseMove<common.util.board.Position> move) Moves a coin from the source position specified to the empty target position specified.- Specified by:
makeMovein interfacecommon.State<common.TwoPhaseMoveState.TwoPhaseMove<common.util.board.Position>, DummyState>- Parameters:
move- the move to be made
-
getLegalMoves
- Specified by:
getLegalMovesin interfacecommon.State<common.TwoPhaseMoveState.TwoPhaseMove<common.util.board.Position>, DummyState>
-
copy
- Specified by:
copyin interfacecommon.util.Copyable<DummyState>- Specified by:
copyin interfacecommon.State<common.TwoPhaseMoveState.TwoPhaseMove<common.util.board.Position>, DummyState>
-
toString
-