Skip to content

Commit e68a692

Browse files
committed
a "bit" of update and rewritten search engine to fix issue #2
1 parent a91eddd commit e68a692

21 files changed

+2071
-1449
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
*
33

44
# But not these directories and files
5-
!*/
65
!*.cpp
76
!*.hpp
87
!*.h
98
!Makefile
109
!README.md
1110
!LICENSE
1211
!.gitignore
12+
!CMakeLists.txt

CMakeLists.txt

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
project(chess_engine)
3+
4+
# Use C++17
5+
set(CMAKE_CXX_STANDARD 17)
6+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7+
8+
# Optional: enable warnings (MSVC specific flags)
9+
if (MSVC)
10+
add_compile_options(/W4 /permissive-)
11+
else()
12+
add_compile_options(-Wall -Wextra -pedantic)
13+
endif()
14+
15+
# Add the source files
16+
set(SOURCES
17+
main.cpp
18+
eval.cpp
19+
search.cpp
20+
tt.cpp
21+
movepick.cpp
22+
uci.cpp
23+
ucioptions.cpp
24+
timeman.cpp
25+
)
26+
27+
# Define the executable
28+
add_executable(${PROJECT_NAME} ${SOURCES})
29+
30+
# Threading support
31+
find_package(Threads REQUIRED)
32+
target_link_libraries(${PROJECT_NAME} Threads::Threads)
33+
34+
# Platform-specific threading configurations
35+
if(WIN32)
36+
if(MSVC)
37+
# Windows with MSVC - uses Windows threading API
38+
target_compile_definitions(${PROJECT_NAME} PRIVATE WIN32_LEAN_AND_MEAN)
39+
elseif(MINGW)
40+
# MinGW on Windows - uses pthread
41+
target_compile_definitions(${PROJECT_NAME} PRIVATE _WIN32_WINNT=0x0601)
42+
# MinGW might need explicit pthread linking
43+
if(CMAKE_THREAD_LIBS_INIT)
44+
target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
45+
endif()
46+
endif()
47+
elseif(UNIX)
48+
# Unix/Linux systems - uses pthread
49+
if(CMAKE_THREAD_LIBS_INIT)
50+
target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
51+
endif()
52+
# Some older systems might need explicit -pthread flag
53+
if(CMAKE_USE_PTHREADS_INIT)
54+
target_compile_options(${PROJECT_NAME} PRIVATE -pthread)
55+
target_link_options(${PROJECT_NAME} PRIVATE -pthread)
56+
endif()
57+
endif()
58+
59+
# Optional: Add atomic library support for older compilers
60+
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9")
61+
target_link_libraries(${PROJECT_NAME} atomic)
62+
endif()
63+
64+
# Set default build type if none is specified
65+
if(NOT CMAKE_BUILD_TYPE)
66+
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the build type (Debug, Release, etc.)" FORCE)
67+
endif()
68+
69+
# Optional: Add specific compile flags per build type
70+
if(NOT MSVC)
71+
set(CMAKE_CXX_FLAGS_DEBUG "-g -march=native -mtune=native")
72+
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -march=native -mtune=native -funroll-loops -ftree-vectorize -fomit-frame-pointer")
73+
else()
74+
set(CMAKE_CXX_FLAGS_DEBUG "/Zi /Od")
75+
set(CMAKE_CXX_FLAGS_RELEASE "/O2 /DNDEBUG")
76+
endif()

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
CXX = g++
33

44
# Source files and object files
5-
SRC = main.cpp eval.cpp search.cpp tt.cpp move_ordering.cpp
5+
SRC = main.cpp eval.cpp search.cpp tt.cpp movepick.cpp timeman.cpp uci.cpp ucioptions.cpp
66
OBJ = $(SRC:.cpp=.o)
77

88
# Output file

0 commit comments

Comments
 (0)