From 7ae3c05795e79c9bd945607cdcfb08198f4c4b45 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Nicolet?= Date: Fri, 23 Sep 2016 19:28:34 +0200 Subject: [PATCH] Rename shift_bb() to shift() Rename shift_bb() to shift(), and DELTA_S to SOUTH, etc. to improve code readability, especially in evaluate.cpp when they are used together: old b = shift_bb(pos.pieces(PAWN)) new b = shift(pos.pieces(PAWN)) While there fix some small code style issues. No functional change. --- src/bitbase.cpp | 14 +++++++------- src/bitboard.cpp | 4 ++-- src/bitboard.h | 12 ++++++------ src/endgame.cpp | 10 +++++----- src/evaluate.cpp | 39 ++++++++++++++++++++------------------- src/movegen.cpp | 48 ++++++++++++++++++++++++------------------------ src/pawns.cpp | 31 +++++++++++++++++-------------- src/psqt.cpp | 5 +++-- src/search.cpp | 4 ++-- src/timeman.cpp | 8 ++++---- src/tt.cpp | 8 ++++---- src/types.h | 22 ++++++++++------------ 12 files changed, 104 insertions(+), 101 deletions(-) diff --git a/src/bitbase.cpp b/src/bitbase.cpp index 25570e12..4170952b 100644 --- a/src/bitbase.cpp +++ b/src/bitbase.cpp @@ -123,9 +123,9 @@ namespace { // Immediate win if a pawn can be promoted without getting captured else if ( us == WHITE && rank_of(psq) == RANK_7 - && ksq[us] != psq + DELTA_N - && ( distance(ksq[~us], psq + DELTA_N) > 1 - || (StepAttacksBB[KING][ksq[us]] & (psq + DELTA_N)))) + && ksq[us] != psq + NORTH + && ( distance(ksq[~us], psq + NORTH) > 1 + || (StepAttacksBB[KING][ksq[us]] & (psq + NORTH)))) result = WIN; // Immediate draw if it is a stalemate or a king captures undefended pawn @@ -166,12 +166,12 @@ namespace { if (Us == WHITE) { if (rank_of(psq) < RANK_7) // Single push - r |= db[index(Them, ksq[Them], ksq[Us], psq + DELTA_N)]; + r |= db[index(Them, ksq[Them], ksq[Us], psq + NORTH)]; if ( rank_of(psq) == RANK_2 // Double push - && psq + DELTA_N != ksq[Us] - && psq + DELTA_N != ksq[Them]) - r |= db[index(Them, ksq[Them], ksq[Us], psq + DELTA_N + DELTA_N)]; + && psq + NORTH != ksq[Us] + && psq + NORTH != ksq[Them]) + r |= db[index(Them, ksq[Them], ksq[Us], psq + NORTH + NORTH)]; } return result = r & Good ? Good : r & UNKNOWN ? UNKNOWN : Bad; diff --git a/src/bitboard.cpp b/src/bitboard.cpp index 318ce049..e329ab52 100644 --- a/src/bitboard.cpp +++ b/src/bitboard.cpp @@ -205,8 +205,8 @@ void Bitboards::init() { StepAttacksBB[make_piece(c, pt)][s] |= to; } - Square RookDeltas[] = { DELTA_N, DELTA_E, DELTA_S, DELTA_W }; - Square BishopDeltas[] = { DELTA_NE, DELTA_SE, DELTA_SW, DELTA_NW }; + Square RookDeltas[] = { NORTH, EAST, SOUTH, WEST }; + Square BishopDeltas[] = { NORTH_EAST, SOUTH_EAST, SOUTH_WEST, NORTH_WEST }; init_magics(RookTable, RookAttacks, RookMagics, RookMasks, RookShifts, RookDeltas, magic_index); init_magics(BishopTable, BishopAttacks, BishopMagics, BishopMasks, BishopShifts, BishopDeltas, magic_index); diff --git a/src/bitboard.h b/src/bitboard.h index 390966e3..715f6c4a 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -124,13 +124,13 @@ inline Bitboard file_bb(Square s) { } -/// shift_bb() moves a bitboard one step along direction Delta. Mainly for pawns +/// shift() moves a bitboard one step along direction D. Mainly for pawns -template -inline Bitboard shift_bb(Bitboard b) { - return Delta == DELTA_N ? b << 8 : Delta == DELTA_S ? b >> 8 - : Delta == DELTA_NE ? (b & ~FileHBB) << 9 : Delta == DELTA_SE ? (b & ~FileHBB) >> 7 - : Delta == DELTA_NW ? (b & ~FileABB) << 7 : Delta == DELTA_SW ? (b & ~FileABB) >> 9 +template +inline Bitboard shift(Bitboard b) { + return D == NORTH ? b << 8 : D == SOUTH ? b >> 8 + : D == NORTH_EAST ? (b & ~FileHBB) << 9 : D == SOUTH_EAST ? (b & ~FileHBB) >> 7 + : D == NORTH_WEST ? (b & ~FileABB) << 7 : D == SOUTH_WEST ? (b & ~FileABB) >> 9 : 0; } diff --git a/src/endgame.cpp b/src/endgame.cpp index 04469e87..cbca34be 100644 --- a/src/endgame.cpp +++ b/src/endgame.cpp @@ -259,8 +259,8 @@ Value Endgame::operator()(const Position& pos) const { result = Value(80) - 8 * distance(wksq, psq); else - result = Value(200) - 8 * ( distance(wksq, psq + DELTA_S) - - distance(bksq, psq + DELTA_S) + result = Value(200) - 8 * ( distance(wksq, psq + SOUTH) + - distance(bksq, psq + SOUTH) - distance(psq, queeningSq)); return strongSide == pos.side_to_move() ? result : -result; @@ -496,7 +496,7 @@ ScaleFactor Endgame::operator()(const Position& pos) const { // If the defending king blocks the pawn and the attacking king is too far // away, it's a draw. if ( r <= RANK_5 - && bksq == wpsq + DELTA_N + && bksq == wpsq + NORTH && distance(wksq, wpsq) - tempo >= 2 && distance(wksq, brsq) - tempo >= 2) return SCALE_FACTOR_DRAW; @@ -517,10 +517,10 @@ ScaleFactor Endgame::operator()(const Position& pos) const { && file_of(wrsq) == f && wrsq < wpsq && (distance(wksq, queeningSq) < distance(bksq, queeningSq) - 2 + tempo) - && (distance(wksq, wpsq + DELTA_N) < distance(bksq, wpsq + DELTA_N) - 2 + tempo) + && (distance(wksq, wpsq + NORTH) < distance(bksq, wpsq + NORTH) - 2 + tempo) && ( distance(bksq, wrsq) + tempo >= 3 || ( distance(wksq, queeningSq) < distance(bksq, wrsq) + tempo - && (distance(wksq, wpsq + DELTA_N) < distance(bksq, wrsq) + tempo)))) + && (distance(wksq, wpsq + NORTH) < distance(bksq, wrsq) + tempo)))) return ScaleFactor( SCALE_FACTOR_MAX - 8 * distance(wpsq, queeningSq) - 2 * distance(wksq, queeningSq)); diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 30958388..d1799d60 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -156,7 +156,8 @@ namespace { // ThreatBySafePawn[PieceType] contains bonuses according to which piece // type is attacked by a pawn which is protected or is not attacked. const Score ThreatBySafePawn[PIECE_TYPE_NB] = { - S(0, 0), S(0, 0), S(176, 139), S(131, 127), S(217, 218), S(203, 215) }; + S(0, 0), S(0, 0), S(176, 139), S(131, 127), S(217, 218), S(203, 215) + }; // Threat[by minor/by rook][attacked PieceType] contains // bonuses according to which piece type attacks which one. @@ -223,8 +224,8 @@ namespace { template void eval_init(const Position& pos, EvalInfo& ei) { - const Color Them = (Us == WHITE ? BLACK : WHITE); - const Square Down = (Us == WHITE ? DELTA_S : DELTA_N); + const Color Them = (Us == WHITE ? BLACK : WHITE); + const Square Down = (Us == WHITE ? SOUTH : NORTH); ei.pinnedPieces[Us] = pos.pinned_pieces(Us); Bitboard b = ei.attackedBy[Them][KING]; @@ -235,7 +236,7 @@ namespace { // Init king safety tables only if we are going to use them if (pos.non_pawn_material(Us) >= QueenValueMg) { - ei.kingRing[Them] = b | shift_bb(b); + ei.kingRing[Them] = b | shift(b); b &= ei.attackedBy[Us][PAWN]; ei.kingAttackersCount[Us] = popcount(b); ei.kingAdjacentZoneAttacksCount[Us] = ei.kingAttackersWeight[Us] = 0; @@ -321,7 +322,7 @@ namespace { && pos.is_chess960() && (s == relative_square(Us, SQ_A1) || s == relative_square(Us, SQ_H1))) { - Square d = pawn_push(Us) + (file_of(s) == FILE_A ? DELTA_E : DELTA_W); + Square d = pawn_push(Us) + (file_of(s) == FILE_A ? EAST : WEST); if (pos.piece_on(s + d) == make_piece(Us, PAWN)) score -= !pos.empty(s + d + pawn_push(Us)) ? TrappedBishopA1H1 * 4 : pos.piece_on(s + d + d) == make_piece(Us, PAWN) ? TrappedBishopA1H1 * 2 @@ -391,8 +392,8 @@ namespace { template Score evaluate_king(const Position& pos, const EvalInfo& ei) { - const Color Them = (Us == WHITE ? BLACK : WHITE); - const Square Up = (Us == WHITE ? DELTA_N : DELTA_S); + const Color Them = (Us == WHITE ? BLACK : WHITE); + const Square Up = (Us == WHITE ? NORTH : SOUTH); Bitboard undefended, b, b1, b2, safe, other; int kingDanger; @@ -438,7 +439,7 @@ namespace { // ... and some other potential checks, only requiring the square to be // safe from pawn-attacks, and not being occupied by a blocked pawn. other = ~( ei.attackedBy[Us][PAWN] - | (pos.pieces(Them, PAWN) & shift_bb(pos.pieces(PAWN)))); + | (pos.pieces(Them, PAWN) & shift(pos.pieces(PAWN)))); b1 = pos.attacks_from(ksq); b2 = pos.attacks_from(ksq); @@ -506,12 +507,12 @@ namespace { template Score evaluate_threats(const Position& pos, const EvalInfo& ei) { - const Color Them = (Us == WHITE ? BLACK : WHITE); - const Square Up = (Us == WHITE ? DELTA_N : DELTA_S); - const Square Left = (Us == WHITE ? DELTA_NW : DELTA_SE); - const Square Right = (Us == WHITE ? DELTA_NE : DELTA_SW); - const Bitboard TRank2BB = (Us == WHITE ? Rank2BB : Rank7BB); - const Bitboard TRank7BB = (Us == WHITE ? Rank7BB : Rank2BB); + const Color Them = (Us == WHITE ? BLACK : WHITE); + const Square Up = (Us == WHITE ? NORTH : SOUTH); + const Square Left = (Us == WHITE ? NORTH_WEST : SOUTH_EAST); + const Square Right = (Us == WHITE ? NORTH_EAST : SOUTH_WEST); + const Bitboard TRank2BB = (Us == WHITE ? Rank2BB : Rank7BB); + const Bitboard TRank7BB = (Us == WHITE ? Rank7BB : Rank2BB); enum { Minor, Rook }; @@ -531,7 +532,7 @@ namespace { b = pos.pieces(Us, PAWN) & ( ~ei.attackedBy[Them][ALL_PIECES] | ei.attackedBy[Us][ALL_PIECES]); - safeThreats = (shift_bb(b) | shift_bb(b)) & weak; + safeThreats = (shift(b) | shift(b)) & weak; if (weak ^ safeThreats) score += ThreatByHangingPawn; @@ -568,13 +569,13 @@ namespace { // Bonus if some pawns can safely push and attack an enemy piece b = pos.pieces(Us, PAWN) & ~TRank7BB; - b = shift_bb(b | (shift_bb(b & TRank2BB) & ~pos.pieces())); + b = shift(b | (shift(b & TRank2BB) & ~pos.pieces())); b &= ~pos.pieces() & ~ei.attackedBy[Them][PAWN] & (ei.attackedBy[Us][ALL_PIECES] | ~ei.attackedBy[Them][ALL_PIECES]); - b = (shift_bb(b) | shift_bb(b)) + b = (shift(b) | shift(b)) & pos.pieces(Them) & ~ei.attackedBy[Us][PAWN]; @@ -803,8 +804,8 @@ Value Eval::evaluate(const Position& pos) { // Pawns blocked or on ranks 2 and 3 will be excluded from the mobility area Bitboard blockedPawns[] = { - pos.pieces(WHITE, PAWN) & (shift_bb(pos.pieces()) | Rank2BB | Rank3BB), - pos.pieces(BLACK, PAWN) & (shift_bb(pos.pieces()) | Rank7BB | Rank6BB) + pos.pieces(WHITE, PAWN) & (shift(pos.pieces()) | Rank2BB | Rank3BB), + pos.pieces(BLACK, PAWN) & (shift(pos.pieces()) | Rank7BB | Rank6BB) }; // Do not include in mobility area squares protected by enemy pawns, or occupied diff --git a/src/movegen.cpp b/src/movegen.cpp index efa47bd5..6a3cdc24 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -42,8 +42,8 @@ namespace { assert(!pos.checkers()); - const Square K = Chess960 ? kto > kfrom ? DELTA_W : DELTA_E - : KingSide ? DELTA_W : DELTA_E; + const Square K = Chess960 ? kto > kfrom ? WEST : EAST + : KingSide ? WEST : EAST; for (Square s = kto; s != kfrom; s += K) if (pos.attackers_to(s) & enemies) @@ -65,23 +65,23 @@ namespace { } - template + template ExtMove* make_promotions(ExtMove* moveList, Square to, Square ksq) { if (Type == CAPTURES || Type == EVASIONS || Type == NON_EVASIONS) - *moveList++ = make(to - Delta, to, QUEEN); + *moveList++ = make(to - D, to, QUEEN); if (Type == QUIETS || Type == EVASIONS || Type == NON_EVASIONS) { - *moveList++ = make(to - Delta, to, ROOK); - *moveList++ = make(to - Delta, to, BISHOP); - *moveList++ = make(to - Delta, to, KNIGHT); + *moveList++ = make(to - D, to, ROOK); + *moveList++ = make(to - D, to, BISHOP); + *moveList++ = make(to - D, to, KNIGHT); } // Knight promotion is the only promotion that can give a direct check // that's not already included in the queen promotion. if (Type == QUIET_CHECKS && (StepAttacksBB[W_KNIGHT][to] & ksq)) - *moveList++ = make(to - Delta, to, KNIGHT); + *moveList++ = make(to - D, to, KNIGHT); else (void)ksq; // Silence a warning under MSVC @@ -94,13 +94,13 @@ namespace { // Compute our parametrized parameters at compile time, named according to // the point of view of white side. - const Color Them = (Us == WHITE ? BLACK : WHITE); - const Bitboard TRank8BB = (Us == WHITE ? Rank8BB : Rank1BB); - const Bitboard TRank7BB = (Us == WHITE ? Rank7BB : Rank2BB); - const Bitboard TRank3BB = (Us == WHITE ? Rank3BB : Rank6BB); - const Square Up = (Us == WHITE ? DELTA_N : DELTA_S); - const Square Right = (Us == WHITE ? DELTA_NE : DELTA_SW); - const Square Left = (Us == WHITE ? DELTA_NW : DELTA_SE); + const Color Them = (Us == WHITE ? BLACK : WHITE); + const Bitboard TRank8BB = (Us == WHITE ? Rank8BB : Rank1BB); + const Bitboard TRank7BB = (Us == WHITE ? Rank7BB : Rank2BB); + const Bitboard TRank3BB = (Us == WHITE ? Rank3BB : Rank6BB); + const Square Up = (Us == WHITE ? NORTH : SOUTH); + const Square Right = (Us == WHITE ? NORTH_EAST : SOUTH_WEST); + const Square Left = (Us == WHITE ? NORTH_WEST : SOUTH_EAST); Bitboard emptySquares; @@ -115,8 +115,8 @@ namespace { { emptySquares = (Type == QUIETS || Type == QUIET_CHECKS ? target : ~pos.pieces()); - Bitboard b1 = shift_bb(pawnsNotOn7) & emptySquares; - Bitboard b2 = shift_bb(b1 & TRank3BB) & emptySquares; + Bitboard b1 = shift(pawnsNotOn7) & emptySquares; + Bitboard b2 = shift(b1 & TRank3BB) & emptySquares; if (Type == EVASIONS) // Consider only blocking squares { @@ -138,8 +138,8 @@ namespace { Bitboard dcCandidates = pos.discovered_check_candidates(); if (pawnsNotOn7 & dcCandidates) { - Bitboard dc1 = shift_bb(pawnsNotOn7 & dcCandidates) & emptySquares & ~file_bb(ksq); - Bitboard dc2 = shift_bb(dc1 & TRank3BB) & emptySquares; + Bitboard dc1 = shift(pawnsNotOn7 & dcCandidates) & emptySquares & ~file_bb(ksq); + Bitboard dc2 = shift(dc1 & TRank3BB) & emptySquares; b1 |= dc1; b2 |= dc2; @@ -168,9 +168,9 @@ namespace { if (Type == EVASIONS) emptySquares &= target; - Bitboard b1 = shift_bb(pawnsOn7) & enemies; - Bitboard b2 = shift_bb(pawnsOn7) & enemies; - Bitboard b3 = shift_bb(pawnsOn7) & emptySquares; + Bitboard b1 = shift(pawnsOn7) & enemies; + Bitboard b2 = shift(pawnsOn7) & enemies; + Bitboard b3 = shift(pawnsOn7) & emptySquares; Square ksq = pos.square(Them); @@ -187,8 +187,8 @@ namespace { // Standard and en-passant captures if (Type == CAPTURES || Type == EVASIONS || Type == NON_EVASIONS) { - Bitboard b1 = shift_bb(pawnsNotOn7) & enemies; - Bitboard b2 = shift_bb(pawnsNotOn7) & enemies; + Bitboard b1 = shift(pawnsNotOn7) & enemies; + Bitboard b2 = shift(pawnsNotOn7) & enemies; while (b1) { diff --git a/src/pawns.cpp b/src/pawns.cpp index b83b780a..245ba0c6 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -50,14 +50,16 @@ namespace { // Lever bonus by rank const Score Lever[RANK_NB] = { S( 0, 0), S( 0, 0), S(0, 0), S(0, 0), - S(17, 16), S(33, 32), S(0, 0), S(0, 0) }; + S(17, 16), S(33, 32), S(0, 0), S(0, 0) + }; // Weakness of our pawn shelter in front of the king by [distance from edge][rank] const Value ShelterWeakness[][RANK_NB] = { { V( 97), V(21), V(26), V(51), V(87), V( 89), V( 99) }, { V(120), V( 0), V(28), V(76), V(88), V(103), V(104) }, { V(101), V( 7), V(54), V(78), V(77), V( 92), V(101) }, - { V( 80), V(11), V(44), V(68), V(87), V( 90), V(119) } }; + { V( 80), V(11), V(44), V(68), V(87), V( 90), V(119) } + }; // Danger of enemy pawns moving toward our king by [type][distance from edge][rank] const Value StormDanger[][4][RANK_NB] = { @@ -76,7 +78,8 @@ namespace { { { V( 0), V(-283), V(-281), V(57), V(31) }, { V( 0), V( 58), V( 141), V(39), V(18) }, { V( 0), V( 65), V( 142), V(48), V(32) }, - { V( 0), V( 60), V( 126), V(51), V(19) } } }; + { V( 0), V( 60), V( 126), V(51), V(19) } } + }; // Max bonus for king safety. Corresponds to start position with all the pawns // in front of the king and no enemy pawn on the horizon. @@ -88,10 +91,10 @@ namespace { template Score evaluate(const Position& pos, Pawns::Entry* e) { - const Color Them = (Us == WHITE ? BLACK : WHITE); - const Square Up = (Us == WHITE ? DELTA_N : DELTA_S); - const Square Right = (Us == WHITE ? DELTA_NE : DELTA_SW); - const Square Left = (Us == WHITE ? DELTA_NW : DELTA_SE); + const Color Them = (Us == WHITE ? BLACK : WHITE); + const Square Up = (Us == WHITE ? NORTH : SOUTH); + const Square Right = (Us == WHITE ? NORTH_EAST : SOUTH_WEST); + const Square Left = (Us == WHITE ? NORTH_WEST : SOUTH_EAST); Bitboard b, neighbours, stoppers, doubled, supported, phalanx; Square s; @@ -103,10 +106,10 @@ namespace { Bitboard ourPawns = pos.pieces(Us , PAWN); Bitboard theirPawns = pos.pieces(Them, PAWN); - e->passedPawns[Us] = e->pawnAttacksSpan[Us] = 0; - e->kingSquares[Us] = SQ_NONE; + e->passedPawns[Us] = e->pawnAttacksSpan[Us] = 0; e->semiopenFiles[Us] = 0xFF; - e->pawnAttacks[Us] = shift_bb(ourPawns) | shift_bb(ourPawns); + e->kingSquares[Us] = SQ_NONE; + e->pawnAttacks[Us] = shift(ourPawns) | shift(ourPawns); e->pawnsOnSquares[Us][BLACK] = popcount(ourPawns & DarkSquares); e->pawnsOnSquares[Us][WHITE] = pos.count(Us) - e->pawnsOnSquares[Us][BLACK]; @@ -117,7 +120,7 @@ namespace { File f = file_of(s); - e->semiopenFiles[Us] &= ~(1 << f); + e->semiopenFiles[Us] &= ~(1 << f); e->pawnAttacksSpan[Us] |= pawn_attack_span(Us, s); // Flag the pawn @@ -142,7 +145,7 @@ namespace { // The pawn is backward when it cannot safely progress to that rank: // either there is a stopper in the way on this rank, or there is a // stopper on adjacent file which controls the way to that rank. - backward = (b | shift_bb(b & adjacent_files_bb(f))) & stoppers; + backward = (b | shift(b & adjacent_files_bb(f))) & stoppers; assert(!backward || !(pawn_attack_span(Them, s + Up) & neighbours)); } @@ -183,8 +186,8 @@ namespace Pawns { /// hard-coded tables, when makes sense, we prefer to calculate them with a formula /// to reduce independent parameters and to allow easier tuning and better insight. -void init() -{ +void init() { + static const int Seed[RANK_NB] = { 0, 8, 19, 13, 71, 94, 169, 324 }; for (int opposed = 0; opposed <= 1; ++opposed) diff --git a/src/psqt.cpp b/src/psqt.cpp index 26cd1a0b..41a9b499 100644 --- a/src/psqt.cpp +++ b/src/psqt.cpp @@ -23,8 +23,9 @@ #include "types.h" Value PieceValue[PHASE_NB][PIECE_NB] = { -{ VALUE_ZERO, PawnValueMg, KnightValueMg, BishopValueMg, RookValueMg, QueenValueMg }, -{ VALUE_ZERO, PawnValueEg, KnightValueEg, BishopValueEg, RookValueEg, QueenValueEg } }; + { VALUE_ZERO, PawnValueMg, KnightValueMg, BishopValueMg, RookValueMg, QueenValueMg }, + { VALUE_ZERO, PawnValueEg, KnightValueEg, BishopValueEg, RookValueEg, QueenValueEg } +}; namespace PSQT { diff --git a/src/search.cpp b/src/search.cpp index 8581b0b3..b3201650 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1588,8 +1588,8 @@ string UCI::pv(const Position& pos, Depth depth, Value alpha, Value beta) { /// fail high at root. We try hard to have a ponder move to return to the GUI, /// otherwise in case of 'ponder on' we have nothing to think on. -bool RootMove::extract_ponder_from_tt(Position& pos) -{ +bool RootMove::extract_ponder_from_tt(Position& pos) { + StateInfo st; bool ttHit; diff --git a/src/timeman.cpp b/src/timeman.cpp index c7c19f47..6d3b7314 100644 --- a/src/timeman.cpp +++ b/src/timeman.cpp @@ -52,8 +52,8 @@ namespace { } template - int remaining(int myTime, int movesToGo, int ply, int slowMover) - { + int remaining(int myTime, int movesToGo, int ply, int slowMover) { + const double TMaxRatio = (T == OptimumTime ? 1 : MaxRatio); const double TStealRatio = (T == OptimumTime ? 0 : StealRatio); @@ -81,8 +81,8 @@ namespace { /// inc > 0 && movestogo == 0 means: x basetime + z increment /// inc > 0 && movestogo != 0 means: x moves in y minutes + z increment -void TimeManagement::init(Search::LimitsType& limits, Color us, int ply) -{ +void TimeManagement::init(Search::LimitsType& limits, Color us, int ply) { + int minThinkingTime = Options["Minimum Thinking Time"]; int moveOverhead = Options["Move Overhead"]; int slowMover = Options["Slow Mover"]; diff --git a/src/tt.cpp b/src/tt.cpp index 3c43e12c..f5b72ba8 100644 --- a/src/tt.cpp +++ b/src/tt.cpp @@ -100,11 +100,11 @@ TTEntry* TranspositionTable::probe(const Key key, bool& found) const { } -/// Returns an approximation of the hashtable occupation during a search. The -/// hash is x permill full, as per UCI protocol. +/// TranspositionTable::hashfull() returns an approximation of the hashtable +/// occupation during a search. The hash is x permill full, as per UCI protocol. + +int TranspositionTable::hashfull() const { -int TranspositionTable::hashfull() const -{ int cnt = 0; for (int i = 0; i < 1000 / ClusterSize; i++) { diff --git a/src/types.h b/src/types.h index e5a7035c..1bf42bbe 100644 --- a/src/types.h +++ b/src/types.h @@ -237,17 +237,15 @@ enum Square { SQUARE_NB = 64, - DELTA_N = 8, - DELTA_E = 1, - DELTA_S = -8, - DELTA_W = -1, - - DELTA_NN = DELTA_N + DELTA_N, - DELTA_NE = DELTA_N + DELTA_E, - DELTA_SE = DELTA_S + DELTA_E, - DELTA_SS = DELTA_S + DELTA_S, - DELTA_SW = DELTA_S + DELTA_W, - DELTA_NW = DELTA_N + DELTA_W + NORTH = 8, + EAST = 1, + SOUTH = -8, + WEST = -1, + + NORTH_EAST = NORTH + EAST, + SOUTH_EAST = SOUTH + EAST, + SOUTH_WEST = SOUTH + WEST, + NORTH_WEST = NORTH + WEST }; enum File { @@ -401,7 +399,7 @@ inline bool opposite_colors(Square s1, Square s2) { } inline Square pawn_push(Color c) { - return c == WHITE ? DELTA_N : DELTA_S; + return c == WHITE ? NORTH : SOUTH; } inline Square from_sq(Move m) { -- 2.39.2