Bagatur

Java Chess Engine

View on GitHub

Bagatur logo

Overview

Bagatur is one of the strongest Java chess engines in the world.

It runs both on Android and on desktop computers (including virtual machines with many CPU cores in the cloud):

If you like the project, please give it a star! :-)

Downloads (desktop)

Running it

Bagatur runs on every operating system with a Java platform:

UCI Options

SMP-only options

These apply only to the SMP (multi-core) version. On Windows it is started by Bagatur_64_2+_cores.exe or Bagatur_mcore.bat; on Linux by Bagatur_mcore.sh. SMP has been tested with up to 64 CPU cores / threads. There is a known JVM-related scaling limitation — more details in Search/SMP.scaling.issue.txt.

Options available in both single-core and SMP

Syzygy Endgame Tablebases

The Bagatur distribution bundles a subset of Syzygy tablebases under ./data/egtb/ — 22 of the most common endgames with up to 5 pieces. The SyzygyPath UCI option points there by default. Change it if you have a fuller or larger Syzygy set installed elsewhere.

NNUE (Efficiently Updatable Neural Network)

Since version 5.0, Bagatur uses NNUE as its evaluation function. The Java port lives in its own subproject — see NNUE/.

Elo Rating

A chess engine’s strength is measured in Elo.

According to CCRL 40/15, the latest official Elo ratings of every well-tested version (with more than 300 games at 40/15 time control) are listed on this page: CCRL — Bagatur family.

Special thanks to Graham Banks, who has put tremendous effort into testing Bagatur versions over the years!

The latest official Elo rating of Bagatur is ~3400 Elo.

Technical details — sub-component documentation

When and how the Bagatur Chess Engine project started

The project started as a bet between me and one of my friends from my first two years at university — he liked to play chess, and I could not win a single game against him. Over time this made me restless, and eventually I promised him (we shook on it) that I would write a chess program that would beat him.

Luckily for me, no time frame was agreed on, and… years later, I won the bet! :-) The whole story is captured in this YouTube video: “How was the idea of Bagatur Chess Engine application born?”.

The first public, open-source version of Bagatur was released on 2011-02-27 and is still available here. The project itself, however, started about 10 years earlier — somewhere between 1999 and 2000. It went through many private, non-public versions until 2011 (I do not even have their history any more). The early versions were very weak: they would make 2-3 moves and then crash. I spent hours and days hunting bugs and trying to understand why things did not work.

At that time the internet was almost empty, and I had no idea that software like CuteChess or Arena even existed, nor that there was a UCI protocol — so I also wrote my own graphical user interface, in Java AWT and Swing. Chess programming exposes you to a wide range of programming disciplines.

I picked Java mostly because of my (limited) experience with it. It also helps that Java was rather modern and popular at the time — only a few years after its first release, the early days of the Java language and the Java ecosystem.

So, if you are planning to write a chess engine: better start early — it takes time to reach a stable version that can beat you. :-)

Contact the author

You can reach me on LinkedIn: Krasimir Topchiyski — or by email at k_topchiyski@yahoo.com.

Some personal thoughts

According to CCRL, there are fewer than ~500 chess engines in the world. That means there are not that many people genuinely interested in chess-engine programming. The author of a chess engine has typically to be interested not only in programming but also in chess itself — and willing to invest a lot of spare time without any incentive, just for fun and curiosity. For that reason, I am always happy to see new engines and new authors appear!

I cannot speak for other authors, but I would also recommend a small, well-measured dose of craziness. It helps. As you release version after version, each release aiming for a higher Elo, sometimes you get stuck — sometimes for months — and it starts to feel like banging your head against a wall. When I reach that state, I step away from Bagatur for a while and wait for inspiration to come back. Always remember: it should be for fun! :-)

Bagatur is powered by YourKit Java Profiler

YourKit Logo

This excellent tool is used to find and fix performance, scalability, and memory-allocation issues. YourKit supports open-source projects with innovative and intelligent tools for monitoring and profiling.

Bagatur flavours

The chess engine JFish uses Bagatur as its base and plugs in the Stockfish NNUE as its evaluation function. The goal is to have the strongest Java chess engine as a reference.

Revision history

The full release history is collected here.

Credits

Fortunately, I am not alone on this project — without the ideas, support, and help from many people and websites, Bagatur would not be what it is today. Many thanks to:

  1. My wife and my family, because every now and then I have been borrowing time from our leisure to work on this project.
  2. Serendipity — thanks to Shawn for explaining how he trained the NNUE network of the Serendipity chess engine, and for the reference Java code that handles the network.
  3. Desislava Chocheva, for her hospitality and willingness to help. Without her support the introductory video could not have happened.
  4. Ivo Zhekov, for motivating me to start this project and for accepting the challenge with such a strong opponent in front of the camera.
  5. Simeon Stoichkov, for his general support on chess topics in Bulgaria, and for providing the chess pieces and the chess clock used in the introductory video.
  6. Varna Sound, for their willingness to support us and to contribute with their great rap music.
  7. Iavor Stoimenov, for the endless discussions about chess topics and chess engines.
  8. Ivo Simeonov, for all the ideas, support, discussions, tests, and contributed source code (e.g. the initial version of pawn-structure evaluation, the C porting, and the .exe launcher).
  9. Graham Banks from the Computer Chess Rating Lists (CCRL) — see also CCRL 40/40 — for organising and broadcasting chess-engine tournaments over the internet for many years.
  10. Anton Mihailov, Aloril, and Kan from the Top Chess Engine Championship (TCEC), for their invitations to Bagatur and for its participation in chess-engine tournaments for many seasons. Special thanks to Aloril, who contributed a lot to the testing of Bagatur’s Symmetric Multiprocessing (SMP) version on a CentOS box with more than 100 CPU cores. Thanks a lot for your support whenever engine issues / bugs surfaced!
  11. Olivier Deville, for his great support during ChessWar XVII — open-aurec.com/chesswar.
  12. Zoran Sevarac, author of Neuroph and co-author of Deep Netts, for his great support with our experiments on Neural Networks and Machine Learning in Java.
  13. Roelof Berkepeis, for testing, for sharing his chess experience, and for the great ideas captured as issues on the Bagatur GitHub page.
  14. Sameer Sehrawala, for the latest logo and his general support.
  15. Dusan Stamenkovic (chessmosaic.com), for several earlier Bagatur logos.
  16. The Internet itself, for connecting us.
  17. The Open Source community!
  18. The MTD(f) algorithm — Bagatur’s parallel search is based on this idea.
  19. winrun4j, for the Windows executables.
  20. All UCI-compatible GUIs, and the UCI protocol itself.
  21. REBEL — a very helpful web page.
  22. The Glaurung chess engine, for nice ideas inside its evaluation function (e.g. king safety).
  23. Fruit, the legendary program with a beautifully clean and simple design.
  24. CuckooChess, one of the first Java chess engines.
  25. Chess22k, an exciting Java chess engine — strong and well written.
  26. The source code of the strongest open-source chess engine — Stockfish.
  27. SourceForge.
  28. GitHub.
  29. Stack Overflow.
  30. … and many others!