Skip to content

Commit

Permalink
Brainlearn 29
Browse files Browse the repository at this point in the history
Aligned with Stockfish 17.
Fixed mcts.
Fixed persisted learning and added the experience book option and an utility for reset (to be done for old experience files) and display content given a fen.
Extended livebook to LiChess in addition to ChessDB.
Removed opening variety and replaced with variety which is now a combo with three values:
-off the default
-standard without loss of elo
-psychological more risky because with elo loss, but not as significant, useful for inviting the engine to a game with psychological/human sacrifices, i.e., strictly speaking, incorrect, but almost impossible to refute.
  • Loading branch information
amchess committed Sep 19, 2024
1 parent 8c82f1a commit 8ff4ee3
Show file tree
Hide file tree
Showing 168 changed files with 33,884 additions and 16,026 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ contact_links:
url: https://discord.gg/GWDRS3kU6R
about: Feel free to ask for support or have a chat with us on our Discord server!
- name: Discussions, Q&A, ideas, show us something...
url: https://github.com/official-stockfish/Stockfish/discussions/new
url: https://github.com/official-brainlearn/Brainlearn/discussions/new
about: Do you have an idea for Brainlearn? Do you want to show something that you made? Please open a discussion about it!
1 change: 1 addition & 0 deletions .github/ci/libcxx17.imp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
{ include: [ "<__fwd/sstream.h>", private, "<iosfwd>", public ] },
{ include: [ "<__fwd/streambuf.h>", private, "<iosfwd>", public ] },
{ include: [ "<__fwd/string_view.h>", private, "<string_view>", public ] },
{ include: [ "<__system_error/errc.h>", private, "<system_error>", public ] },

# Mappings for includes between public headers
{ include: [ "<ios>", public, "<iostream>", public ] },
Expand Down
4 changes: 2 additions & 2 deletions .github/ci/matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"comp": "gcc",
"shell": "bash",
"archive_ext": "tar",
"sde": "/home/runner/work/Stockfish/Stockfish/.output/sde-temp-files/sde-external-9.27.0-2023-09-13-lin/sde -future --"
"sde": "/home/runner/work/Brainlearn/Brainlearn/.output/sde-temp-files/sde-external-9.27.0-2023-09-13-lin/sde -future --"
},
{
"name": "MacOS 13 Apple Clang",
Expand Down Expand Up @@ -38,7 +38,7 @@
"msys_env": "x86_64-gcc",
"shell": "msys2 {0}",
"ext": ".exe",
"sde": "/d/a/Stockfish/Stockfish/.output/sde-temp-files/sde-external-9.27.0-2023-09-13-win/sde.exe -future --",
"sde": "/d/a/Brainlearn/Brainlearn/.output/sde-temp-files/sde-external-9.27.0-2023-09-13-win/sde.exe -future --",
"archive_ext": "zip"
}
],
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/arm_compilation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: ${{ matrix.config.name }} ${{ matrix.binaries }}
runs-on: ${{ matrix.config.os }}
env:
COMPILER: ${{ matrix.config.compiler }}
COMPCXX: ${{ matrix.config.compiler }}
COMP: ${{ matrix.config.comp }}
EMU: ${{ matrix.config.emu }}
EXT: ${{ matrix.config.ext }}
Expand All @@ -26,6 +26,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Download required linux packages
if: runner.os == 'Linux'
Expand Down Expand Up @@ -62,7 +63,7 @@ jobs:
if [ $COMP == ndk ]; then
export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
fi
$COMPILER -v
$COMPCXX -v
- name: Test help target
run: make help
Expand All @@ -82,7 +83,7 @@ jobs:
make -j4 profile-build ARCH=$BINARY COMP=$COMP WINE_PATH=$EMU
make strip ARCH=$BINARY COMP=$COMP
WINE_PATH=$EMU ../tests/signature.sh $benchref
mv ./stockfish$EXT ../stockfish-android-$BINARY$EXT
mv ./brainlearn$EXT ../brainlearn-android-$BINARY$EXT
- name: Remove non src files
run: git clean -fx
Expand All @@ -91,4 +92,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.config.simple_name }} ${{ matrix.binaries }}
path: .
path: |
.
!.git
!.output
122 changes: 122 additions & 0 deletions .github/workflows/brainlearn.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Brainlearn
on:
push:
tags:
- "*"
branches:
- master
- tools
- github_ci
pull_request:
branches:
- master
- tools
jobs:
Prerelease:
if: github.repository == 'official-brainlearn/Brainlearn' && (github.ref == 'refs/heads/master' || (startsWith(github.ref_name, 'sf_') && github.ref_type == 'tag'))
runs-on: ubuntu-latest
permissions:
contents: write # For deleting/creating a prerelease
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

