Skip to content

Commit

Permalink
1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Senders authored and Senders committed Dec 3, 2018
1 parent 7152cbe commit 5b7e62c
Show file tree
Hide file tree
Showing 55 changed files with 1,181 additions and 1,228 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

A chessengine build in Java that uses the UCI protocol to communicate with graphical interfaces.
Should be used with a 64 bit JRE for optimal performance.
The binaries are build using Java 10 and are not compatible with older Java versions.
Score is about 3025 elo (CCRL 40/4).
The binaries are build using Java 11 and are not compatible with older Java versions.
Score is about 3100 elo (CCRL 40/4).

## Features
- (magic) bitboards
- transposition tables
- (internal) iterative-deepening
- killer-moves and history-heuristics for move ordering
- killer/counter-moves and history-heuristics for move ordering
- principal variation search
- (static) null move pruning
- razoring
- late move reductions and pruning
- futility pruning
- static exchange evaluation for move ordering and pruning
- static exchange evaluation pruning
- aspiration window
- evaluation parameters tuned using the Texel's tuning method
- tapered eval
Expand All @@ -25,7 +25,9 @@ Score is about 3025 elo (CCRL 40/4).


## Future
- improved SMP
- singular extensions
- syzygy
- improved king safety
- ...

Expand Down
Binary file added logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 4 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!-- artifactId>${engineName}</artifactId -->
<artifactId>chess22k</artifactId>

<version>1.11</version>
<version>1.12</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -42,14 +42,13 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.10</source>
<target>1.10</target>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openclover</groupId>
<artifactId>clover-maven-plugin</artifactId>
<version>4.2.1</version>
<version>4.3.1</version>
</plugin>
</plugins>
</build>
Expand All @@ -63,7 +62,7 @@
<dependency>
<groupId>org.openclover</groupId>
<artifactId>clover-maven-plugin</artifactId>
<version>4.2.1</version>
<version>4.3.1</version>
</dependency>
</dependencies>

Expand Down
31 changes: 21 additions & 10 deletions release-notes.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
1.11 - 05-09-2018 - 3025 elo
1.12 - 03-12-2018 - 3100 elo
- participated in CSVN 54
- rewritten SMP implementation (inspired by Laser, performs worse than 1.11 at the moment...)
- added some endgame knowledge
- implemented counter move heuristic
- improved LMR reductions calculation (inspired by Ethereal)


1.11 - 05-09-2018 - 3030 elo
- participated in TCEC S14
- implemented pondering
- improved SMP
- SEE pruning
- split-up several evaluation terms in midgame and endgame
- split-up more evaluation terms in midgame and endgame
- better space evaluation (idea by Laser)


1.10 - 09-07-2018 - 3000 elo
- participated in TCEC S13
- lazy SMP
- several simplifications and small updates


1.9 - 23-04-2018 - 3000 elo
1.9 - 23-04-2018 - 2970 elo
- participated in CSVN 53
- fixed some crashes
- improved sorting efficiency
- calculation instead of lookups for pawn move generation
Expand Down Expand Up @@ -56,7 +67,8 @@
- split-up methods into smaller ones for better inlining (suggested by JITWatch)


1.6 - 03-11-2017 - 2800 elo
1.6 - 03-11-2017 - 2850 elo
- participated CSVN 52
- more accurate SEE (pinned pieces)
- improved king safety
- added some eval terms
Expand All @@ -69,7 +81,7 @@
- fixed some crashes


1.5 - 12-08-2017 - 2700 elo
1.5 - 12-08-2017 - 2750 elo
- implemented tapered-eval
- recognize drawish positions
- added more evaluation terms to the texel-tuner
Expand All @@ -82,10 +94,9 @@
- safe mobility for knights and rooks
- small king-safety updates
- small passed-pawn updates
- ...


1.4 - 18-06-2017 - 2600 elo
1.4 - 18-06-2017 - 2650 elo
- tuned evaluation values using the Texel's tuning method
- implemented futility pruning
- small tweaks
Expand All @@ -102,7 +113,7 @@
- fixed some engine crashes


