Class QGraph

java.lang.Object
ubc.team09.state.QGraph

public class QGraph extends Object
This class includes operations that model the board state as a graph, where
- vertices are board positions, and
- two vertices v and u are adjacent if and only if a queen could move from one to the other in a single move.

The queen-move definition of edges is the reason for the "Q" in the name.
See KGraph.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final byte
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    distance(byte origin, long[] occupancy)
    Given an origin, returns the distance from that point to each other point on the board.
    static long[]
    neighbors(byte position, long[] occupancy)
    Returns a bitboard with flags for each position adjacent to position.
    static long[]
    neighbors(long[] originalPositions, long[] occupancy)
    Given a set of origins (on a bitboard) and an occupancy board, this returns a board where each position is flagged if and only if it is adjacent to any one of the origins.

    Methods inherited from class Object

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

  • Method Details

    • neighbors

      public static long[] neighbors(byte position, long[] occupancy)
      Returns a bitboard with flags for each position adjacent to position.
    • neighbors

      public static long[] neighbors(long[] originalPositions, long[] occupancy)
      Given a set of origins (on a bitboard) and an occupancy board, this returns a board where each position is flagged if and only if it is adjacent to any one of the origins.
      Parameters:
      originalPositions - A bitboard with each possible origin flagged.
      occupancy - A bitboard with each occupied square flagged.
    • distance

      public static byte[] distance(byte origin, long[] occupancy)
      Given an origin, returns the distance from that point to each other point on the board. If the point is unreachable, then it is given a distance of 100.