# returns null if no pre-release exists
- name: Get Commit SHA of Latest Pre-release
run: |
# Install required packages
sudo apt-get update
sudo apt-get install -y curl jq
echo "COMMIT_SHA_TAG=$(jq -r 'map(select(.prerelease)) | first | .tag_name' <<< $(curl -s https://api.github.com/repos/${{ github.repository_owner }}/Brainlearn/releases))" >> $GITHUB_ENV
# delete old previous pre-release and tag
- run: gh release delete ${{ env.COMMIT_SHA_TAG }} --cleanup-tag
if: env.COMMIT_SHA_TAG != 'null'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Make sure that an old ci that still runs on master doesn't recreate a prerelease
- name: Check Pullable Commits
id: check_commits
run: |
git fetch
CHANGES=$(git rev-list HEAD..origin/master --count)
echo "CHANGES=$CHANGES" >> $GITHUB_ENV
- name: Get last commit SHA
id: last_commit
run: echo "COMMIT_SHA=$(git rev-parse HEAD | cut -c 1-8)" >> $GITHUB_ENV

- name: Get commit date
id: commit_date
run: echo "COMMIT_DATE=$(git show -s --date=format:'%Y%m%d' --format=%cd HEAD)" >> $GITHUB_ENV

# Create a new pre-release, the other upload_binaries.yml will upload the binaries
# to this pre-release.
- name: Create Prerelease
if: github.ref_name == 'master' && env.CHANGES == '0'
uses: softprops/action-gh-release@4634c16e79c963813287e889244c50009e7f0981
with:
name: Brainlearn dev-${{ env.COMMIT_DATE }}-${{ env.COMMIT_SHA }}
tag_name: brainlearn-dev-${{ env.COMMIT_DATE }}-${{ env.COMMIT_SHA }}
prerelease: true

Matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
arm_matrix: ${{ steps.set-arm-matrix.outputs.arm_matrix }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- id: set-matrix
run: |
TASKS=$(echo $(cat .github/ci/matrix.json) )
echo "MATRIX=$TASKS" >> $GITHUB_OUTPUT
- id: set-arm-matrix
run: |
TASKS_ARM=$(echo $(cat .github/ci/arm_matrix.json) )
echo "ARM_MATRIX=$TASKS_ARM" >> $GITHUB_OUTPUT
Compilation:
needs: [Matrix]
uses: ./.github/workflows/compilation.yml
with:
matrix: ${{ needs.Matrix.outputs.matrix }}
ARMCompilation:
needs: [Matrix]
uses: ./.github/workflows/arm_compilation.yml
with:
matrix: ${{ needs.Matrix.outputs.arm_matrix }}
IWYU:
uses: ./.github/workflows/iwyu.yml
Sanitizers:
uses: ./.github/workflows/sanitizers.yml
Tests:
uses: ./.github/workflows/tests.yml
Matetrack:
uses: ./.github/workflows/matetrack.yml
Games:
uses: ./.github/workflows/games.yml
Binaries:
if: github.repository == 'official-brainlearn/Brainlearn'
needs: [Matrix, Prerelease, Compilation]
uses: ./.github/workflows/upload_binaries.yml
with:
matrix: ${{ needs.Matrix.outputs.matrix }}
permissions:
contents: write # For deleting/creating a (pre)release
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
ARM_Binaries:
if: github.repository == 'official-brainlearn/Brainlearn'
needs: [Matrix, Prerelease, ARMCompilation]
uses: ./.github/workflows/upload_binaries.yml
with:
matrix: ${{ needs.Matrix.outputs.arm_matrix }}
permissions:
contents: write # For deleting/creating a (pre)release
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
16 changes: 11 additions & 5 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
paths:
- "**.cpp"
- "**.h"

permissions:
pull-requests: write

jobs:
Clang-Format:
name: Clang-Format
Expand All @@ -25,27 +29,29 @@ jobs:
id: clang-format
continue-on-error: true
with:
clang-format-version: "17"
clang-format-version: "18"
exclude-regex: "incbin"

- name: Comment on PR
if: steps.clang-format.outcome == 'failure'
uses: thollander/actions-comment-pull-request@1d3973dc4b8e1399c0620d3f2b1aa5e795465308 # @v2.4.3
uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6 # @v2.5.0
with:
message: |
clang-format 17 needs to be run on this PR.
clang-format 18 needs to be run on this PR.
If you do not have clang-format installed, the maintainer will run it when merging.
For the exact version please see https://packages.ubuntu.com/mantic/clang-format-17.
For the exact version please see https://packages.ubuntu.com/noble/clang-format-18.
_(execution **${{ github.run_id }}** / attempt **${{ github.run_attempt }}**)_
comment_tag: execution
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Comment on PR
if: steps.clang-format.outcome != 'failure'
uses: thollander/actions-comment-pull-request@1d3973dc4b8e1399c0620d3f2b1aa5e795465308 # @v2.4.3
uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6 # @v2.5.0
with:
message: |
_(execution **${{ github.run_id }}** / attempt **${{ github.run_attempt }}**)_
create_if_not_exists: false
comment_tag: execution
mode: delete
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 4 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -48,6 +50,6 @@ jobs:
run: make -j build ARCH=x86-64-modern

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
15 changes: 10 additions & 5 deletions .github/workflows/compilation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: ${{ matrix.config.name }} ${{ matrix.binaries }}
runs-on: ${{ matrix.config.os }}
env:
COMPILER: ${{ matrix.config.compiler }}
COMPCXX: ${{ matrix.config.compiler }}
COMP: ${{ matrix.config.comp }}
EXT: ${{ matrix.config.ext }}
NAME: ${{ matrix.config.simple_name }}
Expand All @@ -25,6 +25,8 @@ jobs:
shell: ${{ matrix.config.shell }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Install fixed GCC on Linux
if: runner.os == 'Linux'
Expand All @@ -50,7 +52,7 @@ jobs:
run: make net

- name: Check compiler
run: $COMPILER -v
run: $COMPCXX -v

- name: Test help target
run: make help
Expand All @@ -59,7 +61,7 @@ jobs:
run: git --version

- name: Check compiler
run: $COMPILER -v
run: $COMPCXX -v

- name: Show g++ cpu info
if: runner.os != 'macOS'
Expand All @@ -77,7 +79,7 @@ jobs:
make -j4 profile-build ARCH=$BINARY COMP=$COMP WINE_PATH="$SDE"
make strip ARCH=$BINARY COMP=$COMP
WINE_PATH="$SDE" ../tests/signature.sh $benchref
mv ./stockfish$EXT ../stockfish-$NAME-$BINARY$EXT
mv ./brainlearn$EXT ../brainlearn-$NAME-$BINARY$EXT
- name: Remove non src files
run: git clean -fx
Expand All @@ -86,4 +88,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.config.simple_name }} ${{ matrix.binaries }}
path: .
path: |
.
!.git
!.output
43 changes: 43 additions & 0 deletions .github/workflows/games.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This workflow will play games with a debug enabled SF using the PR

