mirror of
https://github.com/OMGeeky/hcsalmon1-Chess-Engine-Test.git
synced 2025-12-27 22:57:45 +01:00
Add files via upload
This commit is contained in:
74
Java/Bitboard.java
Normal file
74
Java/Bitboard.java
Normal file
@@ -0,0 +1,74 @@
|
||||
import java.math.BigInteger;
|
||||
|
||||
public class Bitboard
|
||||
{
|
||||
|
||||
public static BigInteger addBit(BigInteger bitboard, int square)
|
||||
{
|
||||
return bitboard.setBit(square);
|
||||
}
|
||||
|
||||
public static void printBigInteger(BigInteger bitboard)
|
||||
{
|
||||
for (int rank = 0; rank < 8; rank++)
|
||||
{
|
||||
for (int file = 0; file < 8; file++)
|
||||
{
|
||||
int square = rank * 8 + file;
|
||||
processSquare(bitboard, square);
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
System.out.println("BigInteger: " + bitboard);
|
||||
}
|
||||
|
||||
static void processSquare(BigInteger bitboard, int square)
|
||||
{
|
||||
if (bitboard.testBit(square))
|
||||
{
|
||||
System.out.print("X ");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.print("_ ");
|
||||
}
|
||||
}
|
||||
|
||||
static int bitScanForwardSlow(BigInteger bitboard)
|
||||
{
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
if (bitboard.testBit(i))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void printLong(long input)
|
||||
{
|
||||
for (int rank = 0; rank < 8; rank++)
|
||||
{
|
||||
for (int file = 0; file < 8; file++)
|
||||
{
|
||||
int square = rank * 8 + file;
|
||||
processSquareLong(input, square);
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
System.out.println("long: " + input);
|
||||
}
|
||||
|
||||
static void processSquareLong(long bitboard, int square)
|
||||
{
|
||||
if ((bitboard & MoveConstants.SQUARE_BBS[square]) != 0)
|
||||
{
|
||||
System.out.print("X ");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.print("_ ");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user