Chess engines

Here I have collected the chess engines I have created as a hobby. For those who have never encountered this particular type of software, chess engines are programs capable of analyzing a position on the chessboard and identifying the most promising moves, evaluating their possible consequences. Unlike a human player, a chess engine systematically explores a large number of variations and uses algorithms and evaluation functions to select the continuation it considers best.

Chess engines are generally not standalone programs with their own graphical user interface. Instead, they are loaded into dedicated interfaces, such as Arena, which display the chessboard, manage games, and communicate with the engine through standard protocols such as UCI. This makes it possible to use, compare, and have different engines play against one another, even when they have been developed by different authors.

Index

  1. Naraku
  2. Musashi
  3. Downloads

Naraku 1.4

Naraku is a chess program that I started way back in 2009 and worked on for about two years as a hobby project to learn C, which at the time I thought would be a useful addition to my skills as a chemical engineer. It was based on various algorithms that at the time appeared to be freeware or publicly available, including, in part, the controversial freeware program Ippolit. Its playing strength is estimated at around 2700–2750 Elo on a modern standard notebook.

I no longer have the program’s source code, but I can summarize its main features here:

  • Like the vast majority of chess engines, it uses a Negamax algorithm (a variant of Minimax) with alpha-beta pruning.
  • It employs several pruning and search heuristics, including Null Move Pruning, Late Move Reductions, aspiration windows, futility pruning, and history pruning.
  • In the later versions, I implemented the use of bitboards, although only partially and probably with a few bugs.
  • The earliest versions used a three-stage positional evaluation (opening, middlegame, and endgame), which was later reduced to two stages after I found that the two-phase version was actually stronger.
  • The evaluation function included material balance, piece-square tables (PSTs), mobility, king safety, as well as numerous positional terms (bishop pair, passed and protected pawns, rook on the seventh rank, etc.) and integrated tables for some of the most important endgames.
  • The program could have its playing strength reduced up to around 1000 Elo by modifying or perturbing the evaluation weights and disabling some of its features.

To tune the weights of the evaluation function, I developed my own dedicated tool, which optimized the weights using an evolutionary algorithm that I jokingly called Highlander (“There can be only one”).

Highlander, the tuning algorithm

Broadly speaking, the algorithm worked as follows: dozens of variants of Naraku were pitted against each other, with their evaluation weights randomly modified using a Monte Carlo approach within a certain range determined by the value of each weight. Weights with larger values were allowed to vary within a wider range. The original “parent” program also took part in the matches.

After a large number of ultra-fast games, the program with the highest score advanced to the next generation. All the others were eliminated, hence the name Highlander. The surviving program then generated dozens of new “childrens” through further random mutations of the evaluation terms, with the mutation range gradually becoming narrower.

The algorithm converged relatively quickly compared with testing each individual term over thousands of games, providing substantial Elo gains in a short amount of time. However, it also had some drawbacks, the most serious being its tendency to converge towards suboptimal local minima. I was able to partially counter this by randomly modifying some of the weights and restarting the testing round.

Today, this approach has been superseded by much more efficient methods, such as Texel’s Tuning Method, for example. Nevertheless, I continued to use it occasionally in my work as a chemical engineer, since it could easily be adapted to other fields. More recently, I have managed to extend it further by adding greater flexibility in the way mutations are introduced between different program versions.

The name of the program, for those wondering, comes from the main villain of Rumiko Takahashi’s manga Inuyasha, a series I greatly enjoyed in my youth. In the manga, Naraku was known for becoming stronger through continuous recombination and the development of new incarnations of himself. Ironically, this is exactly what happened to the program when I applied the Highlander algorithm to it.

Below is an example game played by Naraku against GNU Chess 6.21, with 20 seconds per move.

Musashi 1.01

Musashi is the new program I started developing recently, a few months ago. It is written entirely in VB.NET (.NET 8.0) and is natively 64-bit. It also uses the UCI interface. The name comes from the famous samurai Miyamoto Musashi.

Based on my initial tests, under the conditions used for my rating list, its estimated playing strength is currently around 2560 Elo. It is therefore about 100-120 Elo weaker than Naraku at the moment. At least 70-80 Elo of this difference is due to the slower execution speed of Visual Basic compared with C, which is something I can do very little about. The rest is mainly due to features that I still have to implement in Musashi. My goal is to reach and eventually surpass the strength of the old program, while keeping it entirely in Visual Basic.

