Skip to content

amanjpro/zahak

Repository files navigation

Zahak

Build Status

A UCI compatible chess AI written in Go. Still work in progress.

Courtesy to the OpenBench community, Zahak is now part of the official OpenBench instance

The name

Zahak (or Zahhak or Azhi Dahak) is an evil figure in Iranian/Kurdish/Perisan mythology, evident in ancient Iranian folklore as Azhi Dahāka, the name by which he also appears in the texts of the Avesta. Legend has it, that he had two giant snakes on his shoulders and he had to feed them two human brains on daily basis, you can read more about him here

Play Zahak online

Zahak is new to LiChess, you can play him and be impressed with him. His LiChess handle is zahak_engine.

Play Zahak on your Android Phone/Desktop

Zahak is a bare chess engine AI, that means it doesn't come with any GUI interface. That also means, it is easy to plug it into any chess GUI that supports UCI protocol.

Tournaments

Zahak recently got invitation to the TCEC tournament!

Zahak is also participating in ZaTour tournament series for open source and original chess engines. And many other tournaments, like the ones arranged by the amazing Graham Banks.

Rating

Zahak is in almost all major rating lists, here are the details:

version CCRL Blitz Rating CCRL Blitz (8CPU) Rating CCRL 40/40 Rating CCRL 40/4040 (4CPU) Rating
9.x 3278 3406 3213 3282
8.x 3133 N/A 3098 N/A
7.x 2964 (32 bit: 2897) N/A 2938 3006
6.x 2833 N/A 2800 (unstable rating) N/A
5.0 2730 N/A 2676 N/A
4.0 2570 N/A 2568 (unstable rating) N/A
3.0 2407 N/A N/A N/A
2.0.0 2105 (unstable rating) N/A N/A N/A
1.0.0 2011 N/A N/A N/A
0.3.0 1922 N/A N/A N/A
0.2.1 1824 N/A N/A N/A
version CEGT 40/4 Rating CEGT 40/20 Rating CEGT 5"+3' Rating (Ponder On)
9.x 3182 3162 3199
8.x 3046 3022 3051
7.x 2840 N/A 2858
6.x 2664 N/A 2676
5.0 2553 N/A N/A
4.0 2417 N/A N/A
  • Other well-known rating lists
version GRL 40/2 Rating SPCC Rating BRUCE Rating Fast GM 60+06 Fast GM 10m+6s
9.x 3244 3273 3283 N/A 3138
8.x 3140 N/A 3169 N/A 3057
7.x 2929 N/A 2981 2749 N/A
6.x 2785 N/A 2841 2584 2720
5.0 2686 N/A 2683 2505 N/A
4.0 2522 N/A N/A N/A N/A
3.0 2378 N/A N/A N/A N/A

Implemented Features:

Core Features

  • UCI Support
  • (Magic) Bitboards
  • Multi-stage move generation
  • Transposition Table
  • Pawnhash
  • PolyGlot opening book
  • Compliant with OpenBench
  • Syzygy Support
  • MultiPV
  • Skill Levels, 1 to 7 (strongest)

Search

Basics

  • Alpha-Beta search
  • Quiescence Search
  • Iterative Deepening
  • PV Search and PV
  • Search with Zero Windows
  • Aspiration Window with PVS
  • Pondering
  • Multi-Threading (LazySMP)

Move Ordering

  • Hash move
  • Promotions
  • Static Exchange Evaluation followed by LVA-MVV for equal captures according to SEE
  • Killer Moves Heuristics
  • Countermove Heuristics
  • Move History Heuristics
  • Countermove History Heuristics
  • FollowUp History Heuristics

Selectivity

  • Late Move Pruning
  • Null-Move Pruning
  • Delta Pruning
  • Reverse Futility Pruning
  • Futility Pruning
  • Late Move Reduction
  • Razoring
  • Check Extensions
  • Internal Iterative Deepening
  • SEE pruning both in QS and normal search
  • Threat Pruning
  • Singular Extension
  • Multi-Cut

Evaluation

  • NNUE

Command line options

bash-3.2$ bin/zahak -help
Usage of bin/zahak:
  Commands:
   ./zahak         Runs Zahak in UCI mode
   ./zahak bench   Runs Zahak in OpenBench mode
   
  Options:
  
  -book string
        Path to openning book in PolyGlot (bin) format
  -perft
        Provide this to run perft tests
  -perft-tree
        Run the engine in prefttree mode
  -gen-epds
        Generate opening EPDs for self-play
  -profile
        Run the engine in profiling mode
  -slow
        Run all perft tests, even the very slow tests
  -test-positions string
        Path to EPD positions, used to test the strength of the engine

Skill Levels

Anchored around Rustic Alpha 3, I found that, based on CCRL the ratings will probably translate to the following:

  • Skill Level 1: 1270
  • Skill Level 2: 1440
  • Skill Level 3: 1630
  • Skill Level 4: 1856
  • Skill Level 5: 2004
  • Skill Level 6: 2074

Opening Books

Currently only PolyGlot is supported. Then engine doesn't come with any books, but you can attach your favourite one easily by passing the path to -book command: zahak -book PATH_TO_BOOK.

A bunch of free books are available here

Training Networks

Please refer to this guide.

Building

To build the project, simply run make build, testing with make test, and running with make run. Other features exist, for example you can run perft with ./zahak -perft or profile it with ./zahak -profile. You can also run it in perfttree mode with ./zahak -preft-tree.

Contributors

Thanks to the following for their valuable contributions:

  • Basti Dangca: for generating data for training Zahak's network
  • Alan Cooper (Scally): for generating weaker networks for different skill levels.

Acknowledgement

Zahak wouldn't have been possible without:

  • VICE videos
  • Chess Programming Wiki
  • The official OpenBench instance, and the all the hardware donators (noopwn4ftw and others)
  • Aryan Parekh the author of Bit-Genie, who helped me with NNUE
  • Niels Abildskov the author of Loki, who helped me with Texel Tuning
  • Nasrin Zaza for the amazing logo
  • OpenSource engines like: Weiss, Ethereal, CounterGo, Cheng and Berserk (in no specific order)
  • OpenBench community on Discord
  • No4b for helping me with some evaluation terms