Class State

java.lang.Object
ubc.team09.state.State

public class State extends Object
Represents a complete game state.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final byte
    The player who can make a move from this position.
    final int
    The move that created this board state.
    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
    State(long[] occupancy, byte[] queens, byte activePlayer, int move)
    Creates a new game state.
    State(State prev, int move)
    Creates a new board state by applying a move to an existing one.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a generator which yields all possible child states.
    Returns a copy of this state.
    void
    impose(BoardState newState)
    Updates this board's occupancy and queen positions to match the given board.

    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.
    • activePlayer

      public final byte activePlayer
      The player who can make a move from this position.
    • move

      public final int move
      The move that created this board state. See Move
  • Constructor Details

    • State

      public State(long[] occupancy, byte[] queens, byte activePlayer, int move)
      Creates a new game state.
      Parameters:
      occupancy - A bitboard with each occupied square (i.e., any square with an arrow or a queen) flagged.
      queens - The position indices (0-99) of the eight queens on the board. It must be maintained that the first four queens are White's queens, and the latter four are Black's.
      activePlayer - The player whose turn it is in this state; i.e., who will make the next move. Use C.WHITE or C.BLACK.
      move - The integer representation of the most recent move. See Move.
    • State

      public State(State prev, int move)
      Creates a new board state by applying a move to an existing one.
      Parameters:
      prev - The previous board state. This will not be mutated.
      move - The move to apply to get the new board state. See Move.
  • Method Details

    • children

      public StateGenerator children()
      Returns a generator which yields all possible child states.
    • copy

      public State copy()
      Returns a copy of this state.
    • impose

      public void impose(BoardState newState)
      Updates this board's occupancy and queen positions to match the given board.