|
| 1 | +<div align="center"> |
| 2 | + |
| 3 | + # Serendipity |
| 4 | + |
| 5 | +</div> |
| 6 | + |
| 7 | +Serendipity is a UCI chess engine written in the Java programming language. With a CCRL rating of more than 3500 elo, it is the strongest Java chess engine in the world. |
| 8 | + |
| 9 | +### History |
| 10 | + |
| 11 | +In early January 2024, I was inspired by a [tom7 video][elo_world] to create a [chess arena][chess_arena] in Java. |
| 12 | +It didn't get very far, however, as I soon focused all my development effort in a minimax implementation. |
| 13 | + |
| 14 | +In March, I began to work on NNUE support. |
| 15 | +After completing NNUE, the strength of Serendipity skyrocketed, I had several commits with gains of over 100 Elo. |
| 16 | +On March 27, I published my [first release][first_release]. The results were much better than I had expected, as it turns out that I have |
| 17 | +vastly underestimated Serendipity's strength. Two days later, I made my first Stockfish commit. |
| 18 | + |
| 19 | +In May, four other engine developers and I co-founded an [OpenBench][openbench_url] instance, where Serendipity testing happens to this day. |
| 20 | + |
| 21 | +In August, I implemented multithreading for Serendipity's first debut Top Chess Engines Championship. |
| 22 | + |
| 23 | +#### Timeline |
| 24 | + |
| 25 | +- January 9, 2024: First commit to arena project |
| 26 | +- January 12, 2024: First main repo commit |
| 27 | +- March 10, 2024: NNUE support |
| 28 | +- March 27, 2024: First release of Serendipity |
| 29 | +- May 24, 2024: OpenBench instance founded |
| 30 | +- August 23, 2024: Multithreading support |
| 31 | +- August 26, 2024: TCEC Debut |
| 32 | + |
| 33 | +### Strength |
| 34 | + |
| 35 | +As of November 2024, Serendipity is the strongest Java engine in the world and around top 50 overall. |
| 36 | + |
| 37 | +<div align="center"> |
| 38 | + |
| 39 | +| Version | [CCRL Blitz][ccrl-blitz] | [CCRL 40/15][ccrl-4040] | |
| 40 | +|:-------:|:------------------------:|:-----------------------:| |
| 41 | +| v0.1 | - | 3227 | |
| 42 | +| v0.2 | 3411 | - | |
| 43 | +| v0.3 | - | 3390 | |
| 44 | +| v0.4 | 3518 | 3446 | |
| 45 | + |
| 46 | +</div> |
| 47 | + |
| 48 | +### Build |
| 49 | + |
| 50 | +To build Serendipity from source, install [`maven`][maven_url], [`make`][make_url], [`git`][git_url] and [`wget`][wget_url]. Then run the following: |
| 51 | + |
| 52 | +```bash |
| 53 | +git clone [email protected]:xu-shawn/Serendipity.git |
| 54 | +cd Serendipity |
| 55 | +make |
| 56 | +``` |
| 57 | + |
| 58 | +This will produce two versions of Serendipity executable: `Serendipity-Dev` and `Serendipity.jar`. |
| 59 | + |
| 60 | +`Serendipity-Dev` is a standalone executable that can be run on Linux or MacOS directly. |
| 61 | + |
| 62 | +`Serendipity.jar` is cross platform, but it requires extra commands to run. See section below for more details. |
| 63 | + |
| 64 | +### Run |
| 65 | + |
| 66 | +Serendipity only supports Java version 17 or higher due to its dependency on Java's (incubating) [Vector API][vector_api]. To run `Serendipity.jar`: |
| 67 | + |
| 68 | +``` |
| 69 | +java -jar --add-modules jdk.incubator.vector Serendipity.jar |
| 70 | +``` |
| 71 | + |
| 72 | +Alternatively, if you are on Linux/MacOS, you can also opt to run the Serendipity executable file: |
| 73 | + |
| 74 | +``` |
| 75 | +./Serendipity |
| 76 | +``` |
| 77 | + |
| 78 | +### Search |
| 79 | + |
| 80 | +- Efficiency |
| 81 | + - Iterative Deepening |
| 82 | + - Aspiration Windows |
| 83 | + - Principle Variation Search (PVS) |
| 84 | + - Transposition Table |
| 85 | + - Shared Transposition Table |
| 86 | + - 10-byte entries |
| 87 | + - Parallel array implementation |
| 88 | +- Multithreading |
| 89 | + - Lazy SMP |
| 90 | +- Move Ordering |
| 91 | + - Butterfly History |
| 92 | + - Capture History |
| 93 | + - Continuation Histories |
| 94 | + - 1-ply Continuation History |
| 95 | + - 2-ply Continuation History |
| 96 | + - 4-ply Continuation History |
| 97 | + - 6-ply Continuation History |
| 98 | + - Ordering of Captures by Static Exchange Evaluation (SEE) |
| 99 | +- Selectivity |
| 100 | + - Quiescent Search (QS) |
| 101 | + - QS SEE Pruning |
| 102 | + - QS Futility Pruning |
| 103 | + - Extensions |
| 104 | + - Singular Extensions |
| 105 | + - 1-ply Extension of PV Nodes |
| 106 | + - 2-ply Extension of Non-PV Nodes |
| 107 | + - Pruning |
| 108 | + - Before Moves Loop |
| 109 | + - Null Move Pruning |
| 110 | + - Reverse Futility Pruning |
| 111 | + - Razoring |
| 112 | + - Moves Loop Prunings |
| 113 | + - Futility Pruning |
| 114 | + - PVS SEE Pruning |
| 115 | + - Multi-cut Pruning |
| 116 | + - Reductions |
| 117 | + - Late Move Reductions |
| 118 | + - Internal Iterative Reductions |
| 119 | + |
| 120 | +### Evaluation |
| 121 | + |
| 122 | +Serendipity relies on a side-relative and efficiently updatable neural network for evaluation. |
| 123 | +This allows the network to be efficently updated between moves, which helps the engine obtain good evaluation with reasonable speed. |
| 124 | + |
| 125 | +The description of the network architecture, as well as the training procedure, is beyond the scope of this document. |
| 126 | + |
| 127 | +### Acknowledgements |
| 128 | + |
| 129 | +Big shoutout to everyone who has [contributed][contributors_url] ideas or code to this project. |
| 130 | + |
| 131 | +Serendipity depends on the following libraries: |
| 132 | +- [`chesslib`][chesslib_url] for move generation and board representation |
| 133 | +- [`JUnit`][JUnit_url] for testing critical components of the engine |
| 134 | + |
| 135 | +Serendipity's neural network is trained on open data generously provided by the [Leela Chess Zero][lc0_url] project. |
| 136 | + |
| 137 | +Testing Serendipity requires thosands of hours of compute, so thanks to everyone on our [OpenBench instance][furybench_url] for their contributions, however big or small. |
| 138 | +The names of these people are listed below, by alphabetical order: |
| 139 | +- [ArjunBasandrai][ArjunBasandrai] |
| 140 | +- [aronpetko][aronpetko] |
| 141 | +- [gab8192][gab8192] |
| 142 | +- [Haxk20][Haxk20] |
| 143 | +- [Jochengehtab][Jochengehtab] |
| 144 | +- [noobpwnftw][noobpwnftw] |
| 145 | +- Styxdoto |
| 146 | +- [Vast342][Vast342] |
| 147 | +- [Witek902][Witek902] |
| 148 | +- [yl25946][yl25946] |
| 149 | +- [Yoshie2000][Yoshie2000] |
| 150 | + |
| 151 | +Thanks to engine testers such as CCRL and Silvian Rucsandescu for running and testing the engine. |
| 152 | + |
| 153 | +Finally, thanks to everyone on the [Stockfish Discord][sf_discord], [Engine Programming Discord][ep_discord], and the unofficial [CPW Discord][cpw_discord] for being kind, knowledgable, and collaborative. |
| 154 | + |
| 155 | +[elo_world]: https://www.youtube.com/watch?v=DpXy041BIlA |
| 156 | +[chess_arena]: https://github.com/xu-shawn/SimplerChessEngine |
| 157 | +[first_release]: https://github.com/xu-shawn/Serendipity/releases/tag/v0.1 |
| 158 | +[openbench_url]: https://github.com/AndyGrant/OpenBench |
| 159 | + |
| 160 | +[maven_url]: https://maven.apache.org/ |
| 161 | +[make_url]: https://www.gnu.org/software/make/ |
| 162 | +[git_url]: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git |
| 163 | +[wget_url]: https://www.gnu.org/software/wget/ |
| 164 | + |
| 165 | +[vector_api]: https://docs.oracle.com/en/java/javase/17/docs/api/jdk.incubator.vector/jdk/incubator/vector/Vector.html |
| 166 | + |
| 167 | +[ccrl-blitz]: https://www.computerchess.org.uk/ccrl/404/cgi/compare_engines.cgi?family=Serendipity&print=Rating+list |
| 168 | +[ccrl-4040]: https://www.computerchess.org.uk/ccrl/4040/cgi/compare_engines.cgi?family=Serendipity&print=Rating+list |
| 169 | + |
| 170 | +[contributors_url]: https://github.com/xu-shawn/Serendipity/graphs/contributors |
| 171 | +[chesslib_url]: https://github.com/bhlangonijr/chesslib |
| 172 | +[JUnit_url]: https://github.com/junit-team/junit5 |
| 173 | +[lc0_url]: https://lczero.org/ |
| 174 | +[furybench_url]: https://chess.aronpetkovski.com/ |
| 175 | + |
| 176 | +[ArjunBasandrai]: https://github.com/ArjunBasandrai |
| 177 | +[aronpetko]: https://github.com/aronpetko |
| 178 | +[gab8192]: https://github.com/gab8192 |
| 179 | +[Haxk20]: https://github.com/Haxk20 |
| 180 | +[Jochengehtab]: https://github.com/Jochengehtab |
| 181 | +[noobpwnftw]: https://github.com/noobpwnftw |
| 182 | +[Vast342]: https://github.com/Vast342 |
| 183 | +[Witek902]: https://github.com/Witek902 |
| 184 | +[yl25946]: https://github.com/yl25946 |
| 185 | +[Yoshie2000]: https://github.com/Yoshie2000 |
| 186 | + |
| 187 | +[sf_discord]: https://discord.com/invite/GWDRS3kU6R |
| 188 | +[ep_discord]: https://discord.com/invite/F6W6mMsTGN |
| 189 | +[cpw_discord]: https://discord.gg/kWDrFSB2GG |
0 commit comments