Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
a24191c
Delete Makefile
winapiadmin Jan 5, 2026
51d4c29
integrated library
winapiadmin Mar 3, 2026
9492960
Create games.yml
winapiadmin Mar 3, 2026
c423d79
Update games.yml
winapiadmin Mar 3, 2026
047a0b5
Update timeman.cpp
winapiadmin Mar 3, 2026
e1987a3
Update games.yml
winapiadmin Mar 3, 2026
9461633
Update games.yml
winapiadmin Mar 3, 2026
5035495
Update games.yml
winapiadmin Mar 3, 2026
ca09276
Update games.yml
winapiadmin Mar 3, 2026
3503dcf
Update games.yml
winapiadmin Mar 3, 2026
76b2f00
Update games.yml
winapiadmin Mar 4, 2026
567967b
Update eval.cpp
winapiadmin Mar 4, 2026
66ef091
Update eval.cpp
winapiadmin Mar 4, 2026
55eafd9
Update eval.h
winapiadmin Mar 4, 2026
5f2e240
Update movepick.cpp
winapiadmin Mar 4, 2026
87018d5
Update movepick.h
winapiadmin Mar 4, 2026
e0113c4
Update movepick.cpp
winapiadmin Mar 4, 2026
6a3b428
Update search.cpp
winapiadmin Mar 4, 2026
c6259a6
Update eval.h
winapiadmin Mar 4, 2026
112efae
Update eval.cpp
winapiadmin Mar 4, 2026
5a64699
Update movepick.h
winapiadmin Mar 4, 2026
cfa8687
Update search.cpp
winapiadmin Mar 4, 2026
e60c4a2
Update search.cpp
winapiadmin Mar 4, 2026
069362e
Update movepick.cpp
winapiadmin Mar 4, 2026
5d8846f
Update movepick.cpp
winapiadmin Mar 4, 2026
391b6f3
Update movepick.cpp
winapiadmin Mar 4, 2026
5b33054
Update movepick.cpp
winapiadmin Mar 4, 2026
9a01ca5
Update movepick.cpp
winapiadmin Mar 4, 2026
14a9ecc
Update games.yml
winapiadmin Mar 4, 2026
f16cf32
Update games.yml
winapiadmin Mar 4, 2026
3e18c92
Update games.yml
winapiadmin Mar 4, 2026
957b18b
extend time control (6*time)
winapiadmin Mar 4, 2026
bda9208
Update games.yml
winapiadmin Mar 4, 2026
3f12d43
set pv if really hit TT
winapiadmin Mar 4, 2026
9e86d67
Update games.yml
winapiadmin Mar 4, 2026
84af61b
Update search.cpp
winapiadmin Mar 4, 2026
e16df82
Update games.yml
winapiadmin Mar 4, 2026
40c769b
Update games.yml
winapiadmin Mar 4, 2026
608c8ec
fix regression of null pointer deref
winapiadmin Mar 4, 2026
66be7b7
clear PV
winapiadmin Mar 4, 2026
be920c1
Update search.cpp
winapiadmin Mar 5, 2026
66d3364
fix overflow
winapiadmin Mar 5, 2026
c056095
implemented quiescence and fix illegal PV (variable shadowing)
winapiadmin Mar 16, 2026
5202e7c
no functional changes
winapiadmin Mar 17, 2026
9295dec
fix typo
winapiadmin Mar 17, 2026
559d840
Update games.yml
winapiadmin Mar 17, 2026
2f962a9
Update games.yml
winapiadmin Mar 17, 2026
e6b67a0
Update games.yml
winapiadmin Mar 17, 2026
8a7f646
update source
winapiadmin Mar 28, 2026
4e5461e
Update uci.cpp
winapiadmin Mar 28, 2026
26e4720
some features and improvements (#3)
winapiadmin Apr 25, 2026
29f8c08
some QoL changes and specifically, BUGS.
winapiadmin Apr 26, 2026
5d6c1a8
library side fix nullmoves
winapiadmin May 9, 2026
d4336c8
Apply clang-format
actions-user May 9, 2026
8895ce0
Update eval.cpp
winapiadmin Jun 1, 2026
d877e11
Update search.cpp
winapiadmin Jun 1, 2026
dd9a1dd
Fix typo in move type check for score calculation
winapiadmin Jun 1, 2026
ed208f1
Update uci.cpp
winapiadmin Jun 1, 2026
4d4e1ab
Fix FEN setting in engine loop
winapiadmin Jun 1, 2026
6adfd1f
Update uci.cpp
winapiadmin Jun 1, 2026
a522468
improvements and bugfix (#6)
winapiadmin Jul 9, 2026
49cf63a
Update games.yml
winapiadmin Jul 9, 2026
aa08fd3
Update Makefile
winapiadmin Jul 9, 2026
b242210
resolved some issues, no functional changes
winapiadmin Jul 9, 2026
a8545a4
Apply clang-format
actions-user Jul 9, 2026
efa8bb4
Potential fix for pull request finding 'CodeQL / Workflow does not co…
winapiadmin Jul 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
BasedOnStyle: LLVM
IndentWidth: 4
ContinuationIndentWidth: 4
ColumnLimit: 128
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
BinPackParameters: false
BinPackArguments: false
BraceWrapping:
# AfterInitializerList: true
AfterFunction: true
BeforeElse: false
IndentBraces: false
AlignArrayOfStructures: Right
Cpp11BracedListStyle: false
SpacesInContainerLiterals: false
35 changes: 35 additions & 0 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: clang-format

on:
pull_request:
branches: [ "main" ]
push:
branches-ignore:
- main
jobs:
format:
if: github.actor != 'github-actions[bot]'
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install clang-format
run: pip install clang-format==18.1.0

- name: Run clang-format
run: |
clang-format -i $(git ls-files '*.cpp' '*.hpp' '*.h' '*.c')

- name: Commit and push changes
run: |
if ! git diff --quiet; then
git config user.email "actions@github.com"
git config user.name "GitHub Actions"
git commit -am "Apply clang-format"
git push
fi
145 changes: 145 additions & 0 deletions .github/workflows/games.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: Fastchess SPRT Test (Linux)

on:
workflow_dispatch:
inputs:
base_ref:
description: "Base branch, tag, or commit"
required: false
default: "test_chesslib"
rounds:
description: "Max rounds for SPRT"
required: false
default: "6000"
tc:
description: "Time control (e.g. 60+0.6 or 10+0.1)"
required: false
default: "60+0.6"
elo0:
description: "elo0"
required: false
default: "0.5"
elo1:
description: "elo1"
required: false
default: "2.5"
output_exec:
description: "Executable output file name"
required: false
default: "engine"

permissions:
contents: read

jobs:

build-new:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
path: new
persist-credentials: false

- name: Install deps
run: sudo apt update && sudo apt install -y build-essential cmake

- name: Build new engine
run: |
cd new
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)

- name: Upload new engine
uses: actions/upload-artifact@v4
with:
name: new-engine
path: new/build/engine


build-base:
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.base_ref }}
path: base
persist-credentials: false

