Class BoardState

java.lang.Object
ubc.team09.state.BoardState

public class BoardState extends Object
Represents a board state. Unlike a full game state (see State), this board will not include information about who the active player is, the last move taken, nor does it include any method to produce child states.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final long[]
    An occupancy board; i.e., a bitboard that has a flag wherever there is a queen or an arrow.
    final byte[]
    The position indices of the queens on the board.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BoardState(long[] occupancy, byte[] queens)
    Creates a new minimal state.
    BoardState(BoardState prev, int move)
    Creates a new state by applying the given move to an old state.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if and only if the given state has the same occupancy board and queen positions as this object.
    static BoardState
    Creates the initial board state.
    boolean
    Returns true if and only if the given state has the same occupancy board and queen positions as this object.
    boolean
    isTerminal(byte activePlayer)
    Returns true if and only if there are no moves that could be made from this position.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • occupancy

      public final long[] occupancy
      An occupancy board; i.e., a bitboard that has a flag wherever there is a queen or an arrow. If a position is not flagged on this board, then it means that position is empty.
    • queens

      public final byte[] queens
      The position indices of the queens on the board. The first four are White's queens, and the last four are Black's.
  • Constructor Details

    • BoardState

      public BoardState(long[] occupancy, byte[] queens)
      Creates a new minimal state. The arguments given are directly given to the state's fields, without being copied, so it's important that they are not mutated.
      Parameters:
      occupancy -
      queens -
    • BoardState

      public BoardState(BoardState prev, int move)
      Creates a new state by applying the given move to an old state.
  • Method Details

    • isConsistentWith

      public boolean isConsistentWith(State state)
      Returns true if and only if the given state has the same occupancy board and queen positions as this object.
      Parameters:
      state - The full state to consider.
    • equals

      public boolean equals(BoardState state)
      Returns true if and only if the given state has the same occupancy board and queen positions as this object.
      Parameters:
      state - The state to consider.
    • isTerminal

      public boolean isTerminal(byte activePlayer)
      Returns true if and only if there are no moves that could be made from this position.
    • initial

      public static BoardState initial()
      Creates the initial board state.