name: Games
on:
workflow_call:
jobs:
Matetrack:
name: Games
runs-on: ubuntu-22.04
steps:
- name: Checkout SF repo
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
path: Brainlearn
persist-credentials: false

- name: build debug enabled version of SF
working-directory: Brainlearn/src
run: make -j build debug=yes

- name: Checkout fast-chess repo
uses: actions/checkout@v4
with:
repository: Disservin/fast-chess
path: fast-chess
ref: d54af1910d5479c669dc731f1f54f9108a251951
persist-credentials: false

- name: fast-chess build
working-directory: fast-chess
run: make -j

- name: Run games
working-directory: fast-chess
run: |
./fast-chess -rounds 4 -games 2 -repeat -concurrency 4 -openings file=app/tests/data/openings.epd format=epd order=random -srand $RANDOM\
-engine name=sf1 cmd=/home/runner/work/Brainlearn/Brainlearn/Brainlearn/src/brainlearn\
-engine name=sf2 cmd=/home/runner/work/Brainlearn/Brainlearn/Brainlearn/src/brainlearn\
-ratinginterval 1 -report penta=true -each proto=uci tc=4+0.04 -log file=fast.log | tee fast.out
cat fast.log
! grep "Assertion" fast.log > /dev/null
! grep "disconnect" fast.out > /dev/null
10 changes: 6 additions & 4 deletions .github/workflows/iwyu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,22 @@ jobs:
runs-on: ubuntu-22.04
defaults:
run:
working-directory: Stockfish/src
working-directory: Brainlearn/src
shell: bash
steps:
- name: Checkout Stockfish
- name: Checkout Brainlearn
uses: actions/checkout@v4
with:
path: Stockfish
path: Brainlearn
persist-credentials: false

- name: Checkout include-what-you-use
uses: actions/checkout@v4
with:
repository: include-what-you-use/include-what-you-use
ref: f25caa280dc3277c4086ec345ad279a2463fea0f
path: include-what-you-use
persist-credentials: false

- name: Download required linux packages
run: |
Expand All @@ -44,4 +46,4 @@ jobs:
make analyze
COMP=clang
CXX=include-what-you-use
CXXFLAGS="-stdlib=libc++ -Xiwyu --comment_style=long -Xiwyu --mapping='${{ github.workspace }}/Stockfish/.github/ci/libcxx17.imp' -Xiwyu --error"
CXXFLAGS="-stdlib=libc++ -Xiwyu --comment_style=long -Xiwyu --mapping='${{ github.workspace }}/Brainlearn/.github/ci/libcxx17.imp' -Xiwyu --error"
Loading

0 comments on commit 8ff4ee3

Please sign in to comment.