- name: Install deps
run: sudo apt update && sudo apt install -y build-essential cmake

- name: Build base engine
run: |
cd base
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)

- name: Upload base engine
uses: actions/upload-artifact@v4
with:
name: base-engine
path: base/build/${{ github.event.inputs.output_exec }}


test:
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
runs-on: ubuntu-latest
needs: [build-new, build-base]

steps:
- name: Download engines
uses: actions/download-artifact@v4

- name: Install tools
env:
OUTPUT_EXEC: ${{ github.event.inputs.output_exec }}
run: |
sudo apt update
sudo apt install -y wget unzip

wget https://github.com/Disservin/fastchess/releases/download/v1.8.0-alpha/fastchess-linux-x86-64.tar
tar -xf fastchess-linux-x86-64.tar
chmod +x fastchess-linux-x86-64/fastchess
mv fastchess-linux-x86-64/fastchess fastchess

wget https://github.com/official-stockfish/books/raw/refs/heads/master/UHO_Lichess_4852_v1.epd.zip
unzip UHO_Lichess_4852_v1.epd.zip

wget https://github.com/michiguel/Ordo/releases/download/1.0/ordo-linux64
chmod +x ordo-linux64

chmod +x new-engine/engine
chmod +x base-engine/$OUTPUT_EXEC

- name: Run fastchess
env:
ELO0: ${{ github.event.inputs.elo0 }}
ELO1: ${{ github.event.inputs.elo1 }}
TC: ${{ github.event.inputs.tc }}
OUTPUT_EXEC: ${{ github.event.inputs.output_exec }}
ROUNDS: ${{ github.event.inputs.rounds }}
run: |
./fastchess -recover \
-engine cmd=new-engine/engine name=new \
-engine cmd=base-engine/$OUTPUT_EXEC name=base \
-openings file=UHO_Lichess_4852_v1.epd format=epd order=random \
-each tc=$TC \
-rounds $ROUNDS \
-concurrency $(nproc) \
-pgnout notation=san nodes=true file=games.pgn \
-sprt elo0=$ELO0 elo1=$ELO1 alpha=0.05 beta=0.05 | tee results.txt
./ordo-linux64 -o ratings.txt -- games.pgn
- name: Upload results
uses: actions/upload-artifact@v4
with:
name: results
path: |
games.pgn
ratings.txt
results.txt
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

