Skip to content

Commit 381978a

Browse files
committed
disabled library testing
1 parent 0f597cd commit 381978a

3 files changed

Lines changed: 25 additions & 16 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ project(cppchess_engine)
55
set(CMAKE_CXX_STANDARD 17)
66
set(CMAKE_CXX_STANDARD_REQUIRED ON)
77
include(FetchContent)
8+
set(BUILD_TESTING OFF)
89
FetchContent_Declare(
910
chesslib
1011
GIT_REPOSITORY https://github.com/winapiadmin/chesslib.git
11-
GIT_TAG 46-null-move-modification-fix
12+
GIT_TAG main
1213
)
1314
FetchContent_MakeAvailable(chesslib)
1415
add_executable(engine "main.cpp" "timeman.cpp" "timeman.h" "eval.h" "eval.cpp" "tune.h" "ucioption.h" "tune.cpp" "ucioption.cpp" "tt.h" "tt.cpp" "uci.cpp" "uci.h" "search.h" "search.cpp" "score.h" "score.cpp" "movepick.h" "movepick.cpp")

eval.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ Value eg_king_table[64] = {-74, -35, -18, -18, -11, 15, 4, -17, -12, 17, 14,
9797
-17, -53, -34, -21, -11, -28, -14, -24, -43};
9898

9999
Value *mg_pesto_table[] = {
100-
{0}, mg_pawn_table, mg_knight_table, mg_bishop_table,
100+
nullptr, mg_pawn_table, mg_knight_table, mg_bishop_table,
101101
mg_rook_table, mg_queen_table, mg_king_table};
102102

103103
Value *eg_pesto_table[] = {
104-
{0}, eg_pawn_table, eg_knight_table, eg_bishop_table,
104+
nullptr, eg_pawn_table, eg_knight_table, eg_bishop_table,
105105
eg_rook_table, eg_queen_table, eg_king_table};
106106

107107
Value eval(const chess::Board &board) {

search.cpp

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Value qsearch(Board &board, Value alpha, Value beta, Session &session,
5656
}
5757
return maxScore;
5858
}
59-
Value doSearch(Board &board, int depth, Value alpha, Value beta,
59+
Value doSearch(Board board, int depth, Value alpha, Value beta,
6060
Session &session, int ply = 0) {
6161
if (ply >= MAX_PLY - 1)
6262
return eval::eval(board);
@@ -118,25 +118,34 @@ Value doSearch(Board &board, int depth, Value alpha, Value beta,
118118
Value score =
119119
doSearch(board, depth - 1 - R, -beta, -beta + 1, session, ply + 1);
120120

121-
if (score == VALUE_NONE)
121+
if (score == VALUE_NONE) {
122+
board.undoMove();
122123
return VALUE_NONE;
124+
}
123125
score = -score;
124126
board.undoMove();
125127
if (score >= beta)
126-
return beta;
128+
return score;
127129
}
128-
for (Move move : moves) {
130+
for (size_t i = 0; i < moves.size(); ++i) {
131+
Move move = moves[i];
132+
int reduction = (i >= 3 && depth >= 3 && !board.isCapture(move)) ? 1 : 0;
129133
board.doMove(move);
130-
Value childScore =
131-
doSearch(board, depth - 1, -beta, -alpha, session, ply + 1);
132-
133-
board.undoMove();
134-
135-
if (childScore == VALUE_NONE)
134+
Value childScore = doSearch(board, depth - 1 - reduction, -alpha - 1, -alpha, session, ply + 1);
135+
if (childScore == VALUE_NONE){
136+
board.undoMove();
136137
return VALUE_NONE;
137-
138+
}
138139
Value score = -childScore;
139-
140+
if (reduction > 0 && score > alpha) {
141+
childScore = doSearch(board, depth - 1, -beta, -alpha, session, ply + 1);
142+
board.undoMove();
143+
if (childScore == VALUE_NONE) return VALUE_NONE;
144+
score = -childScore;
145+
}
146+
else
147+
board.undoMove();
148+
140149
if (score > maxScore) {
141150
maxScore = score;
142151
update_pv(session.pv[ply], move, session.pv[ply + 1]);
@@ -194,7 +203,6 @@ void search::search(const chess::Board &board,
194203
// since MAX_PLY=64
195204
session.pv[_][j] = Move::none();
196205
}
197-
session.nodes = 0;
198206
auto board_ = board;
199207
Value score_ =
200208
doSearch(board_, i, -VALUE_INFINITE, VALUE_INFINITE, session);

0 commit comments

Comments
 (0)