diff --git a/AUTHORS b/AUTHORS index c0a8beebc45..90f76787762 100644 --- a/AUTHORS +++ b/AUTHORS @@ -111,6 +111,7 @@ Jean Gauthier (OuaisBla) Jekaa Jerry Donald Watson (jerrydonaldwatson) jjoshua2 +John Doknjas (johndoknjas) Jonathan Buladas Dumale (SFisGOD) Jonathan Calovski (Mysseno) Jonathan McDermid (jonathanmcdermid) diff --git a/src/bitboard.cpp b/src/bitboard.cpp index a8b4e5f4464..e856c02a3f3 100644 --- a/src/bitboard.cpp +++ b/src/bitboard.cpp @@ -180,7 +180,7 @@ void init_magics(PieceType pt, Bitboard table[], Magic magics[]) { if (HasPext) m.attacks[pext(b, m.mask)] = reference[size]; - size++; + size += 1; b = (b - m.mask) & m.mask; } while (b); diff --git a/src/misc.cpp b/src/misc.cpp index 10c86b7a6e7..7cd6acf08a5 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -307,26 +307,25 @@ DebugExtremes extremes[MaxDebugSlots]; void dbg_hit_on(bool cond, int slot) { - ++hit[slot][0]; - if (cond) - ++hit[slot][1]; + hit[slot][0] += 1; + hit[slot][1] += cond; } void dbg_mean_of(int64_t value, int slot) { - ++mean[slot][0]; + mean[slot][0] += 1; mean[slot][1] += value; } void dbg_stdev_of(int64_t value, int slot) { - ++stdev[slot][0]; + stdev[slot][0] += 1; stdev[slot][1] += value; stdev[slot][2] += value * value; } void dbg_extremes_of(int64_t value, int slot) { - ++extremes[slot][0]; + extremes[slot][0] += 1; int64_t current_max = extremes[slot][1].load(); while (current_max < value && !extremes[slot][1].compare_exchange_weak(current_max, value)) @@ -339,7 +338,7 @@ void dbg_extremes_of(int64_t value, int slot) { void dbg_correl_of(int64_t value1, int64_t value2, int slot) { - ++correl[slot][0]; + correl[slot][0] += 1; correl[slot][1] += value1; correl[slot][2] += value1 * value1; correl[slot][3] += value2; diff --git a/src/movegen.cpp b/src/movegen.cpp index 69b8fe6ae2b..ad06cff1f21 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -246,9 +246,9 @@ ExtMove* generate(const Position& pos, ExtMove* moveList) { while (cur != moveList) if (((pinned & cur->from_sq()) || cur->from_sq() == ksq || cur->type_of() == EN_PASSANT) && !pos.legal(*cur)) - *cur = *(--moveList); + *cur = *--moveList; else - ++cur; + cur += 1; return moveList; } diff --git a/src/movepick.cpp b/src/movepick.cpp index f4ef0e5499b..c87507d611e 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -228,7 +228,7 @@ Move MovePicker::next_move(bool skipQuiets) { case EVASION_TT : case QSEARCH_TT : case PROBCUT_TT : - ++stage; + stage += 1; return ttMove; case CAPTURE_INIT : @@ -239,7 +239,7 @@ Move MovePicker::next_move(bool skipQuiets) { score(); partial_insertion_sort(cur, endMoves, std::numeric_limits::min()); - ++stage; + stage += 1; goto top; case GOOD_CAPTURE : @@ -250,7 +250,7 @@ Move MovePicker::next_move(bool skipQuiets) { })) return *(cur - 1); - ++stage; + stage += 1; [[fallthrough]]; case QUIET_INIT : @@ -263,7 +263,7 @@ Move MovePicker::next_move(bool skipQuiets) { partial_insertion_sort(cur, endMoves, quiet_threshold(depth)); } - ++stage; + stage += 1; [[fallthrough]]; case GOOD_QUIET : @@ -280,7 +280,7 @@ Move MovePicker::next_move(bool skipQuiets) { cur = moves; endMoves = endBadCaptures; - ++stage; + stage += 1; [[fallthrough]]; case BAD_CAPTURE : @@ -291,7 +291,7 @@ Move MovePicker::next_move(bool skipQuiets) { cur = beginBadQuiets; endMoves = endBadQuiets; - ++stage; + stage += 1; [[fallthrough]]; case BAD_QUIET : @@ -305,7 +305,7 @@ Move MovePicker::next_move(bool skipQuiets) { endMoves = generate(pos, cur); score(); - ++stage; + stage += 1; [[fallthrough]]; case EVASION : diff --git a/src/nnue/nnue_common.h b/src/nnue/nnue_common.h index 4bc3408f18a..88cb0d550e9 100644 --- a/src/nnue/nnue_common.h +++ b/src/nnue/nnue_common.h @@ -197,7 +197,7 @@ inline void read_leb_128(std::istream& stream, IntType* out, std::size_t count) } std::uint8_t byte = buf[buf_pos++]; - --bytes_left; + bytes_left -= 1; result |= (byte & 0x7f) << shift; shift += 7; @@ -236,7 +236,7 @@ inline void write_leb_128(std::ostream& stream, const IntType* values, std::size { byte = value & 0x7f; value >>= 7; - ++byte_count; + byte_count += 1; } while ((byte & 0x40) == 0 ? value != 0 : value != -1); } diff --git a/src/nnue/nnue_feature_transformer.h b/src/nnue/nnue_feature_transformer.h index fa180678d89..f721991714b 100644 --- a/src/nnue/nnue_feature_transformer.h +++ b/src/nnue/nnue_feature_transformer.h @@ -746,9 +746,9 @@ class FeatureTransformer { acc[k] = vec_add_16(acc[k], column[k]); } - for (IndexType k = 0; k < NumRegs; k++) + for (IndexType k = 0; k < NumRegs; ++k) vec_store(&entryTile[k], acc[k]); - for (IndexType k = 0; k < NumRegs; k++) + for (IndexType k = 0; k < NumRegs; ++k) vec_store(&accTile[k], acc[k]); } diff --git a/src/perft.h b/src/perft.h index e907742da05..e20f4759cad 100644 --- a/src/perft.h +++ b/src/perft.h @@ -42,7 +42,7 @@ uint64_t perft(Position& pos, Depth depth) { for (const auto& m : MoveList(pos)) { if (Root && depth <= 1) - cnt = 1, nodes++; + cnt = 1, nodes += 1; else { pos.do_move(m, st); diff --git a/src/position.cpp b/src/position.cpp index f596b015355..9e36a5e1d12 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -149,7 +149,7 @@ void Position::init() { break; i = (i == H1(key)) ? H2(key) : H1(key); // Push victim to alternative slot } - count++; + count += 1; } assert(count == 3668); } @@ -697,7 +697,7 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) { // Increment ply counters. In particular, rule50 will be reset to zero later on // in case of a capture or a pawn move. - ++gamePly; + gamePly += 1; ++st->rule50; ++st->pliesFromNull; @@ -836,7 +836,7 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) { dp.piece[dp.dirty_num] = promotion; dp.from[dp.dirty_num] = SQ_NONE; dp.to[dp.dirty_num] = to; - dp.dirty_num++; + dp.dirty_num += 1; // Update hash keys k ^= Zobrist::psq[pc][to] ^ Zobrist::psq[promotion][to]; @@ -972,7 +972,7 @@ void Position::undo_move(Move m) { // Finally point our state pointer back to the previous state st = st->previous; - --gamePly; + gamePly -= 1; assert(pos_is_ok()); } diff --git a/src/position.h b/src/position.h index 888612da78d..cb39a5a0501 100644 --- a/src/position.h +++ b/src/position.h @@ -342,8 +342,8 @@ inline void Position::put_piece(Piece pc, Square s) { board[s] = pc; byTypeBB[ALL_PIECES] |= byTypeBB[type_of(pc)] |= s; byColorBB[color_of(pc)] |= s; - pieceCount[pc]++; - pieceCount[make_piece(color_of(pc), ALL_PIECES)]++; + pieceCount[pc] += 1; + pieceCount[make_piece(color_of(pc), ALL_PIECES)] += 1; } inline void Position::remove_piece(Square s) { @@ -353,8 +353,8 @@ inline void Position::remove_piece(Square s) { byTypeBB[type_of(pc)] ^= s; byColorBB[color_of(pc)] ^= s; board[s] = NO_PIECE; - pieceCount[pc]--; - pieceCount[make_piece(color_of(pc), ALL_PIECES)]--; + pieceCount[pc] -= 1; + pieceCount[make_piece(color_of(pc), ALL_PIECES)] -= 1; } inline void Position::move_piece(Square from, Square to) { diff --git a/src/search.cpp b/src/search.cpp index a206cddab3d..792af7bc84b 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -292,7 +292,7 @@ void Search::Worker::iterative_deepening() { pvLast = 0; if (!threads.increaseDepth) - searchAgainCounter++; + searchAgainCounter += 1; // MultiPV loop. We perform a full root search for each PV line for (pvIdx = 0; pvIdx < multiPV; ++pvIdx) @@ -300,7 +300,7 @@ void Search::Worker::iterative_deepening() { if (pvIdx == pvLast) { pvFirst = pvLast; - for (pvLast++; pvLast < rootMoves.size(); pvLast++) + for (++pvLast; pvLast < rootMoves.size(); ++pvLast) if (rootMoves[pvLast].tbRank != rootMoves[pvFirst].tbRank) break; } @@ -366,7 +366,7 @@ void Search::Worker::iterative_deepening() { else if (bestValue >= beta) { beta = std::min(bestValue + delta, VALUE_INFINITE); - ++failedHighCnt; + failedHighCnt += 1; } else break; @@ -1147,7 +1147,7 @@ Value Search::Worker::search( // Decrease reduction for PvNodes (~0 Elo on STC, ~2 Elo on LTC) if (PvNode) - r--; + r -= 1; // These reduction adjustments have no proven non-linear scaling @@ -1573,7 +1573,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta) givesCheck = pos.gives_check(move); capture = pos.capture_stage(move); - moveCount++; + moveCount += 1; // Step 6. Pruning if (bestValue > VALUE_TB_LOSS_IN_MAX_PLY && pos.non_pawn_material(us)) @@ -1955,7 +1955,7 @@ void syzygy_extend_pv(const OptionsMap& options, if (legalMoves[0].tbRank != rm.tbRank) break; - ply++; + ply += 1; auto& st = sts.emplace_back(); pos.do_move(pvMove, st); @@ -1964,7 +1964,7 @@ void syzygy_extend_pv(const OptionsMap& options, if (config.rootInTB && pos.is_draw(ply)) { pos.undo_move(pvMove); - ply--; + ply -= 1; break; } @@ -2015,7 +2015,7 @@ void syzygy_extend_pv(const OptionsMap& options, if (!config.rootInTB || config.cardinality > 0) break; - ply++; + ply += 1; Move& pvMove = legalMoves[0].pv[0]; rootMove.pv.push_back(pvMove); diff --git a/src/syzygy/tbprobe.cpp b/src/syzygy/tbprobe.cpp index 9b24e700b18..723e45a9ae8 100644 --- a/src/syzygy/tbprobe.cpp +++ b/src/syzygy/tbprobe.cpp @@ -516,7 +516,7 @@ void TBTables::add(const std::vector& pieces) { if (file_dtz.is_open()) { file_dtz.close(); - foundDTZFiles++; + foundDTZFiles += 1; } TBFile file(code + ".rtbw"); // KRK -> KRvK @@ -525,7 +525,7 @@ void TBTables::add(const std::vector& pieces) { return; file.close(); - foundWDLFiles++; + foundWDLFiles += 1; MaxCardinality = std::max(int(pieces.size()), MaxCardinality); @@ -616,7 +616,7 @@ int decompress_pairs(PairsData* d, uint64_t idx) { // to 64 bits we know that d->base64[l-1] >= s64 >= d->base64[l] so we // can find the symbol length iterating through base64[]. while (buf64 < d->base64[len]) - ++len; + len += 1; // All the symbols of a given length are consecutive integers (numerical // sequence property), so we can compute the offset of our symbol of @@ -958,7 +958,7 @@ void set_groups(T& e, PairsData* d, int order[], File f) { // the encoder will default on '111', so groupLen[] will be (3, 1). for (int i = 1; i < e.pieceCount; ++i) if (--firstLen > 0 || d->pieces[i] == d->pieces[i - 1]) - d->groupLen[n]++; + d->groupLen[n] += 1; else d->groupLen[++n] = 1; @@ -1148,7 +1148,7 @@ void set(T& e, uint8_t* data) { assert(e.hasPawns == bool(*data & HasPawns)); assert((e.key != e.key2) == bool(*data & Split)); - data++; // First byte stores flags + data += 1; // First byte stores flags const int sides = T::Sides == 2 && (e.key != e.key2) ? 2 : 1; const File maxFile = e.hasPawns ? FILE_D : FILE_A; @@ -1160,7 +1160,7 @@ void set(T& e, uint8_t* data) { for (File f = FILE_A; f <= maxFile; ++f) { - for (int i = 0; i < sides; i++) + for (int i = 0; i < sides; ++i) *e.get(i, f) = PairsData(); int order[][2] = {{*data & 0xF, pp ? *(data + 1) & 0xF : 0xF}, @@ -1168,7 +1168,7 @@ void set(T& e, uint8_t* data) { data += 1 + pp; for (int k = 0; k < e.pieceCount; ++k, ++data) - for (int i = 0; i < sides; i++) + for (int i = 0; i < sides; ++i) e.get(i, f)->pieces[k] = Piece(i ? *data >> 4 : *data & 0xF); for (int i = 0; i < sides; ++i) @@ -1178,27 +1178,27 @@ void set(T& e, uint8_t* data) { data += uintptr_t(data) & 1; // Word alignment for (File f = FILE_A; f <= maxFile; ++f) - for (int i = 0; i < sides; i++) + for (int i = 0; i < sides; ++i) data = set_sizes(e.get(i, f), data); data = set_dtz_map(e, data, maxFile); for (File f = FILE_A; f <= maxFile; ++f) - for (int i = 0; i < sides; i++) + for (int i = 0; i < sides; ++i) { (d = e.get(i, f))->sparseIndex = (SparseEntry*) data; data += d->sparseIndexSize * sizeof(SparseEntry); } for (File f = FILE_A; f <= maxFile; ++f) - for (int i = 0; i < sides; i++) + for (int i = 0; i < sides; ++i) { (d = e.get(i, f))->blockLength = (uint16_t*) data; data += d->blockLengthSize * sizeof(uint16_t); } for (File f = FILE_A; f <= maxFile; ++f) - for (int i = 0; i < sides; i++) + for (int i = 0; i < sides; ++i) { data = (uint8_t*) ((uintptr_t(data) + 0x3F) & ~0x3F); // 64 byte alignment (d = e.get(i, f))->data = data; @@ -1286,7 +1286,7 @@ WDLScore search(Position& pos, ProbeState* result) { if (!pos.capture(move) && (!CheckZeroingMoves || type_of(pos.moved_piece(move)) != PAWN)) continue; - moveCount++; + moveCount += 1; pos.do_move(move, st); value = -search(pos, result); @@ -1372,7 +1372,7 @@ void Tablebases::init(const std::string& paths) { // diagonal, the other one shall not be above the a1-h8 diagonal. std::vector> bothOnDiagonal; code = 0; - for (int idx = 0; idx < 10; idx++) + for (int idx = 0; idx < 10; ++idx) for (Square s1 = SQ_A1; s1 <= SQ_D4; ++s1) if (MapA1D1D4[s1] == idx && (idx || s1 == SQ_B1)) // SQ_B1 is mapped to 0 { @@ -1398,7 +1398,7 @@ void Tablebases::init(const std::string& paths) { // are Binomial[k][n] ways to choose k elements from a set of n elements. Binomial[0][0] = 1; - for (int n = 1; n < 64; n++) // Squares + for (int n = 1; n < 64; ++n) // Squares for (int k = 0; k < 6 && k <= n; ++k) // Pieces Binomial[k][n] = (k > 0 ? Binomial[k - 1][n - 1] : 0) + (k < n ? Binomial[k][n - 1] : 0); diff --git a/src/tune.h b/src/tune.h index ed4738cdc47..a648e02d299 100644 --- a/src/tune.h +++ b/src/tune.h @@ -134,7 +134,7 @@ class Tune { // Template specialization for arrays: recursively handle multi-dimensional arrays template int add(const SetRange& range, std::string&& names, T (&value)[N], Args&&... args) { - for (size_t i = 0; i < N; i++) + for (size_t i = 0; i < N; ++i) add(range, next(names, i == N - 1) + "[" + std::to_string(i) + "]", value[i]); return add(range, std::move(names), args...); }