AdaChess is growing: more Ada and more Chess

The latest AdaChess release is really a nice improvement if compared to the previous one. AdaChess comes with some cool new features both in terms of chess playing style/strenght and in the Ada source code. As everybody knows, AdaChess had (has?) only two serious weakness: the speed – in terms of nodes per second – and the search depth. Both of them has been greatly improved.

The focus of this release has been both in rendering a clear and beautiful code and in improve the egine. Let’s see what’s new in the last release!

The engine

Compared to the last version, AdaChess is surely stronger. I will tell you soon how much it is! Those are the main changes in the engine.

Basically, the data types has been updated accordingly with the Ada strong-typing mechanism. For example, the Piece is not an Integer anymore but is a custom data type, the Piece_Type. This makes code much more clean and idiomatic, less error-prone and better optimized.

The move generator

The new AdaChess move generator is almost “greedy”. The generator returns only legal moves – thatk makes it a bit slower due to legality test, but much more cool and fun to develop.

In “normal” conditions the moves are generated with the pseudo-legal move generator. However, AdaChess is able to recognize if a piece is absolutely pinned and if so the moves for that piece are generated only in the pinning direction. This reduces the legality-test to a minimum affort. Further, AdaChess has a special move generator for check-evasion that is used in substitution of the “normal” when the side that is moving is in check.

Compared to the v2.1 GSEI version, the move generator speed is 3x faster and handles more information about the generated move.

The search

Another important improvement is new the principal variation search. The alpha-beta is still the main searching algorithm but with the support of Late Move Reduction, futility pruning and null-move. The zero-window has been removed – tests showed that AdaChess plays better without it.

Accordingly with the check and pin information obtained while generating moves, the moves are played in a better order and more cut-offs occurred in the Alpha-Beta. Currently, the search goes at least 2-3 ply deeper than the v2.1 version.

The hash tables

Yes! Finally I developed the hash tables for AdaChess. Thanks to the transposition tables, the engine save lot of time while searching the same positions twice or more. Currently, the hash tables works well on endgames and for recaptures where the engine saves the previous search and reuse those data.

The evaluation

Other improvement has been done in statical position evaluation. The evaluation in the 2.1 wasn’t so bad, but had some weakness in the king safety scoring. AdaChess now full understand if each side has castled and can detect leaks in castle structure. Also, AdaChess recognize attacks to the opponent king and defends according to the weight of the attack.

Most notable, the new evaluation has three “weight” for scoring each phase of the game: opening, middle game and end game.

Other stuffs

AdaChess has many other minor (but cool) changes:

  • Recognize if a moves checks the opponent king and it recognize what kind of check it is;
  • New input/output notation. AdaChess recognize and works with your favourite notation:
    • Winboard: c5d6, e1g1, d7d8q, …
    • SAN: Bf5, Nb6+, O-O, Qxf8#, …
    • Long Algebraic: Nf1-g3, Rh1xd1, …

You can switch between notation by starting the engine and passing the notation as parameter with

adachess -n <winboard|uci|san|long_algebraic>

Please note that AdaChess does not communicate by using UCI protocol but only via Winboard!

However, AdaChess recognize all of those notations as input so if you want to build your own book just build it as you want and call it!

Source code: more Ada-idiomatic and less chess

When I started to develop AdaChess I had two things in mind: making a nice chess engine in Ada. Wait, I said two things, which one is the other? I mean: making a nice chess engine and make it in Ada. It is the same sentence, one from the chess point of view and one from the Ada coding point of view. From the chess point of view it means making the engine stronger and faster. From the Ada point of view it means write code that is readable and as much idiomatic as possible.

The new code is very much Ada idiomatic and it is well commented so everybody who wants to read it can find full explanations on data structures, procedures as well as any other thing inside AdaChess. I believe that this release is a great step further in coding the engine in Ada and I’m sure you will find the code interesting and nothing to complain about!

You can always download the latest release from the dowload page!

Please do not forget that AdaChess is a GPL software. Feel always free to use and redistribuite it under the terms of the GNU Public License. If you find any bug or if you thing that can be improved in some way please contact me!

Have fun and enjoy!

Alessandro Iavicoli

I'm an italian computer software developer. Passionate about Ada, passionate about chess and then a passionate chess engine writer :-) As a hobby I dance cuban salsa which I am a certificated teacher.

Leave a Reply

Your email address will not be published. Required fields are marked *