Skip to content

Commit 55b4b0e

Browse files
committed
Apply clang-format
1 parent 3998d8a commit 55b4b0e

1 file changed

Lines changed: 42 additions & 46 deletions

File tree

search.cpp

Lines changed: 42 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -131,86 +131,82 @@ Value doSearch(Board board, int depth, Value alpha, Value beta,
131131
Move move = moves[i];
132132

133133
bool isCapture = board.isCapture(move);
134-
bool givesCheck = board.givesCheck(move)!=CheckType::NO_CHECK;
134+
bool givesCheck = board.givesCheck(move) != CheckType::NO_CHECK;
135135

136136
// --- LMR reduction ---
137137
int reduction = 0;
138138
if (i >= 3 && depth >= 3 && !isCapture && !givesCheck) {
139-
reduction = 1 + (int)(i / 6) + (depth / 8);
139+
reduction = 1 + (int)(i / 6) + (depth / 8);
140140

141-
// history heuristic: good moves get reduced less
142-
if (movepick::historyHeuristic[(int)move.from()][(int)move.to()] > 0)
143-
reduction--;
141+
// history heuristic: good moves get reduced less
142+
if (movepick::historyHeuristic[(int)move.from()][(int)move.to()] > 0)
143+
reduction--;
144144

145-
reduction = std::max(0, reduction);
146-
reduction = std::min(reduction, depth - 2);
145+
reduction = std::max(0, reduction);
146+
reduction = std::min(reduction, depth - 2);
147147
}
148148

149149
board.doMove(move);
150150

151151
Value score;
152152

153153
if (i == 0) {
154-
// --- First move: full window (PVS root move) ---
155-
score = -doSearch(board, depth - 1, -beta, -alpha, session, ply + 1);
154+
// --- First move: full window (PVS root move) ---
155+
score = -doSearch(board, depth - 1, -beta, -alpha, session, ply + 1);
156156

157-
if (score == VALUE_NONE){
158-
board.undoMove();
159-
return VALUE_NONE;
160-
}
157+
if (score == VALUE_NONE) {
158+
board.undoMove();
159+
return VALUE_NONE;
160+
}
161161
} else {
162-
// --- Null-window search (PVS + LMR) ---
163-
score = doSearch(board,
164-
depth - 1 - reduction,
165-
-alpha - 1, -alpha,
166-
session, ply + 1);
162+
// --- Null-window search (PVS + LMR) ---
163+
score = doSearch(board, depth - 1 - reduction, -alpha - 1, -alpha,
164+
session, ply + 1);
165+
if (score == VALUE_NONE) {
166+
board.undoMove();
167+
return VALUE_NONE;
168+
}
169+
score = -score;
170+
// --- Re-search if it improves alpha ---
171+
if (score > alpha) {
172+
score = doSearch(board, depth - 1, -beta, -alpha, session, ply + 1);
167173
if (score == VALUE_NONE) {
168-
board.undoMove();
169-
return VALUE_NONE;
170-
}
171-
score=-score;
172-
// --- Re-search if it improves alpha ---
173-
if (score > alpha) {
174-
score = doSearch(board,
175-
depth - 1,
176-
-beta, -alpha,
177-
session, ply + 1);
178-
if (score == VALUE_NONE) {
179-
board.undoMove();
180-
return VALUE_NONE;
181-
}
182-
score = -score;
174+
board.undoMove();
175+
return VALUE_NONE;
183176
}
177+
score = -score;
178+
}
184179
}
185180

186181
board.undoMove();
187182

188183
if (score > maxScore) {
189-
maxScore = score;
190-
update_pv(session.pv[ply], move, session.pv[ply + 1]);
184+
maxScore = score;
185+
update_pv(session.pv[ply], move, session.pv[ply + 1]);
191186
}
192187

193188
if (score > alpha) {
194-
alpha = score;
189+
alpha = score;
195190

196-
if (!isCapture)
197-
movepick::historyHeuristic[(int)move.from()][(int)move.to()] += depth * depth;
191+
if (!isCapture)
192+
movepick::historyHeuristic[(int)move.from()][(int)move.to()] +=
193+
depth * depth;
198194
}
199195

200196
if (alpha >= beta) {
201-
// killer moves
202-
if (!isCapture) {
203-
if (movepick::killerMoves[ply][0] != move) {
204-
movepick::killerMoves[ply][1] = movepick::killerMoves[ply][0];
205-
movepick::killerMoves[ply][0] = move;
206-
}
197+
// killer moves
198+
if (!isCapture) {
199+
if (movepick::killerMoves[ply][0] != move) {
200+
movepick::killerMoves[ply][1] = movepick::killerMoves[ply][0];
201+
movepick::killerMoves[ply][0] = move;
207202
}
208-
break;
203+
}
204+
break;
209205
}
210206

211207
if (session.tm.elapsed() >= session.tm.optimum() ||
212208
stopSearch.load(std::memory_order_relaxed))
213-
return VALUE_NONE;
209+
return VALUE_NONE;
214210
}
215211

216212
if (maxScore != -VALUE_INFINITE) {

0 commit comments

Comments
 (0)