Class QGraph
java.lang.Object
ubc.team09.state.QGraph
This class includes operations that model the board state as a graph, where
- vertices are board positions, and
- two vertices
The queen-move definition of edges is the reason for the "Q" in the name.
See
- 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 -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 toposition.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.
-
Field Details
-
UNREACHABLE
public static final byte UNREACHABLE- See Also:
-
-
Method Details
-
neighbors
public static long[] neighbors(byte position, long[] occupancy) Returns a bitboard with flags for each position adjacent toposition. -
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 of100.
-