Remove unneeded code from buildSrc

This commit is contained in:
Peter Osterlund
2019-08-11 11:40:31 +02:00
parent 2a01797dfa
commit 4230847224
13 changed files with 23 additions and 2750 deletions

View File

@@ -20,99 +20,13 @@ package chess;
public class BitBoard {
/** Squares attacked by a king on a given square. */
public static final long[] kingAttacks;
public static final long[] knightAttacks;
public static final long[] wPawnAttacks, bPawnAttacks;
// Squares preventing a pawn from being a passed pawn, if occupied by enemy pawn
static final long[] wPawnBlockerMask, bPawnBlockerMask;
public static final long maskAToGFiles = 0x7F7F7F7F7F7F7F7FL;
public static final long maskBToHFiles = 0xFEFEFEFEFEFEFEFEL;
public static final long maskAToFFiles = 0x3F3F3F3F3F3F3F3FL;
public static final long maskCToHFiles = 0xFCFCFCFCFCFCFCFCL;
public static final long[] maskFile = {
0x0101010101010101L,
0x0202020202020202L,
0x0404040404040404L,
0x0808080808080808L,
0x1010101010101010L,
0x2020202020202020L,
0x4040404040404040L,
0x8080808080808080L
};
public static final long maskRow1 = 0x00000000000000FFL;
public static final long maskRow2 = 0x000000000000FF00L;
public static final long maskRow3 = 0x0000000000FF0000L;
public static final long maskRow4 = 0x00000000FF000000L;
public static final long maskRow5 = 0x000000FF00000000L;
public static final long maskRow6 = 0x0000FF0000000000L;
public static final long maskRow7 = 0x00FF000000000000L;
public static final long maskRow8 = 0xFF00000000000000L;
public static final long maskRow1Row8 = 0xFF000000000000FFL;
public static final long maskDarkSq = 0xAA55AA55AA55AA55L;
public static final long maskLightSq = 0x55AA55AA55AA55AAL;
public static final long maskCorners = 0x8100000000000081L;
static {
// Compute king attacks
kingAttacks = new long[64];
for (int sq = 0; sq < 64; sq++) {
long m = 1L << sq;
long mask = (((m >>> 1) | (m << 7) | (m >>> 9)) & maskAToGFiles) |
(((m << 1) | (m << 9) | (m >>> 7)) & maskBToHFiles) |
(m << 8) | (m >>> 8);
kingAttacks[sq] = mask;
}
// Compute knight attacks
knightAttacks = new long[64];
for (int sq = 0; sq < 64; sq++) {
long m = 1L << sq;
long mask = (((m << 6) | (m >>> 10)) & maskAToFFiles) |
(((m << 15) | (m >>> 17)) & maskAToGFiles) |
(((m << 17) | (m >>> 15)) & maskBToHFiles) |
(((m << 10) | (m >>> 6)) & maskCToHFiles);
knightAttacks[sq] = mask;
}
// Compute pawn attacks
wPawnAttacks = new long[64];
bPawnAttacks = new long[64];
wPawnBlockerMask = new long[64];
bPawnBlockerMask = new long[64];
for (int sq = 0; sq < 64; sq++) {
long m = 1L << sq;
long mask = ((m << 7) & maskAToGFiles) | ((m << 9) & maskBToHFiles);
wPawnAttacks[sq] = mask;
mask = ((m >>> 9) & maskAToGFiles) | ((m >>> 7) & maskBToHFiles);
bPawnAttacks[sq] = mask;
int x = Position.getX(sq);
int y = Position.getY(sq);
m = 0;
for (int y2 = y+1; y2 < 8; y2++) {
if (x > 0) m |= 1L << Position.getSquare(x-1, y2);
m |= 1L << Position.getSquare(x , y2);
if (x < 7) m |= 1L << Position.getSquare(x+1, y2);
}
wPawnBlockerMask[sq] = m;
m = 0;
for (int y2 = y-1; y2 >= 0; y2--) {
if (x > 0) m |= 1L << Position.getSquare(x-1, y2);
m |= 1L << Position.getSquare(x , y2);
if (x < 7) m |= 1L << Position.getSquare(x+1, y2);
}
bPawnBlockerMask[sq] = m;
}
}
private final static long[][] rTables;
private final static long[] rMasks;
private final static int[] rBits = { 12, 11, 11, 11, 11, 11, 11, 12,
@@ -277,106 +191,4 @@ public class BitBoard {
public static long rookAttacks(int sq, long occupied) {
return rTables[sq][(int)(((occupied & rMasks[sq]) * rMagics[sq]) >>> (64 - rBits[sq]))];
}
static public final long[][] squaresBetween;
static {
squaresBetween = new long[64][];
for (int sq1 = 0; sq1 < 64; sq1++) {
squaresBetween[sq1] = new long[64];
for (int j = 0; j < 64; j++)
squaresBetween[sq1][j] = 0;
for (int dx = -1; dx <= 1; dx++) {
for (int dy = -1; dy <= 1; dy++) {
if ((dx == 0) && (dy == 0))
continue;
long m = 0;
int x = Position.getX(sq1);
int y = Position.getY(sq1);
while (true) {
x += dx; y += dy;
if ((x < 0) || (x > 7) || (y < 0) || (y > 7))
break;
int sq2 = Position.getSquare(x, y);
squaresBetween[sq1][sq2] = m;
m |= 1L << sq2;
}
}
}
}
}
private static final byte dirTable[] = {
-9, 0, 0, 0, 0, 0, 0, -8, 0, 0, 0, 0, 0, 0, -7,
0, 0, -9, 0, 0, 0, 0, 0, -8, 0, 0, 0, 0, 0, -7, 0,
0, 0, 0, -9, 0, 0, 0, 0, -8, 0, 0, 0, 0, -7, 0, 0,
0, 0, 0, 0, -9, 0, 0, 0, -8, 0, 0, 0, -7, 0, 0, 0,
0, 0, 0, 0, 0, -9, 0, 0, -8, 0, 0, -7, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, -9,-17, -8,-15, -7, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,-10, -9, -8, -7, -6, 0, 0, 0, 0, 0,
0, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 1, 1, 1, 1, 1,
0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 7, 15, 8, 17, 9, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 7, 0, 0, 8, 0, 0, 9, 0, 0, 0, 0,
0, 0, 0, 0, 7, 0, 0, 0, 8, 0, 0, 0, 9, 0, 0, 0,
0, 0, 0, 7, 0, 0, 0, 0, 8, 0, 0, 0, 0, 9, 0, 0,
0, 0, 7, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 9, 0,
0, 7, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 9
};
static public final int getDirection(int from, int to) {
int offs = to + (to|7) - from - (from|7) + 0x77;
return dirTable[offs];
}
private static final byte distTable[] = {
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
0, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7,
0, 7, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 7,
0, 7, 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 6, 7,
0, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7,
0, 7, 6, 5, 4, 3, 2, 2, 2, 2, 2, 3, 4, 5, 6, 7,
0, 7, 6, 5, 4, 3, 2, 1, 1, 1, 2, 3, 4, 5, 6, 7,
0, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7,
0, 7, 6, 5, 4, 3, 2, 1, 1, 1, 2, 3, 4, 5, 6, 7,
0, 7, 6, 5, 4, 3, 2, 2, 2, 2, 2, 3, 4, 5, 6, 7,
0, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7,
0, 7, 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 6, 7,
0, 7, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 7,
0, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7,
0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
};
public static int getDistance(int from, int to) {
int offs = to + (to|7) - from - (from|7) + 0x77;
return distTable[offs];
}
public static long southFill(long mask) {
mask |= (mask >>> 8);
mask |= (mask >>> 16);
mask |= (mask >>> 32);
return mask;
}
public static long northFill(long mask) {
mask |= (mask << 8);
mask |= (mask << 16);
mask |= (mask << 32);
return mask;
}
private static final int trailingZ[] = {
63, 0, 58, 1, 59, 47, 53, 2,
60, 39, 48, 27, 54, 33, 42, 3,
61, 51, 37, 40, 49, 18, 28, 20,
55, 30, 34, 11, 43, 14, 22, 4,
62, 57, 46, 52, 38, 26, 32, 41,
50, 36, 17, 19, 29, 10, 13, 21,
56, 45, 25, 31, 35, 16, 9, 12,
44, 24, 15, 8, 23, 7, 6, 5
};
static public final int numberOfTrailingZeros(long mask) {
return trailingZ[(int)(((mask & -mask) * 0x07EDD5E59A4E28C2L) >>> 58)];
}
}