Skip to content

Commit bfe0572

Browse files
committed
Update Catch2 and fix ToppleTune target
1 parent 949759a commit bfe0572

File tree

12 files changed

+209
-13361
lines changed

12 files changed

+209
-13361
lines changed

CMakeLists.txt

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.9)
1+
cmake_minimum_required(VERSION 3.11)
22
project(Topple)
33

44
set(CMAKE_CXX_STANDARD 17)
@@ -18,12 +18,12 @@ set(SOURCE_FILES
1818
pvs.h pvs.cpp
1919
syzygy/tbcore.h
2020
syzygy/tbprobe.h syzygy/tbprobe.cpp syzygy/tbresolve.h syzygy/tbresolve.cpp)
21-
set(TEST_FILES testing/catch.hpp testing/runner.cpp testing/util.h testing/util.cpp
22-
testing/tests/test_bb.cpp
23-
testing/tests/test_board.cpp
24-
testing/tests/test_perft.cpp
25-
testing/tests/test_see.cpp
26-
testing/tests/test_hash.cpp)
21+
set(TEST_FILES testing/runner.cpp testing/util.h testing/util.cpp
22+
testing/test_bb.cpp
23+
testing/test_board.cpp
24+
testing/test_perft.cpp
25+
testing/test_see.cpp
26+
testing/test_hash.cpp)
2727
set(TOPPLE_TUNE_FILES toppletuning/main.cpp
2828
toppletuning/game.cpp toppletuning/game.h
2929
toppletuning/toppletuner.cpp toppletuning/toppletuner.h
@@ -34,7 +34,18 @@ set(TEXEL_TUNE_FILES texeltuning/main.cpp
3434
# Add version definitions
3535
add_definitions(-DTOPPLE_VER="${TOPPLE_VERSION}")
3636

37+
# Set up Catch2 unit tests
38+
Include(FetchContent)
39+
FetchContent_Declare(
40+
Catch2
41+
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
42+
GIT_TAG v2.13.3)
43+
FetchContent_MakeAvailable(Catch2)
3744
add_executable(ToppleTest ${SOURCE_FILES} ${TEST_FILES})
45+
target_link_libraries(ToppleTest Catch2::Catch2)
46+
target_compile_options(ToppleTest PUBLIC -march=native -O3)
47+
add_test(NAME ToppleTest COMMAND ToppleTest)
48+
3849
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
3950
add_executable(Topple ${SOURCE_FILES} main.cpp)
4051
add_executable(ToppleTune ${SOURCE_FILES} ${TOPPLE_TUNE_FILES})
@@ -44,19 +55,17 @@ add_executable(ToppleTexelTune ${SOURCE_FILES} ${TEXEL_TUNE_FILES})
4455
set(THREADS_PREFER_PTHREAD_FLAG ON)
4556
find_package(Threads REQUIRED)
4657
target_link_libraries(Topple Threads::Threads)
47-
target_link_libraries(ToppleTest Threads::Threads)
4858
target_link_libraries(ToppleTune Threads::Threads)
4959
target_link_libraries(ToppleTexelTune Threads::Threads)
5060

5161
# Set -march for the Topple target, only enable asserts for tests
52-
target_compile_options(ToppleTest PUBLIC -march=native -O3)
5362
target_compile_options(Topple PUBLIC -march=native -O3 -DNDEBUG)
5463
target_compile_options(ToppleTune PUBLIC -DTOPPLE_TUNE -O3 -march=native -DNDEBUG)
5564
target_compile_options(ToppleTexelTune PUBLIC -DTEXEL_TUNE -O3 -march=native -DNDEBUG)
5665

5766
# Configure the "Release" target
5867
if (CMAKE_BUILD_TYPE STREQUAL "Release")
59-
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
68+
set(CMAKE_EXE_LINKER_FLAGS "-static -static-libgcc -static-libstdc++")
6069

6170
add_custom_target(Release)
6271
add_executable(Topple_${TOPPLE_VERSION}_legacy ${SOURCE_FILES} main.cpp)

movesort.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,6 @@ movesort_t::movesort_t(GenMode mode, const heuristic_set_t &heuristics, const b
1010
killer_1 = heur.killers.primary(ply);
1111
killer_2 = heur.killers.secondary(ply);
1212
killer_3 = ply > 2 ? heur.killers.primary(ply - 2) : EMPTY_MOVE;
13-
14-
if(killer_1 == hash_move) {
15-
killer_1 = EMPTY_MOVE;
16-
}
17-
18-
if(killer_2 == killer_1 || killer_2 == hash_move) {
19-
killer_2 = EMPTY_MOVE;
20-
}
21-
22-
if(killer_3 == killer_2 || killer_3 == killer_1 || killer_3 == hash_move) {
23-
killer_3 = EMPTY_MOVE;
24-
}
2513
}
2614

2715
// Pray that the compiler optimises tail recursion here - this is a very hot method
@@ -73,7 +61,9 @@ move_t movesort_t::next(GenStage &stage, int &score, bool skip_quiets) {
7361

7462
// Score quiets
7563
for (int i = 0; i < main_buf_size; i++) {
76-
if (main_buf[i] == killer_1) {
64+
if (main_buf[i] == hash_move) {
65+
main_scores[i] = -1000000000;
66+
} else if (main_buf[i] == killer_1) {
7767
main_scores[i] = 1000000003;
7868
} else if (main_buf[i] == killer_2) {
7969
main_scores[i] = 1000000002;

0 commit comments

Comments
 (0)