public class Bitboard extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Bitboard.AntiDiagonal
An enum type for the 15 anti-diagonals of a chess board.
|
static class |
Bitboard.Diagonal
An enum type for the 15 diagonals of a chess board.
|
static class |
Bitboard.File
An enum type for the 8 files/columns of a chess board.
|
static class |
Bitboard.Rank
An enum type for the 8 ranks/rows of a chess board.
|
static class |
Bitboard.Rays
An enum type for all the eight different rays on the chess board for each square.
|
static class |
Bitboard.Square
An enum type for the 64 squares of the chess board.
|
Modifier and Type | Field and Description |
---|---|
static long |
EMPTY_BOARD
A bitboard with none of the bits set.
|
static long |
FULL_BOARD
A bitboard with all the 64 bits set.
|
Modifier and Type | Method and Description |
---|---|
static String |
bitboardToString(long bitboard)
Returns a long in binary form aligned like a chess board with one byte per row, in a human-readable way.
|
static long |
computeBishopMoveSets(long bishops,
long allOpponentOccupied,
long allEmpty)
Generates a move set bitboard for a set of bishops.
|
static long[] |
computeBishopMoveSetVariations(long bishops,
long[] occupancyVariations)
Generates an array of bishop move set variations given an array of occupancy variations.
|
static long |
computeBishopOccupancyMasks(long bishops)
Generates an occupancy mask bitboard for a set of bishops.
|
static long |
computeBlackPawnAdvanceSets(long blackPawns,
long allEmpty)
Generates a bitboard of the basic black pawn's advance set.
|
static long |
computeBlackPawnCaptureSets(long blackPawns,
long allWhiteOccupied)
Generates a bitboard of the basic black pawn's capture set.
|
static long |
computeKingMoveSets(long king,
long allNonSameColorOccupied)
Generates a bitboard of the basic king's move set.
|
static long |
computeKnightMoveSets(long knight,
long allNonSameColorOccupied)
Generates a bitboard of the basic knight's move set.
|
static long |
computeQueenMoveSets(long queens,
long allOpponentOccupied,
long allEmpty)
Generates a move set bitboard for a set of queens.
|
static long |
computeRookMoveSets(long rooks,
long allOpponentOccupied,
long allEmpty)
Generates a move set bitboard for a set of rooks.
|
static long[] |
computeRookMoveSetVariations(long rooks,
long[] occupancyVariations)
Generates an array of rook move set variations given an array of occupancy variations.
|
static long |
computeRookOccupancyMasks(long rooks)
Generates an occupancy mask bitboard for a set of rooks.
|
static long |
computeWhitePawnAdvanceSets(long whitePawns,
long allEmpty)
Generates a bitboard of the basic white pawn's advance set.
|
static long |
computeWhitePawnCaptureSets(long whitePawns,
long allBlackOccupied)
Generates a bitboard of the basic white pawn's capture set.
|
static long |
fillEast(long generator,
long propagator)
A parallel prefix occluded fill algorithm that returns the move (non-attack) sets in direction east of multiple sliding pieces at the
same time.
|
static long |
fillNorth(long generator)
It propagates north all set bits of the bitboard all the way.
|
static long |
fillNorth(long generator,
long propagator)
A parallel prefix occluded fill algorithm that returns the move (non-attack) sets in direction north of multiple sliding pieces at the
same time.
|
static long |
fillNorthEast(long generator,
long propagator)
A parallel prefix occluded fill algorithm that returns the move (non-attack) sets in direction north-east of multiple sliding pieces at
the same time.
|
static long |
fillNorthWest(long generator,
long propagator)
A parallel prefix occluded fill algorithm that returns the move (non-attack) sets in direction north-west of multiple sliding pieces at
the same time.
|
static long |
fillSouth(long generator)
It propagates south all set bits of the bitboard all the way.
|
static long |
fillSouth(long generator,
long propagator)
A parallel prefix occluded fill algorithm that returns the move (non-attack) sets in direction south of multiple sliding pieces at the
same time.
|
static long |
fillSouthEast(long generator,
long propagator)
A parallel prefix occluded fill algorithm that returns the move (non-attack) sets in direction south-east of multiple sliding pieces at
the same time.
|
static long |
fillSouthWest(long generator,
long propagator)
A parallel prefix occluded fill algorithm that returns the move (non-attack) sets in direction south-west of multiple sliding pieces at
the same time.
|
static long |
fillWest(long generator,
long propagator)
A parallel prefix occluded fill algorithm that returns the move (non-attack) sets in direction west of multiple sliding pieces at the
same time.
|
static List<Map.Entry<Long,Byte>> |
generateAllMagics(boolean rook,
int... enhancedSquares)
Generates magic numbers for each square either for a rook or a bishop.
|
static Map.Entry<Long,Byte> |
generateMagics(int sqrInd,
boolean rook,
boolean enhanced)
Generates a magic number for the square specified either for a rook or for a bishop depending on the parameters.
|
static long |
getLineSegment(int fromSqrInd,
int toSqrInd) |
static long |
getPinnedPieces(byte kingInd,
long straightSliders,
long diagonalSliders,
long allOccupied,
long allSameColorOccupied)
Returns a bitboard of all pinned pieces.
|
static long |
getPinningPieces(byte kingInd,
long straightSliders,
long diagonalSliders,
long allOccupied,
long allSameColorOccupied)
Returns a bitboard of all pinning pieces.
|
public static final long FULL_BOARD
public static final long EMPTY_BOARD
public static long getLineSegment(int fromSqrInd, int toSqrInd)
fromSqrInd
- The origin square's index.toSqrInd
- The destination square's index.public static long fillNorth(long generator)
generator
- Piece squares.public static long fillSouth(long generator)
generator
- Piece squares.public static long fillNorth(long generator, long propagator)
generator
- Piece squares.propagator
- All empty squares.public static long fillSouth(long generator, long propagator)
generator
- Piece squares.propagator
- All empty squares.public static long fillWest(long generator, long propagator)
generator
- Piece squares.propagator
- All empty squares.public static long fillEast(long generator, long propagator)
generator
- Piece squares.propagator
- All empty squares.public static long fillNorthWest(long generator, long propagator)
generator
- Piece squares.propagator
- All empty squares.public static long fillNorthEast(long generator, long propagator)
generator
- Piece squares.propagator
- All empty squares.public static long fillSouthWest(long generator, long propagator)
generator
- Piece squares.propagator
- All empty squares.public static long fillSouthEast(long generator, long propagator)
generator
- Piece squares.propagator
- All empty squares.public static long computeKingMoveSets(long king, long allNonSameColorOccupied)
king
- The biboard for the king.allNonSameColorOccupied
- The bitboard for all squares non occupied by the same color as the king.public static long computeKnightMoveSets(long knight, long allNonSameColorOccupied)
knight
- The bitboard for the knights.allNonSameColorOccupied
- The bitboard for all squares non occupied by the same color as the knights.public static long computeWhitePawnCaptureSets(long whitePawns, long allBlackOccupied)
whitePawns
- The bitboard for the white pawns.allBlackOccupied
- The bitboard for all squares occupied by black pieces.public static long computeBlackPawnCaptureSets(long blackPawns, long allWhiteOccupied)
blackPawns
- The bitboard for the black pawns.allWhiteOccupied
- The bitboard for all squares occupied by white pieces.public static long computeWhitePawnAdvanceSets(long whitePawns, long allEmpty)
whitePawns
- The bitboard for the white pawns.allEmpty
- A bitboard for all the empty squares.public static long computeBlackPawnAdvanceSets(long blackPawns, long allEmpty)
blackPawns
- The bitboard for the black pawns.allEmpty
- A bitboard for all the empty squares.public static long computeBishopMoveSets(long bishops, long allOpponentOccupied, long allEmpty)
bishops
- The bitboard for the bishops.allOpponentOccupied
- The bitboard for all the sqaures occupied by the opponent.allEmpty
- The bitboard of all the empty squares.public static long computeRookMoveSets(long rooks, long allOpponentOccupied, long allEmpty)
rooks
- The bitboard for the rooks.allOpponentOccupied
- The bitboard for all the sqaures occupied by the opponent.allEmpty
- The bitboard of all the empty squares.public static long computeQueenMoveSets(long queens, long allOpponentOccupied, long allEmpty)
queens
- The bitboard for the queens.allOpponentOccupied
- The bitboard for all the sqaures occupied by the opponent.allEmpty
- The bitboard of all the empty squares.public static long computeBishopOccupancyMasks(long bishops)
bishops
- The bitboard for the bishops.public static long computeRookOccupancyMasks(long rooks)
rooks
- The bitboard for the rooks.public static long[] computeBishopMoveSetVariations(long bishops, long[] occupancyVariations)
bishops
- The bitboard of bishops.occupancyVariations
- An array of occupancy bitboard variations for the above bishops.public static long[] computeRookMoveSetVariations(long rooks, long[] occupancyVariations)
rooks
- The bitboard of rooks.occupancyVariations
- An array of occupancy bitboard variations for the above rooks.public static long getPinnedPieces(byte kingInd, long straightSliders, long diagonalSliders, long allOccupied, long allSameColorOccupied)
kingInd
- The index of the king.straightSliders
- A bitboard of all the queens and rooks of the opponent.diagonalSliders
- A bitboard of all the queens and bishops of the opponent.allOccupied
- A bitboard of all occupied squares.allSameColorOccupied
- A bitboard of all squares occupied by friendly pieces.public static long getPinningPieces(byte kingInd, long straightSliders, long diagonalSliders, long allOccupied, long allSameColorOccupied)
kingInd
- The index of the king.straightSliders
- A bitboard of all the queens and rooks of the opponent.diagonalSliders
- A bitboard of all the queens and bishops of the opponent.allOccupied
- A bitboard of all occupied squares.allSameColorOccupied
- A bitboard of all squares occupied by friendly pieces.public static Map.Entry<Long,Byte> generateMagics(int sqrInd, boolean rook, boolean enhanced) throws InterruptedException, ExecutionException
sqrInd
- The origin square index.rook
- Whether the magics are to be generated for a rook move set or a bishop move set.enhanced
- Whether the magic number is to work with a greater magic shift value.ExecutionException
- If something goes wrong while generating enhanced magic numbers.InterruptedException
- If the thread is interrupted while waiting for the background threads to compute the enhanced magic
numbers.public static List<Map.Entry<Long,Byte>> generateAllMagics(boolean rook, int... enhancedSquares) throws InterruptedException, ExecutionException
rook
- Whether the magics are to be generated for a rook move set or a bishop move set.enhancedSquares
- The indices of the squares for which enhanced magic numbers are to be computed.ExecutionException
- If something goes wrong while generating enhanced magic numbers.InterruptedException
- If the thread is interrupted while waiting for the background threads to compute the enhanced magic
numbers.public static String bitboardToString(long bitboard)
bitboard
- The bitboard to represent as a string.Copyright © 2020. All rights reserved.