Skip to content

Commit 19958f3

Browse files
committed
Apply clang-format
1 parent 598da59 commit 19958f3

5 files changed

Lines changed: 40 additions & 38 deletions

File tree

‎eval.cpp‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "eval.h"
22
#include "tune.h"
3-
#include <position.h>
43
#include <iostream>
4+
#include <position.h>
55
using namespace chess;
66
using namespace engine::eval;
77

@@ -114,7 +114,7 @@ Value mgMobility[] = {
114114
};
115115

116116
Value egMobility[] = {0, 0, 2, 5, 3, 2, 0};
117-
Value spaceWeight=28;
117+
Value spaceWeight = 28;
118118
// tuning slop here
119119
Value eval(const chess::Board &board) {
120120
constexpr int KnightPhase = 1;
@@ -128,10 +128,10 @@ Value eval(const chess::Board &board) {
128128
int egScore = 0;
129129
int phase = 0;
130130
{
131-
mgScore=egScore=board.sideToMove() == WHITE?spaceWeight:0;
132-
Bitboard occ = board.occ(), occ2=occ;
131+
mgScore = egScore = board.sideToMove() == WHITE ? spaceWeight : 0;
132+
Bitboard occ = board.occ(), occ2 = occ;
133133
while (occ) {
134-
Square sq = (Square)pop_lsb(occ),_sq=sq;
134+
Square sq = (Square)pop_lsb(occ), _sq = sq;
135135
auto p = board.at(sq);
136136
int _sign = 1;
137137
if (color_of(p) == BLACK) {
@@ -296,12 +296,14 @@ Value eval(const chess::Board &board) {
296296
int endF = std::min(7, (int)kf + 1);
297297
for (int adjF = startF; adjF <= endF; adjF++) {
298298
if (c == WHITE) {
299-
for (int r = rank_of(kingSq) + 1; r <= std::min(7, rank_of(kingSq) + 3); r++) {
299+
for (int r = rank_of(kingSq) + 1; r <= std::min(7, rank_of(kingSq) + 3);
300+
r++) {
300301
if (pawns & (Bitboard(1) << make_sq((File)adjF, (Rank)r)))
301302
shelter += 10 - (r - rank_of(kingSq) - 1) * 3;
302303
}
303304
} else {
304-
for (int r = rank_of(kingSq) - 1; r >= std::max(0, rank_of(kingSq) - 3); r--) {
305+
for (int r = rank_of(kingSq) - 1; r >= std::max(0, rank_of(kingSq) - 3);
306+
r--) {
305307
if (pawns & (Bitboard(1) << make_sq((File)adjF, (Rank)r)))
306308
shelter += 10 - (rank_of(kingSq) - r - 1) * 3;
307309
}
@@ -317,9 +319,8 @@ Value eval(const chess::Board &board) {
317319
return finalScore;
318320
}
319321
Value piece_value(PieceType pt) {
320-
Value pieces[] = {0, PawnValue, KnightValue,
321-
BishopValue, RookValue, QueenValue,
322-
KingValue};
322+
Value pieces[] = {0, PawnValue, KnightValue, BishopValue,
323+
RookValue, QueenValue, KingValue};
323324
return pieces[pt];
324325
}
325326
} // namespace engine::eval

‎main.cpp‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ int main() {
1111
std::cout << std::unitbuf;
1212
std::cout << "cppchess_engine version " << BUILD_VERSION << '\n';
1313
options.add("Move Overhead", Option(10, 0, 1000));
14-
options.add("Hash", Option(16, 1, 1 << 25,
15-
[](const Option &o) {
16-
search::tt.resize(int(o));
17-
return std::nullopt;
18-
}));
14+
options.add("Hash", Option(16, 1, 1 << 25, [](const Option &o) {
15+
search::tt.resize(int(o));
16+
return std::nullopt;
17+
}));
1918

2019
options.add("Clear Hash", Option(+[](const Option &) {
2120
search::tt.clear();

‎movepick.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using engine::eval::piece_value;
77
namespace engine::movepick {
88

99
void orderMoves(chess::Board &board, chess::Movelist &moves, chess::Move ttMove,
10-
int ply, const engine::search::Session& session) {
10+
int ply, const engine::search::Session &session) {
1111
std::vector<std::pair<chess::Move, Value>> scoredMoves;
1212
scoredMoves.reserve(moves.size());
1313

‎movepick.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#pragma once
22
#include <fwd_decl.h>
3-
namespace engine::search{
3+
namespace engine::search {
44
struct Session;
55
} // namespace engine::search
66
namespace engine::movepick {
7-
void orderMoves(chess::Board &, chess::Movelist &, chess::Move, int, const engine::search::Session&);
7+
void orderMoves(chess::Board &, chess::Movelist &, chess::Move, int,
8+
const engine::search::Session &);
89
} // namespace engine::movepick

‎search.cpp‎

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -354,28 +354,29 @@ void search::search(const chess::Board &board,
354354

355355
// Aspiration windows
356356
if (i >= 3 && prevScore != VALUE_NONE) {
357-
Value delta = Value(17);
358-
Value alpha = std::max(prevScore - delta, -VALUE_INFINITE);
359-
Value beta = std::min(prevScore + delta, VALUE_INFINITE);
360-
361-
score_ = doSearch(board_, i, alpha, beta, session);
362-
363-
if (score_ != VALUE_NONE) {
364-
if (score_ <= alpha) {
365-
alpha = -VALUE_INFINITE;
366-
score_ = doSearch(board_, i, alpha, beta, session);
367-
}
368-
if (score_ >= beta && score_ != VALUE_NONE) {
369-
beta = VALUE_INFINITE;
370-
score_ = doSearch(board_, i, alpha, beta, session);
371-
}
372-
if ((score_ <= alpha || score_ >= beta) && score_ != VALUE_NONE)
373-
score_ = doSearch(board_, i, -VALUE_INFINITE, VALUE_INFINITE, session);
374-
} else {
375-
score_ = doSearch(board_, i, -VALUE_INFINITE, VALUE_INFINITE, session);
357+
Value delta = Value(17);
358+
Value alpha = std::max(prevScore - delta, -VALUE_INFINITE);
359+
Value beta = std::min(prevScore + delta, VALUE_INFINITE);
360+
361+
score_ = doSearch(board_, i, alpha, beta, session);
362+
363+
if (score_ != VALUE_NONE) {
364+
if (score_ <= alpha) {
365+
alpha = -VALUE_INFINITE;
366+
score_ = doSearch(board_, i, alpha, beta, session);
376367
}
377-
} else {
368+
if (score_ >= beta && score_ != VALUE_NONE) {
369+
beta = VALUE_INFINITE;
370+
score_ = doSearch(board_, i, alpha, beta, session);
371+
}
372+
if ((score_ <= alpha || score_ >= beta) && score_ != VALUE_NONE)
373+
score_ =
374+
doSearch(board_, i, -VALUE_INFINITE, VALUE_INFINITE, session);
375+
} else {
378376
score_ = doSearch(board_, i, -VALUE_INFINITE, VALUE_INFINITE, session);
377+
}
378+
} else {
379+
score_ = doSearch(board_, i, -VALUE_INFINITE, VALUE_INFINITE, session);
379380
}
380381
prevScore = score_;
381382
if (session.tm.elapsed() >= session.tm.optimum() ||

0 commit comments

Comments
 (0)