Skip to content

Commit

Permalink
Search rework (#61)
Browse files Browse the repository at this point in the history
Elo   | 250.57 +- 44.99 (95%)
SPRT  | 60.0+0.60s Threads=1 Hash=64MB
LLR   | 1.05 (-2.94, 2.94) [0.50, 2.50]
Games | N: 340 W: 252 L: 42 D: 46
Penta | [3, 4, 33, 40, 90]

Bench: 3746694
  • Loading branch information
Dannyj1 authored Dec 14, 2023
1 parent 8bc36bf commit 765fac1
Show file tree
Hide file tree
Showing 41 changed files with 4,562 additions and 4,684 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
Language: Cpp
BasedOnStyle: Google
ColumnLimit: 100
IndentWidth: 4
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
cmake_minimum_required(VERSION 3.16)
set(CMAKE_CXX_STANDARD 20)
project(Zagreus)
set(ZAGREUS_VERSION_MAJOR "3")
set(ZAGREUS_VERSION_MAJOR "4")
set(ZAGREUS_VERSION_MINOR "0")

# Default values
Expand Down
31 changes: 22 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,29 @@ You can download binaries here: https://github.com/Dannyj1/Zagreus/releases
This engine requires a GUI that supports the UCI (Universal Chess Interface) protocol to use it. I personally
use [CuteChess](https://cutechess.com/).

# Development

Development of all new changes and bug fixes happens in a separate branch for each change. When the change is properly
tested using OpenBench and proven to improve ELO, it will be merged with the master branch. Because of this, the master
branch is not the latest released version and may contain bugs.
Every stable release (as in the version has been uploaded under releases) will have a tag. If you want to compile the
stable version for yourself, you can use the tag. You can list all tags and search for tags under the branches dropdown
on GitHub.

# Features
- Bitboard board representation with Plain Magic Bitboards for sliding piece move generation
- Tapered Evaluation consisting of material balance, mobility, very simple connectivity, king safety, piece square
tables and more
- Evaluation values automatically tuned with a gradient descent tuner with the Adam optimizer.
- Tapered Evaluation with:
- Material
- Piece-Square Tables
- Several evaluation terms per piece type (e.g. passed pawn, king safety, etc.)
- Penalty for undefended minor pieces
- And more
- Evaluation values automatically tuned using a gradient descent tuner with the Adam optimizer.
- Principal Variation Search with Alpha-Beta pruning
- Aspiration Windows
- Quiescence Search with delta pruning and SEE move ordering
- Move ordering using MVV/LVA, killer moves, history heuristic, countermove heuristic
- Transposition Table
- Null Move Pruning
- Late Move Reduction
- And more! This list is constantly growing and changing, but it is difficult to keep track of all features and changes.

# UCI Options
Expand All @@ -42,7 +53,8 @@ Zagreus Engine has the following UCI options that can be changed:
# Build Instructions

To build Zagreus, you will need to use LLVM. On Windows, I use [LLVM MinGW](https://github.com/mstorsjo/llvm-mingw). On
Linux I just use [LLVM](https://releases.llvm.org/download.html).
Linux I just use [LLVM](https://releases.llvm.org/download.html), but it is also possible to use GCC. LLVM seems to have
slightly better performance.
Zagreus uses CMake to build. On Windows you can use the [CMake-GUI](https://cmake.org/runningcmake/). On Linux, use the
following commands:

Expand All @@ -51,10 +63,11 @@ Clone the repository:
git clone https://github.com/Dannyj1/Zagreus.git
```

Set the compiler to clang++:
If you want to use Clang/LLVM, set the compiler to clang++ (not required. If you don't run these commands, your default
compiler will be used which works fine in most cases):
```bash
export CC=/usr/bin/clang-15
export CXX=/usr/bin/clang++-15
export CC=/usr/bin/clang-<version here>
export CXX=/usr/bin/clang++-<version here>
```
Build:
```bash
Expand Down
4 changes: 2 additions & 2 deletions senjo/BackgroundCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ namespace senjo {
continue;
}

int depth = toNumber<int>(depthToken.substr(1));
int16_t depth = toNumber<int>(depthToken.substr(1));
if (depth < 1) {
Output() << "--- invalid depth: " << depthToken;
break;
Expand Down Expand Up @@ -252,7 +252,7 @@ namespace senjo {
//! \param[out] leaf_count The actual leaf count at \p depth
//! \return false if leaf_count count does not match expected leaf count
//-----------------------------------------------------------------------------
bool PerftCommandHandle::process(const int depth,
bool PerftCommandHandle::process(const int16_t depth,
const uint64_t expected_leaf_count,
uint64_t &leaf_count) {
if ((maxDepth > 0) && (depth > maxDepth)) {
Expand Down
2 changes: 1 addition & 1 deletion senjo/BackgroundCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ namespace senjo {
void doWork();

private:
bool process(const int depth, const uint64_t expected_leaf_count,
bool process(const int16_t depth, const uint64_t expected_leaf_count,
uint64_t &leaf_count);

static const std::string _TEST_FILE;
Expand Down
2 changes: 1 addition & 1 deletion senjo/ChessEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ namespace senjo {
//! \param[in] depth How many half-moves (plies) to search
//! \return The number of leaf nodes visited at \p depth
//---------------------------------------------------------------------------
virtual uint64_t perft(const int depth) = 0;
virtual uint64_t perft(const int16_t depth) = 0;

//---------------------------------------------------------------------------
//! \brief Execute search on current position to find best move
Expand Down
2 changes: 1 addition & 1 deletion senjo/GoParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace senjo {
struct GoParams {
bool infinite = false; // SearchManager until the "stop" command
bool ponder = false; // Start searching in pondering mode
int depth = 0; // Maximum number of half-moves (plies) to search
int16_t depth = 0; // Maximum number of half-moves (plies) to search
int movestogo = 0; // Number of moves remaining until next time control
uint64_t binc = 0; // BLACK increment per move in milliseconds
uint64_t btime = 0; // Milliseconds remaining on black's clock
Expand Down
2 changes: 1 addition & 1 deletion senjo/SearchStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace senjo {

//-----------------------------------------------------------------------------
struct SearchStats {
int depth = 0; // The current search depth
int16_t depth = 0; // The current search depth
int seldepth = 0; // The maximum selective depth reached on "move"
uint64_t nodes = 0; // The number of nodes searched so far
uint64_t qnodes = 0; // The number of quiescence nodes searched so far
Expand Down
Loading

0 comments on commit 765fac1

Please sign in to comment.