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.Status

    Nested classes/interfaces inherited from interface common.TwoPhaseMoveState

    common.TwoPhaseMoveState.TwoPhaseMove<T>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The size of the game board.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a DummyState object representing the initial state of the game.
    Creates a deep copy of the specified DummyState object.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    Set<common.TwoPhaseMoveState.TwoPhaseMove<common.util.board.Position>>
     
    game.State.Player
    Returns the player who moves next.
    game.State.Status
    Returns the status of the game.
    boolean
    Returns whether the game is over.
    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.
    boolean
    isLegalToMoveFrom(common.util.board.Position from)
    Returns whether it is possible to move a coin from the source position specified.
    void
    makeMove(common.TwoPhaseMoveState.TwoPhaseMove<common.util.board.Position> move)
    Moves a coin from the source position specified to the empty target position specified.
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface game.State

    isWinner
  • Field Details

    • BOARD_SIZE

      public static final int BOARD_SIZE
      The size of the game board.
      See Also:
  • Constructor Details

    • DummyState

      public DummyState()
      Creates a DummyState object representing the initial state of the game.
    • DummyState

      public DummyState(DummyState other)
      Creates a deep copy of the specified DummyState object.
      Parameters:
      other - the object to be copied
  • Method Details

    • getNextPlayer

      public game.State.Player getNextPlayer()
      Returns the player who moves next.
      Specified by:
      getNextPlayer in interface game.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:
      isGameOver in interface game.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:
      getStatus in interface game.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:
      isLegalToMoveFrom in interface common.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:
      isLegalMove in interface common.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:
      makeMove in interface common.State<common.TwoPhaseMoveState.TwoPhaseMove<common.util.board.Position>, DummyState>
      Parameters:
      move - the move to be made
    • getLegalMoves

      public Set<common.TwoPhaseMoveState.TwoPhaseMove<common.util.board.Position>> getLegalMoves()
      Specified by:
      getLegalMoves in interface common.State<common.TwoPhaseMoveState.TwoPhaseMove<common.util.board.Position>, DummyState>
    • copy

      public DummyState copy()
      Specified by:
      copy in interface common.util.Copyable<DummyState>
      Specified by:
      copy in interface common.State<common.TwoPhaseMoveState.TwoPhaseMove<common.util.board.Position>, DummyState>
    • toString

      public String toString()
      Overrides:
      toString in class Object