Package api

Class MoveRecord


  • public class MoveRecord
    extends java.lang.Object
    A MoveRecord encapsulates a State along with information about how it might have been shifted or modified during a move in the game.
    Author:
    smkautz
    • Constructor Summary

      Constructors 
      Constructor Description
      MoveRecord​(State givenState, int currentIndex)
      Constructs a MoveRecord from the given State and index.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getIndex()
      Returns the index in this MoveRecord.
      int getMovedTo()
      Returns the (possibly) new index for this MoveRecord's cell.
      State getState()
      Returns the state in this MoveRecord.
      boolean isClosed()
      Determines whether this state is an open gate that was closed by a move.
      boolean isDisappeared()
      Determines whether this state was deleted.
      boolean isMoved()
      Determines whether this cell has been given a new index.
      void setClosed()
      Sets the closed status of this MoveRecord.
      void setDisappeared()
      Sets the disappeared status of this MoveRecord.
      void setMovedToIndex​(int newIndex)
      Sets the new index to indicate a state moved to a new location within a state sequence.
      java.lang.String toString()
      Returns a string representation of this MoveRecord.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • MoveRecord

        public MoveRecord​(State givenState,
                          int currentIndex)
        Constructs a MoveRecord from the given State and index. Normally the index is the same as the cell's array index within a valid state sequence. The movedTo index is initially the same as the given index and the disappeared status is false. Index 0 is always the player's initial location.
        Parameters:
        givenState - State for this MoveRecord
        currentIndex - index for this MoveRecord
    • Method Detail

      • getState

        public State getState()
        Returns the state in this MoveRecord.
        Returns:
        state in this MoveRecord
      • getIndex

        public int getIndex()
        Returns the index in this MoveRecord.
        Returns:
        index in this MoveRecord
      • setMovedToIndex

        public void setMovedToIndex​(int newIndex)
        Sets the new index to indicate a state moved to a new location within a state sequence. In the case of a cell containing the player, the new index indicates the new location of the player in the sequence.
        Parameters:
        newIndex - new index for the current cell (or player)
      • getMovedTo

        public int getMovedTo()
        Returns the (possibly) new index for this MoveRecord's cell.
        Returns:
        new index for this MoveRecord's cell
      • isMoved

        public boolean isMoved()
        Determines whether this cell has been given a new index.
        Returns:
        true if the new index differs from the original index
      • isDisappeared

        public boolean isDisappeared()
        Determines whether this state was deleted.
        Returns:
        true if this state was deleted, false otherwise
      • setDisappeared

        public void setDisappeared()
        Sets the disappeared status of this MoveRecord.
      • isClosed

        public boolean isClosed()
        Determines whether this state is an open gate that was closed by a move.
        Returns:
        true if this state was closed
      • setClosed

        public void setClosed()
        Sets the closed status of this MoveRecord.
      • toString

        public java.lang.String toString()
        Returns a string representation of this MoveRecord.
        Overrides:
        toString in class java.lang.Object