From: Marco Costalba Date: Sat, 9 Oct 2010 12:05:58 +0000 (+0100) Subject: Small codestyle touches X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=7733dadfd7c8781e3bde3cc4e21751fa44ab6ed8 Small codestyle touches Mostly suggested by Justin (UncombedCoconut), the 0ULL -> 0 conversion is mine. No functional change. Signed-off-by: Marco Costalba --- diff --git a/src/bitboard.cpp b/src/bitboard.cpp index 2b42ce01..e23e5b6b 100644 --- a/src/bitboard.cpp +++ b/src/bitboard.cpp @@ -403,7 +403,7 @@ namespace { AttackSpanMask[c][s] = in_front_bb(c, s) & neighboring_files_bb(s); } - for (Bitboard b = 0ULL; b < 256ULL; b++) + for (Bitboard b = 0; b < 256; b++) BitCount8Bit[b] = (uint8_t)count_1s(b); } @@ -511,7 +511,7 @@ namespace { for (int i = 0, index = 0; i < 64; i++) { attackIndex[i] = index; - mask[i] = sliding_attacks(i, 0ULL, 4, deltas, 1, 6, 1, 6); + mask[i] = sliding_attacks(i, 0, 4, deltas, 1, 6, 1, 6); #if defined(IS_64BIT) int j = (1 << (64 - shift[i])); diff --git a/src/book.cpp b/src/book.cpp index ad0d406d..c9a2e9c9 100644 --- a/src/book.cpp +++ b/src/book.cpp @@ -441,7 +441,7 @@ Move Book::get_move(const Position& pos, bool findBestMove) { if (!bookMove) return MOVE_NONE; - MoveStack mlist[256]; + MoveStack mlist[MOVES_MAX]; MoveStack* last = generate_moves(pos, mlist); for (MoveStack* cur = mlist; cur != last; cur++) if ((int(cur->move) & 07777) == bookMove) @@ -515,7 +515,7 @@ uint64_t Book::read_integer(int size) { read(buf, size); // Numbers are stored on disk as a binary byte stream - uint64_t n = 0ULL; + uint64_t n = 0; for (int i = 0; i < size; i++) n = (n << 8) + (unsigned char)buf[i]; @@ -531,7 +531,7 @@ namespace { uint64_t book_key(const Position& pos) { - uint64_t result = 0ULL; + uint64_t result = 0; for (Color c = WHITE; c <= BLACK; c++) { @@ -566,7 +566,7 @@ namespace { uint64_t book_castle_key(const Position& pos) { - uint64_t result = 0ULL; + uint64_t result = 0; if (pos.can_castle_kingside(WHITE)) result ^= Random64[RandomCastle+0]; @@ -585,11 +585,11 @@ namespace { uint64_t book_ep_key(const Position& pos) { - return (pos.ep_square() == SQ_NONE ? 0ULL : Random64[RandomEnPassant + square_file(pos.ep_square())]); + return pos.ep_square() == SQ_NONE ? 0 : Random64[RandomEnPassant + square_file(pos.ep_square())]; } uint64_t book_color_key(const Position& pos) { - return (pos.side_to_move() == WHITE ? Random64[RandomTurn] : 0ULL); + return pos.side_to_move() == WHITE ? Random64[RandomTurn] : 0; } } diff --git a/src/move.h b/src/move.h index 9df3277d..e2562a42 100644 --- a/src/move.h +++ b/src/move.h @@ -31,6 +31,8 @@ #include "piece.h" #include "square.h" +// Maximum number of allowed moves per position +const int MOVES_MAX = 256; //// //// Types diff --git a/src/movegen.cpp b/src/movegen.cpp index ef080cc3..076af3fe 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -308,7 +308,7 @@ MoveStack* generate_moves(const Position& pos, MoveStack* mlist, bool pseudoLega bool move_is_legal(const Position& pos, const Move m) { - MoveStack mlist[256]; + MoveStack mlist[MOVES_MAX]; MoveStack *cur, *last = generate_moves(pos, mlist, true); for (cur = mlist; cur != last; cur++) diff --git a/src/movepick.cpp b/src/movepick.cpp index c2b8924a..2e8eb665 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -75,7 +75,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h, int searchTT = ttm; ttMoves[0].move = ttm; badCaptureThreshold = 0; - badCaptures = moves + 256; + badCaptures = moves + MOVES_MAX; pinned = p.pinned_pieces(pos.side_to_move()); @@ -151,7 +151,7 @@ void MovePicker::go_next_phase() { // Bad captures SEE value is already calculated so just pick // them in order to get SEE move ordering. curMove = badCaptures; - lastMove = moves + 256; + lastMove = moves + MOVES_MAX; return; case PH_EVASIONS: diff --git a/src/movepick.h b/src/movepick.h index 1a652d6f..c71ff1a9 100644 --- a/src/movepick.h +++ b/src/movepick.h @@ -66,7 +66,7 @@ private: int badCaptureThreshold, phase; const uint8_t* phasePtr; MoveStack *curMove, *lastMove, *lastGoodNonCapture, *badCaptures; - MoveStack moves[256]; + MoveStack moves[MOVES_MAX]; }; diff --git a/src/position.cpp b/src/position.cpp index 3b7916bf..74cb1f4e 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -382,7 +382,7 @@ const string Position::to_fen() const { /// Position::print() prints an ASCII representation of the position to -/// the standard output. If a move is given then also the san is print. +/// the standard output. If a move is given then also the san is printed. void Position::print(Move move) const { @@ -1561,7 +1561,7 @@ void Position::allow_ooo(Color c) { Key Position::compute_key() const { - Key result = Key(0ULL); + Key result = 0; for (Square s = SQ_A1; s <= SQ_H8; s++) if (square_is_occupied(s)) @@ -1586,7 +1586,7 @@ Key Position::compute_key() const { Key Position::compute_pawn_key() const { - Key result = Key(0ULL); + Key result = 0; Bitboard b; Square s; @@ -1611,7 +1611,7 @@ Key Position::compute_pawn_key() const { Key Position::compute_material_key() const { - Key result = Key(0ULL); + Key result = 0; for (Color c = WHITE; c <= BLACK; c++) for (PieceType pt = PAWN; pt <= QUEEN; pt++) { @@ -1703,7 +1703,7 @@ bool Position::is_draw() const { bool Position::is_mate() const { - MoveStack moves[256]; + MoveStack moves[MOVES_MAX]; return is_check() && (generate_moves(*this, moves) == moves); } @@ -1713,7 +1713,7 @@ bool Position::is_mate() const { bool Position::has_mate_threat() { - MoveStack mlist[256], *last, *cur; + MoveStack mlist[MOVES_MAX], *last, *cur; StateInfo st1, st2; bool mateFound = false; diff --git a/src/search.cpp b/src/search.cpp index 24c741aa..d54794bb 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -52,9 +52,6 @@ using std::endl; namespace { - // Maximum number of allowed moves per position - const int MOVES_MAX = 256; - // Types enum NodeType { NonPV, PV }; @@ -633,7 +630,7 @@ namespace { // Add some extra time if the best move has changed during the last two iterations if (Iteration > 5 && Iteration <= 50) - TimeMgr.pv_unstability(BestMoveChangesByIteration[Iteration], + TimeMgr.pv_instability(BestMoveChangesByIteration[Iteration], BestMoveChangesByIteration[Iteration-1]); // Stop search if most of MaxSearchTime is consumed at the end of the diff --git a/src/timeman.cpp b/src/timeman.cpp index 64861feb..e05c4626 100644 --- a/src/timeman.cpp +++ b/src/timeman.cpp @@ -88,7 +88,7 @@ namespace { //// Functions //// -void TimeManager::pv_unstability(int curChanges, int prevChanges) { +void TimeManager::pv_instability(int curChanges, int prevChanges) { unstablePVExtraTime = curChanges * (optimumSearchTime / 2) + prevChanges * (optimumSearchTime / 3); diff --git a/src/timeman.h b/src/timeman.h index 1c28f7db..1d001c61 100644 --- a/src/timeman.h +++ b/src/timeman.h @@ -29,7 +29,7 @@ class TimeManager { public: void init(int myTime, int myInc, int movesToGo, int currentPly); - void pv_unstability(int curChanges, int prevChanges); + void pv_instability(int curChanges, int prevChanges); int available_time() const { return optimumSearchTime + unstablePVExtraTime; } int maximum_time() const { return maximumSearchTime; }