Skip to content

Commit

Permalink
Merge pull request #70 from SzilBalazs/dev
Browse files Browse the repository at this point in the history
BlackCore v4.0
Bench: 4304291
  • Loading branch information
SzilBalazs authored Dec 26, 2022
2 parents 3224ee0 + 25bf2bd commit fa49d66
Show file tree
Hide file tree
Showing 17 changed files with 453 additions and 354 deletions.
55 changes: 21 additions & 34 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,33 @@ jobs:
strategy:
matrix:
config:
#- {
# name: "Ubuntu g++ popcnt",
# os: ubuntu-latest,
# compiler: g++-11,
# arch: popcnt,
# target: BlackCore-popcnt-linux,
#}
#- {
# name: "Ubuntu g++ modern",
# os: ubuntu-latest,
# compiler: g++-11,
# arch: modern,
# target: BlackCore-modern-linux,
#}
#- {
# name: "Ubuntu g++ avx2",
# os: ubuntu-latest,
# compiler: g++-11,
# arch: avx2,
# target: BlackCore-avx2-linux,
#}
#- {
# name: "Ubuntu g++ bmi2",
# os: ubuntu-latest,
# compiler: g++-11,
# arch: bmi2,
# target: BlackCore-bmi2-linux,
#}
- {
name: "Windows g++ popcnt",
os: windows-latest,
compiler: g++,
name: "Ubuntu g++ popcnt",
os: ubuntu-latest,
compiler: g++-11,
arch: popcnt,
target: BlackCore-popcnt-win.exe,
target: BlackCore-popcnt-linux,
}
- {
name: "Ubuntu g++ avx2",
os: ubuntu-latest,
compiler: g++-11,
arch: avx2,
target: BlackCore-avx2-linux,
}
- {
name: "Windows g++ modern",
name: "Ubuntu g++ bmi2",
os: ubuntu-latest,
compiler: g++-11,
arch: bmi2,
target: BlackCore-bmi2-linux,
}
- {
name: "Windows g++ popcnt",
os: windows-latest,
compiler: g++,
arch: popcnt,
target: BlackCore-modern-win.exe,
target: BlackCore-popcnt-win.exe,
}
- {
name: "Windows g++ avx2",
Expand Down Expand Up @@ -96,3 +82,4 @@ jobs:
with:
name: BlackCore
path: src/${{matrix.config.target}}

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Project exclude paths
/cmake-build-debug/
/release/
/testing/
/.idea/
106 changes: 61 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,62 @@

## Overview

BlackCore is a grandmaster level UCI compatible c++ chess engine written from scratch.
BlackCore is a UCI compatible c++ chess engine written from scratch.
Its alpha beta search uses various pruning techniques, powered by a neural network evaluation and a blazing fast
move generator.

## Playing strength - Last updated 2022. dec. 26.

| Version | CCRL Blitz elo | CCRL 40/15 elo |
|:----------|:------------------:|-----------------------------:|
| v4.0 4CPU | ~3200 (estiamtion) | ~3200 (estiamtion) |
| v4.0 1CPU | ~3100 (estiamtion) | ~3100 (estiamtion) |
| v3.0 1CPU | 3069 | 3035 |
| v2.0 1CPU | N/A | 2982 |
| v1.0 1CPU | 2134 | N/A |

## Installation

### Downloading prebuilt binary

You can download the latest release <a href="https://github.com/SzilBalazs/BlackCore/releases/latest">here</a> both for
Windows and Linux.
To select the right binary use the first instruction set that your CPU supports (doesn't crash), in the order of BMI2 ->
AVX2 -> popcnt

### Building from source (recommended)

After downloading the source, you can run the following commands, to build
a native binary.
This option gives the best performance.
**Please update your compiler before building!**

With any questions or problems feel free to create a github issue.

```
cd src
make clean build CXX=g++ ARCH=native
```

ARCH = popcnt/avx2/bmi2/native

CXX = the compiler of your choice (I recommend using g++, as it gives the best performance)

## Usage

BlackCore in itself is a command line program, and requires a UCI compatible
Chess GUI (like <a href="https://github.com/cutechess/cutechess">Cute Chess</a>
or <a href="http://www.playwitharena.de/">Arena</a>) for the best user experience.

### UCI Options

- **Hash** - The size of the Hash table in MB.
- **Threads** - The amount of threads that can be used in the search
- **Move Overhead** - The delay (in ms) between finding the best move and the GUI reacting to it. You may want to make
this
higher if you notice that the engine often runs out of time.


## Files

This project contains the following files:
Expand Down Expand Up @@ -42,9 +94,12 @@ This project contains the following files:
* Entry aging
* Bucket system
* Principal variation search
* Late move reduction
* Late move reduction/extension
* R = max(2, LMR_BASE + (ln(moveIndex) * ln(depth) / LMR_SCALE)));
* Move count/late move pruning
* Futility pruning
* Singular extension
* Check extension
* Razoring
* Reverse futility pruning
* Null move pruning
Expand All @@ -55,56 +110,17 @@ This project contains the following files:
* Move ordering
* Hash move
* MVV-LVA and SEE
* Killer and history heuristics
* Fast repetition detection
* Killer, counter and history heuristics
* History difference - killer move replacement
* Multithreading support
* Lazy SMP
* Time management based on search stability
* NNUE evaluation
* Trained using <a href="https://github.com/SzilBalazs/CoreTrainer">CoreTrainer</a>
* Training data was generated using <a href="https://github.com/jhonnold/berserk">Berserk</a> data
* Support for AVX2 architecture for vectorized accumulator updates
* Net embedded using incbin (for license see /src/incbin/UNLICENSE)

## Installation

### Building from source (recommended)

After downloading the source, you can run the following commands, to build
a native binary.
This option gives the best performance.
**Please update your compiler before building!**

With any questions or problems feel free to create a github issue.

```
cd src
make clean build CXX=g++ ARCH=native
```

ARCH = popcnt/modern/avx2/bmi2/native

CXX = the compiler of your choice (I recommend using g++, as it gives the best performance)

### Downloading prebuilt binary

You can download the latest release <a href="https://github.com/SzilBalazs/BlackCore/releases/latest">here</a> both for
Windows and Linux.
To select the right binary use the first instruction set that your CPU supports (doesn't crash), in the order of BMI2 ->
AVX2 -> modern -> popcnt

## Usage

BlackCore in itself is a command line program, and requires a UCI compatible
Chess GUI (like <a href="https://github.com/cutechess/cutechess">Cute Chess</a>
or <a href="http://www.playwitharena.de/">Arena</a>) for the best user experience.

### UCI Options

- **Hash** - The size of the Hash table in MB.
- **Threads** - Currently BlackCore only supports single threaded search, but this will probably change in the future.
- **Move Overhead** - The delay (in ms) between finding the best move and the GUI reacting to it. You may want to make
this
higher if you notice that the engine often runs out of time.

## Special thanks to

### <a href="https://www.chessprogramming.org/Main_Page">Chess Programming Wiki</a>
Expand Down
11 changes: 11 additions & 0 deletions scripts/make_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
cd ..
mkdir release
cd src
for ARCH in 'popcnt' 'avx2' 'bmi2'
do
make clean
make -j CXX=x86_64-w64-mingw32-g++-posix EXE=../release/BlackCore-$ARCH-win.exe ARCH=$ARCH
make clean
make -j CXX=g++ EXE=../release/BlackCore-$ARCH-linux ARCH=$ARCH
done
10 changes: 3 additions & 7 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ CXX = g++
TARGET_FLAGS = -static -static-libgcc -static-libstdc++
ARCH=native
NAME = BlackCore
VERSION_MAJOR = 3
VERSION_MAJOR = 4
VERSION_MINOR = 0
OBJECT_DIR = objects
SOURCES := $(wildcard *.cpp)
Expand All @@ -26,19 +26,15 @@ ifeq ($(ARCH), native)
endif

ifeq ($(ARCH), bmi2)
ARCH_FLAGS = -march=x86-64 -mpopcnt -msse -msse2 -mssse3 -msse4.1 -mavx2 -mbmi2
ARCH_FLAGS = -march=x86-64 -mpopcnt -msse -msse2 -mssse3 -msse4.1 -mavx2 -mbmi -mbmi2
DEFINE_FLAGS = -DAVX2 -DBMI2
endif

ifeq ($(ARCH), avx2)
ARCH_FLAGS = -march=x86-64 -mpopcnt -msse -msse2 -mssse3 -msse4.1 -mavx2
ARCH_FLAGS = -march=x86-64 -mpopcnt -msse -msse2 -mssse3 -msse4.1 -mavx2 -mbmi
DEFINE_FLAGS = -DAVX2
endif

ifeq ($(ARCH), modern)
ARCH_FLAGS = -march=x86-64 -mpopcnt -msse -msse2 -mssse3 -msse4.1
endif

ifeq ($(ARCH), popcnt)
ARCH_FLAGS = -march=x86-64 -mpopcnt
endif
Expand Down
9 changes: 6 additions & 3 deletions src/bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,12 @@ void testSearch() {
info.maxDepth = SEARCH_DEPTH;
info.uciMode = false;
startSearch(info, pos, 1);
joinThread(true);
totalNodes += nodeCount;
nps += getNps();

while (!stopped) {}
totalNodes += getTotalNodes();
nps += getNps(getTotalNodes());

joinThreads(true);
}

std::cout << totalNodes << " nodes " << nps / posCount << " nps" << std::endl;
Expand Down
96 changes: 0 additions & 96 deletions src/move_ordering.cpp

This file was deleted.

Loading

0 comments on commit fa49d66

Please sign in to comment.