1.2 - 19-03-2017 - 2400 elo, this time for real? :P
1.2 - 19-03-2017 - 2400 elo
- improved passed-pawn scoring in endgames
- added time to UCI output
- improved time control: x moves in y minutes
Expand All @@ -112,15 +123,15 @@
- bugs, again ;)


1.1 - 09-02-2017 - 2400 elo
1.1 - 09-02-2017 - 2300 elo
- re-enabled mobility evaluation
- knight outposts
- implemented king safety (using Ed Schroders idea), but disabled for the moment
- check-aware quiescence-search
- bug fixes, of course


1.0 - 13-01-2017 - 2300 elo
1.0 - 13-01-2017 - 2200 elo
- (magic) bitboards
- transposition table
- (internal) iterative-deepening
Expand Down
59 changes: 44 additions & 15 deletions src/main/java/nl/s22k/chess/Bitboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,16 @@ public class Bitboard {
public static final long F8_G8 = F8 | G8;
public static final long F8_H8 = F8 | H8;
public static final long G8_H8 = G8 | H8;
public static final long A1_B1_C1 = A1 | B1 | C1;
public static final long B1_C1_D1 = B1 | C1 | D1;
public static final long F1_G1_H1 = F1 | G1 | H1;
public static final long A8_B8_C8 = A8 | B8 | C8;
public static final long B8_C8_D8 = B8 | C8 | D8;
public static final long F8_G8_H8 = F8 | G8 | H8;
public static final long A1_B1_A2_B2 = A1 | B1 | A2 | B2;
public static final long D1_E1_D2_E2 = D1 | E1 | D2 | E2;
public static final long G1_H1_G2_H2 = G1 | H1 | G2 | H2;
public static final long D7_E7_D8_E8 = D7 | E7 | D8 | E8;
public static final long A7_B7_A8_B8 = A7 | B7 | A8 | B8;
public static final long G7_H7_G8_H8 = G7 | H7 | G8 | H8;
public static final long A1B1C1 = A1 | B1 | C1;
public static final long B1C1D1 = B1 | C1 | D1;
public static final long A8B8C8 = A8 | B8 | C8;
public static final long B8C8D8 = B8 | C8 | D8;
public static final long A1B1A2B2 = A1 | B1 | A2 | B2;
public static final long D1E1D2E2 = D1 | E1 | D2 | E2;
public static final long G1H1G2H2 = G1 | H1 | G2 | H2;
public static final long D7E7D8E8 = D7 | E7 | D8 | E8;
public static final long A7B7A8B8 = A7 | B7 | A8 | B8;
public static final long G7H7G8H8 = G7 | H7 | G8 | H8;
public static final long WHITE_SQUARES = 0xaa55aa55aa55aa55L;
public static final long BLACK_SQUARES = ~WHITE_SQUARES;
public static final long CORNER_SQUARES = A1 | H1 | A8 | H8;
Expand Down Expand Up @@ -153,14 +151,26 @@ public class Bitboard {
public static final long FILE_F = F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8;
public static final long FILE_G = G1 | G2 | G3 | G4 | G5 | G6 | G7 | G8;
public static final long FILE_H = H1 | H2 | H3 | H4 | H5 | H6 | H7 | H8;
public static final long FILE_D_E = FILE_D | FILE_E;
public static final long FILE_CDEF = FILE_C | FILE_D| FILE_E | FILE_F;
public static final long FILE_ABC = FILE_A | FILE_B | FILE_C;
public static final long FILE_FGH = FILE_F | FILE_G | FILE_H;
public static final long FILE_CDEF = FILE_C | FILE_D | FILE_E | FILE_F;
public static final long NOT_FILE_A = ~FILE_A;
public static final long NOT_FILE_H = ~FILE_H;

// special
public static final long WHITE_CORNERS = 0xf8f0e0c183070f1fL;
public static final long BLACK_CORNERS = 0x1f0f0783c1e0f0f8L;

public static final long RANKS[] = { RANK_1, RANK_2, RANK_3, RANK_4, RANK_5, RANK_6, RANK_7, RANK_8 };
public static final long FILES[] = { FILE_H, FILE_G, FILE_F, FILE_E, FILE_D, FILE_C, FILE_B, FILE_A };
public static final long FILES_ADJACENT[] = { FILE_G, FILE_H | FILE_F, FILE_G | FILE_E, FILE_F | FILE_D, FILE_E | FILE_C, FILE_D | FILE_B, FILE_C | FILE_A,
public static final long FILES_ADJACENT[] = { //
FILE_G, //
FILE_H | FILE_F, //
FILE_G | FILE_E, //
FILE_F | FILE_D, //
FILE_E | FILE_C, //
FILE_D | FILE_B, //
FILE_C | FILE_A, //
FILE_B };

public static final long KING_SIDE = FILE_F | FILE_G | FILE_H;
Expand Down Expand Up @@ -195,4 +205,23 @@ public static int manhattanCenterDistance(int sq) {
return (file + rank) & 7;
}

public static long getWhitePassedPawnMask(final int index) {
return (FILES[index & 7] | FILES_ADJACENT[index & 7]) << ((index >>> 3 << 3) + 8);
}

public static long getBlackPassedPawnMask(final int index) {
if (index < 8) {
return 0;
}
return (FILES[index & 7] | FILES_ADJACENT[index & 7]) >>> ((71 - index) >>> 3 << 3);
}

public static long getWhiteAdjacentMask(final int index) {
return getWhitePassedPawnMask(index) & ~FILES[index & 7];
}

public static long getBlackAdjacentMask(final int index) {
return getBlackPassedPawnMask(index) & ~FILES[index & 7];
}

}
21 changes: 14 additions & 7 deletions src/main/java/nl/s22k/chess/CastlingUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public final class CastlingUtil {

// 4 bits: white-king,white-queen,black-king,black-queen
public static long getCastlingIndexes(final ChessBoard cb) {
if (cb.castlingRights == 0) {
return 0;
}
if (cb.colorToMove == WHITE) {
switch (cb.castlingRights) {
case 0:
Expand Down Expand Up @@ -91,44 +94,48 @@ public static long getRookInBetweenIndex(final int castlingIndex) {
case 1:
return Bitboard.F1_G1;
case 5:
return Bitboard.B1_C1_D1;
return Bitboard.B1C1D1;
case 57:
return Bitboard.F8_G8;
case 61:
return Bitboard.B8_C8_D8;
return Bitboard.B8C8D8;
}
throw new RuntimeException("Incorrect castling-index: " + castlingIndex);
}

public static void uncastleRook(final ChessBoard cb, final int kingToIndex) {
public static void uncastleRookUpdatePsqt(final ChessBoard cb, final int kingToIndex) {
switch (kingToIndex) {
case 1:
// white rook from 2 to 0
cb.pieces[cb.colorToMoveInverse][ROOK] ^= Bitboard.F1_H1;
cb.friendlyPieces[cb.colorToMoveInverse] ^= Bitboard.F1_H1;
cb.pieceIndexes[2] = EMPTY;
cb.pieceIndexes[0] = ROOK;
cb.psqtScore += EvalConstants.PSQT[ROOK][cb.colorToMoveInverse][0] - EvalConstants.PSQT[ROOK][cb.colorToMoveInverse][2];
return;
case 57:
// black rook from 58 to 56
cb.pieces[cb.colorToMoveInverse][ROOK] ^= Bitboard.F8_H8;
cb.friendlyPieces[cb.colorToMoveInverse] ^= Bitboard.F8_H8;
cb.pieceIndexes[58] = EMPTY;
cb.pieceIndexes[56] = ROOK;
cb.psqtScore += EvalConstants.PSQT[ROOK][cb.colorToMoveInverse][56] - EvalConstants.PSQT[ROOK][cb.colorToMoveInverse][58];
return;
case 5:
// white rook from 4 to 7
cb.pieces[cb.colorToMoveInverse][ROOK] ^= Bitboard.A1_D1;
cb.friendlyPieces[cb.colorToMoveInverse] ^= Bitboard.A1_D1;
cb.pieceIndexes[4] = EMPTY;
cb.pieceIndexes[7] = ROOK;
cb.psqtScore += EvalConstants.PSQT[ROOK][cb.colorToMoveInverse][7] - EvalConstants.PSQT[ROOK][cb.colorToMoveInverse][4];
return;
case 61:
// black rook from 60 to 63
cb.pieces[cb.colorToMoveInverse][ROOK] ^= Bitboard.A8_D8;
cb.friendlyPieces[cb.colorToMoveInverse] ^= Bitboard.A8_D8;
cb.pieceIndexes[60] = EMPTY;
cb.pieceIndexes[63] = ROOK;
cb.psqtScore += EvalConstants.PSQT[ROOK][cb.colorToMoveInverse][63] - EvalConstants.PSQT[ROOK][cb.colorToMoveInverse][60];
return;
}
throw new RuntimeException("Incorrect king castling to-index: " + kingToIndex);
Expand All @@ -142,7 +149,7 @@ public static void castleRookUpdateKeyAndPsqt(final ChessBoard cb, final int kin
cb.friendlyPieces[cb.colorToMove] ^= Bitboard.F1_H1;
cb.pieceIndexes[0] = EMPTY;
cb.pieceIndexes[2] = ROOK;
cb.zobristKey ^= ChessBoard.zkPieceValues[0][WHITE][ROOK] ^ ChessBoard.zkPieceValues[2][WHITE][ROOK];
cb.zobristKey ^= Zobrist.piece[0][WHITE][ROOK] ^ Zobrist.piece[2][WHITE][ROOK];
cb.psqtScore += EvalConstants.PSQT[ROOK][cb.colorToMove][2] - EvalConstants.PSQT[ROOK][cb.colorToMove][0];
return;
case 57:
Expand All @@ -151,7 +158,7 @@ public static void castleRookUpdateKeyAndPsqt(final ChessBoard cb, final int kin
cb.friendlyPieces[cb.colorToMove] ^= Bitboard.F8_H8;
cb.pieceIndexes[56] = EMPTY;
cb.pieceIndexes[58] = ROOK;
cb.zobristKey ^= ChessBoard.zkPieceValues[56][BLACK][ROOK] ^ ChessBoard.zkPieceValues[58][BLACK][ROOK];
cb.zobristKey ^= Zobrist.piece[56][BLACK][ROOK] ^ Zobrist.piece[58][BLACK][ROOK];
cb.psqtScore += EvalConstants.PSQT[ROOK][cb.colorToMove][58] - EvalConstants.PSQT[ROOK][cb.colorToMove][56];
return;
case 5:
Expand All @@ -160,7 +167,7 @@ public static void castleRookUpdateKeyAndPsqt(final ChessBoard cb, final int kin
cb.friendlyPieces[cb.colorToMove] ^= Bitboard.A1_D1;
cb.pieceIndexes[7] = EMPTY;
cb.pieceIndexes[4] = ROOK;
cb.zobristKey ^= ChessBoard.zkPieceValues[7][WHITE][ROOK] ^ ChessBoard.zkPieceValues[4][WHITE][ROOK];
cb.zobristKey ^= Zobrist.piece[7][WHITE][ROOK] ^ Zobrist.piece[4][WHITE][ROOK];
cb.psqtScore += EvalConstants.PSQT[ROOK][cb.colorToMove][4] - EvalConstants.PSQT[ROOK][cb.colorToMove][7];
return;
case 61:
Expand All @@ -169,7 +176,7 @@ public static void castleRookUpdateKeyAndPsqt(final ChessBoard cb, final int kin
cb.friendlyPieces[cb.colorToMove] ^= Bitboard.A8_D8;
cb.pieceIndexes[63] = EMPTY;
cb.pieceIndexes[60] = ROOK;
cb.zobristKey ^= ChessBoard.zkPieceValues[63][BLACK][ROOK] ^ ChessBoard.zkPieceValues[60][BLACK][ROOK];
cb.zobristKey ^= Zobrist.piece[63][BLACK][ROOK] ^ Zobrist.piece[60][BLACK][ROOK];
cb.psqtScore += EvalConstants.PSQT[ROOK][cb.colorToMove][60] - EvalConstants.PSQT[ROOK][cb.colorToMove][63];
return;
}
Expand Down
Loading

0 comments on commit 5b7e62c

Please sign in to comment.