These are the program’s current features:

  • It is a fairly classic chess engine using alpha-beta pruning, PVS, internal iterative deepening, a hand-crafted evaluation function (no NNUE), numerous pruning heuristics, quiescence search, and a transposition table.
  • A bitboard-based board representation, with magic bitboards for bishop and rook move generation, and Zobrist hashing.
  • Move ordering based on MVV-LVA, killer moves, and the history heuristic, with SEE used to prune unfavorable captures.
  • An evaluation function that currently includes the following main terms: static piece values (tapered), middlegame and endgame PSTs, piece-specific mobility, king safety with pawn storm and pawn shelter, bishop pair, knight and bishop outposts, passed, candidate, hanging, doubled, isolated, and protected pawns, rook supporting a passed pawn, rook on an open file and on the seventh rank, material imbalance, and, for the moment, some simplified endgame heuristics.
  • The evaluation function is optimized using an evolution of the Highlander algorithm, which has now become a more complete evolutionary algorithm. In the future, I may switch to Texel’s Tuning Method or another approach, depending, of course, on whether the Texel tuning license is compatible with a closed-source freeware program.
  • Single-core at the moment.

Why VB.NET rather than other, much faster programming languages?

I chose to use VB.NET rather than other, more widely used and faster programming languages for several reasons. First of all, Visual Basic is a language I have always liked, and it is also a language I use on a daily basis for work. Another reason is that there are not many chess engines written in Visual Basic.

The goal, after all, is not to create a 3700-Elo chess engine in Visual Basic that can take on Stockfish, but simply to see how far I can push it.

Does it use NNUE?

No. As a deliberate choice, I wanted to build a more “old-school” chess engine, with a hand-crafted evaluation function. I find it more enjoyable, and I expect to continue along this path in the future.

Why is it closed source rather than being hosted on GitHub?

For the time being, I prefer to keep it closed source, as I have done with all the other programs on this website. The main reason is that this is a personal project that I prefer to work on in my spare time, without the additional obligations of having to explain the reasoning behind every design choice or maintain a GitHub repository.

There is also a less serious, but nevertheless real, reason: I would be rather annoyed to see someone much more skilled than me at VB.NET fork the program and turn it into an engine that is 500 Elo stronger!

Is it a derivative or clone of Stockfish, Reckless, Ethereal, or any other engine?

No. The code has been written entirely from scratch in VB.NET and uses the techniques described above in their more traditional forms, with (almost certainly) several bugs and plenty of room for optimization.

For anyone interested, I can provide parts of the source code by email for verification. Obviously, engines such as Stockfish, Ethereal, Fruit, and many others have been sources of inspiration. That does not mean that their code has been copied.

Below are a couple of screenshots showing examples of Musashi’s source code:

         

 

Does it use AI?

Not for writing the main program itself. However, I do use AI to help identify and fix bugs, as well as to implement the tuning algorithm.

I consider AI an excellent tool when used for bug detection and debugging. Besides, it is becoming increasingly integrated into modern development environments. Visual Studio, for example, has AI features enabled by default.

Below is an example of VB.NET code from the implementation of the lazy evaluation, where I fixed one of the many bugs uncovered with the help of AI.

         

Is it Naraku rewritten in Visual Basic?

No. Although some of the search and evaluation techniques are very similar, since they are standard features of modern chess engines, the two programs are fundamentally different, as can be seen directly from their evaluation of positions.

For example, although Musashi is two to three times slower, modern techniques allow it to prune far more aggressively than Naraku. This allows it to reach, and sometimes even exceed, the same search depth as Naraku while searching only about one third as many nodes.

Downloads

Musashi can be downloaded by clicking the following link: Musashi 1.01.

Here the changelog in txt format. Changelog.txt.

Old version: Musashi 1.0.

It requires .NET 8.0. It has been tested and confirmed to work on Windows 7, Windows 10, and Windows 11, and runs perfectly under Arena, Cute Chess, Scid vs. PC, and LittleBlitzer.

Some example screenshots:

Musashi playing against Naraku in Arena, things are not going particularly well…
Musashi playing against Rebel 6.0.