Skip to content

Commit bc2a69b

Browse files
committed
feat: Improve search, evaluation, and move ordering
This commit introduces several enhancements to the search algorithm, evaluation function, and move ordering techniques to improve the engine's performance. - Makefile: Added -pthread flag to ensure proper threading support. - search.hpp: Reduced PV move array size, added nodes counter and seldepth. - move_ordering.hpp: Changed moveOrder signature to include ttMove, added see prototype. - CMakeLists.txt: Added threading support and platform-specific configurations. - eval.h: Removed unused popcount and lsb implementations, added MoveStack class, added trace function prototype. - main.cpp: Implemented benchmark mode, fixed bestmove output, added eval command. - move_ordering.cpp: Implemented SEE (Static Exchange Evaluation) for move ordering. - search.cpp: Implemented iterative deepening with aspiration windows, quiescence search, LMR (Late Move Reduction), and TT probing. - eval.cpp: Rewrote evaluation function with material, pawn structure, mobility, king safety, space, tempo, and PSQT (Piece-Square Table) evaluation. Added trace function to print evaluation breakdown.
1 parent bb7dea0 commit bc2a69b

File tree

9 files changed

+640
-625
lines changed

9 files changed

+640
-625
lines changed

CMakeLists.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,37 @@ set(SOURCES
2323

2424
# Define the executable
2525
add_executable(${PROJECT_NAME} ${SOURCES})
26+
27+
# Threading support
28+
find_package(Threads REQUIRED)
29+
target_link_libraries(${PROJECT_NAME} Threads::Threads)
30+
31+
# Platform-specific threading configurations
32+
if(WIN32)
33+
if(MSVC)
34+
# Windows with MSVC - uses Windows threading API
35+
target_compile_definitions(${PROJECT_NAME} PRIVATE WIN32_LEAN_AND_MEAN)
36+
elseif(MINGW)
37+
# MinGW on Windows - uses pthread
38+
target_compile_definitions(${PROJECT_NAME} PRIVATE _WIN32_WINNT=0x0601)
39+
# MinGW might need explicit pthread linking
40+
if(CMAKE_THREAD_LIBS_INIT)
41+
target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
42+
endif()
43+
endif()
44+
elseif(UNIX)
45+
# Unix/Linux systems - uses pthread
46+
if(CMAKE_THREAD_LIBS_INIT)
47+
target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
48+
endif()
49+
# Some older systems might need explicit -pthread flag
50+
if(CMAKE_USE_PTHREADS_INIT)
51+
target_compile_options(${PROJECT_NAME} PRIVATE -pthread)
52+
target_link_options(${PROJECT_NAME} PRIVATE -pthread)
53+
endif()
54+
endif()
55+
56+
# Optional: Add atomic library support for older compilers
57+
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9")
58+
target_link_libraries(${PROJECT_NAME} atomic)
59+
endif()

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ all: $(EXEC)
1313

1414
# Linking the object files into the executable
1515
$(EXEC): $(OBJ)
16-
$(CXX) $(LDFLAGS) -o $(EXEC) $(OBJ)
16+
$(CXX) $(LDFLAGS) -pthread -o $(EXEC) $(OBJ)
1717

1818
# Rule to build object files from source files
1919
%.o: %.cpp

0 commit comments

Comments
 (0)