# But not these directories and files
!*.cpp
!*.hpp
!*.h
!Makefile
!README.md
!LICENSE
!.gitignore
!CMakeLists.txt
!CMakeLists.txt
!.github/
!.github/**
!.clang-format
129 changes: 67 additions & 62 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,76 +1,81 @@
cmake_minimum_required(VERSION 3.10)
project(chess_engine)
project(cppchess_engine)

# Use C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Optional: enable warnings (MSVC specific flags)
if (MSVC)
add_compile_options(/W4 /permissive-)
else()
add_compile_options(-Wall -Wextra -pedantic)
endif()

# Add the source files
set(SOURCES
main.cpp
eval.cpp
search.cpp
tt.cpp
movepick.cpp
uci.cpp
ucioptions.cpp
timeman.cpp
include(FetchContent)
set(BUILD_TESTING OFF)
FetchContent_Declare(
chesslib
GIT_REPOSITORY https://github.com/winapiadmin/chesslib.git
GIT_TAG main
)
FetchContent_Declare(
tbprobe
GIT_REPOSITORY https://github.com/winapiadmin/tb_probing_tool.git
GIT_TAG main
)
set(BUILD_GAVIOTA OFF CACHE BOOL "Enable Gaviota TB probing" FORCE)
option(ENGINE_TUNING "enable Texel tuning (requires csv-parser)" OFF)
FetchContent_MakeAvailable(chesslib tbprobe)
set(SOURCES
"main.cpp"
"timeman.cpp"
"eval.cpp"
"tune.cpp"
"ucioption.cpp"
"tt.cpp"
"uci.cpp"
"search.cpp"
"score.cpp"
"movepick.cpp"
"tb.cpp"
)

# Define the executable
add_executable(${PROJECT_NAME} ${SOURCES})

# Threading support
find_package(Threads REQUIRED)
target_link_libraries(${PROJECT_NAME} Threads::Threads)

# Platform-specific threading configurations
if(WIN32)
if(MSVC)
# Windows with MSVC - uses Windows threading API
target_compile_definitions(${PROJECT_NAME} PRIVATE WIN32_LEAN_AND_MEAN)
elseif(MINGW)
# MinGW on Windows - uses pthread
target_compile_definitions(${PROJECT_NAME} PRIVATE _WIN32_WINNT=0x0601)
# MinGW might need explicit pthread linking
if(CMAKE_THREAD_LIBS_INIT)
target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
endif()
endif()
elseif(UNIX)
# Unix/Linux systems - uses pthread
if(CMAKE_THREAD_LIBS_INIT)
target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
endif()
# Some older systems might need explicit -pthread flag
if(CMAKE_USE_PTHREADS_INIT)
target_compile_options(${PROJECT_NAME} PRIVATE -pthread)
target_link_options(${PROJECT_NAME} PRIVATE -pthread)
endif()
if(ENGINE_TUNING)
list(APPEND SOURCES "tune_cmd.cpp")
endif()

# Optional: Add atomic library support for older compilers
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9")
target_link_libraries(${PROJECT_NAME} atomic)
endif()
add_executable(engine ${SOURCES})

# Set default build type if none is specified
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the build type (Debug, Release, etc.)" FORCE)
target_link_libraries(engine PRIVATE chesslib syzygy_probe)
target_include_directories(engine PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${chesslib_SOURCE_DIR})
execute_process(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
ERROR_QUIET
OUTPUT_VARIABLE GIT_SHA
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(GIT_SHA STREQUAL "")
set(GIT_SHA "unknown")
endif()
execute_process(
COMMAND git describe --tags --exact-match
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_TAG
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# Optional: Add specific compile flags per build type
if(NOT MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "-g -march=native -mtune=native")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -march=native -mtune=native -funroll-loops -ftree-vectorize -fomit-frame-pointer")
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT CMAKE_BUILD_TYPE)
set(BUILD_VERSION "debug-${GIT_SHA}")
elseif(GIT_TAG)
set(BUILD_VERSION "${GIT_TAG}")
else()
set(CMAKE_CXX_FLAGS_DEBUG "/Zi /Od")
set(CMAKE_CXX_FLAGS_RELEASE "/O2 /DNDEBUG")
set(BUILD_VERSION "release-${GIT_SHA}")
endif()

message(STATUS "Build Version: ${BUILD_VERSION}")
target_compile_definitions(engine PRIVATE BUILD_VERSION="${BUILD_VERSION}")
if (ENGINE_TUNING)
FetchContent_Declare(
csv
GIT_REPOSITORY https://github.com/vincentlaucsb/csv-parser.git
GIT_TAG master
)
FetchContent_MakeAvailable(csv)
target_link_libraries(engine PRIVATE csv)
target_compile_definitions(engine PRIVATE USE_CSV_PARSER)
endif()
Loading
Loading