No functional change.
db.reserve(IndexMax);
// Initialize db with known win / draw positions
- for (idx = 0; idx < IndexMax; idx++)
+ for (idx = 0; idx < IndexMax; ++idx)
db.push_back(KPKPosition(idx));
// Iterate through the positions until no more of the unknown positions can be
// changed to either wins or draws (15 cycles needed).
while (repeat)
- for (repeat = idx = 0; idx < IndexMax; idx++)
+ for (repeat = idx = 0; idx < IndexMax; ++idx)
repeat |= (db[idx] == UNKNOWN && db[idx].classify(db) != UNKNOWN);
// Map 32 results into one KPKBitbase[] entry
- for (idx = 0; idx < IndexMax; idx++)
+ for (idx = 0; idx < IndexMax; ++idx)
if (db[idx] == WIN)
KPKBitbase[idx / 32] |= 1 << (idx & 0x1F);
}
for (Color c = WHITE; c <= BLACK; ++c)
for (PieceType pt = PAWN; pt <= KING; ++pt)
for (Square s = SQ_A1; s <= SQ_H8; ++s)
- for (int k = 0; steps[pt][k]; k++)
+ for (int k = 0; steps[pt][k]; ++k)
{
Square to = s + Square(c == WHITE ? steps[pt][k] : -steps[pt][k]);
if (b & ei.kingRing[Them])
{
- ei.kingAttackersCount[Us]++;
+ ++ei.kingAttackersCount[Us];
ei.kingAttackersWeight[Us] += KingAttackWeights[Piece];
Bitboard bb = (b & ei.attackedBy[Them][KING]);
if (bb)
+ RedundantQueen * pieceCount[Us][QUEEN];
// Second-degree polynomial material imbalance by Tord Romstad
- for (pt1 = NO_PIECE_TYPE; pt1 <= QUEEN; pt1++)
+ for (pt1 = NO_PIECE_TYPE; pt1 <= QUEEN; ++pt1)
{
pc = pieceCount[Us][pt1];
if (!pc)
v = LinearCoefficients[pt1];
- for (pt2 = NO_PIECE_TYPE; pt2 <= pt1; pt2++)
+ for (pt2 = NO_PIECE_TYPE; pt2 <= pt1; ++pt2)
v += QuadraticCoefficientsSameColor[pt1][pt2] * pieceCount[Us][pt2]
+ QuadraticCoefficientsOppositeColor[pt1][pt2] * pieceCount[Them][pt2];
static uint64_t hits[2], means[2];
-void dbg_hit_on(bool b) { hits[0]++; if (b) hits[1]++; }
+void dbg_hit_on(bool b) { ++hits[0]; if (b) ++hits[1]; }
void dbg_hit_on_c(bool c, bool b) { if (c) dbg_hit_on(b); }
-void dbg_mean_of(int v) { means[0]++; means[1] += v; }
+void dbg_mean_of(int v) { ++means[0]; means[1] += v; }
void dbg_print() {
(mlist++)->move = make<CASTLE>(kfrom, rfrom);
if (Checks && !pos.gives_check((mlist - 1)->move, CheckInfo(pos)))
- mlist--;
+ --mlist;
return mlist;
}
// evasions so to skip known illegal moves avoiding useless legality check later.
do
{
- checkersCnt++;
+ ++checkersCnt;
checksq = pop_lsb(&b);
assert(color_of(pos.piece_on(checksq)) == ~us);
&& !pos.legal(cur->move, pinned))
cur->move = (--end)->move;
else
- cur++;
+ ++cur;
return end;
}
struct MoveList {
explicit MoveList(const Position& pos) : cur(mlist), last(generate<T>(pos, mlist)) { last->move = MOVE_NONE; }
- void operator++() { cur++; }
+ void operator++() { ++cur; }
Move operator*() const { return cur->move; }
size_t size() const { return last - mlist; }
bool contains(Move m) const {
switch (stage) {
case MAIN_SEARCH: case EVASION: case QSEARCH_0: case QSEARCH_1: case PROBCUT:
- cur++;
+ ++cur;
return ttMove;
case CAPTURES_S1:
Rank rkUs, rkThem;
File kf = std::max(FILE_B, std::min(FILE_G, file_of(ksq)));
- for (int f = kf - 1; f <= kf + 1; f++)
+ for (int f = kf - 1; f <= kf + 1; ++f)
{
b = ourPawns & FileBB[f];
rkUs = b ? relative_rank(Us, backmost_sq(Us, b)) : RANK_1;
for (File f = FILE_A; f <= FILE_H; ++f)
Zobrist::enpassant[f] = rk.rand<Key>();
- for (int cr = CASTLES_NONE; cr <= ALL_CASTLES; cr++)
+ for (int cr = CASTLES_NONE; cr <= ALL_CASTLES; ++cr)
{
Bitboard b = cr;
while (b)
int emptyCnt = 1;
for ( ; file < FILE_H && empty(++sq); ++file)
- emptyCnt++;
+ ++emptyCnt;
ss << emptyCnt;
}
assert(is_ok(m));
assert(&newSt != st);
- nodes++;
+ ++nodes;
Key k = st->key;
// Copy some fields of old state to our new StateInfo object except the ones
// Increment ply counters.In particular rule50 will be later reset it to zero
// in case of a capture or a pawn move.
- gamePly++;
- st->rule50++;
- st->pliesFromNull++;
+ ++gamePly;
+ ++st->rule50;
+ ++st->pliesFromNull;
Color us = sideToMove;
Color them = ~us;
// Finally point our state pointer back to the previous state
st = st->previous;
- gamePly--;
+ --gamePly;
assert(pos_is_ok());
}
st->key ^= Zobrist::side;
prefetch((char*)TT.first_entry(st->key));
- st->rule50++;
+ ++st->rule50;
st->pliesFromNull = 0;
sideToMove = ~sideToMove;
// Add the new entry to the swap list
swapList[slIndex] = -swapList[slIndex - 1] + PieceValue[MG][captured];
- slIndex++;
+ ++slIndex;
// Locate and remove the next least valuable attacker
captured = min_attacker<PAWN>(byTypeBB, to, stmAttackers, occupied, attackers);
st = &startState;
for (int i = 0; i < PIECE_TYPE_NB; ++i)
- for (int j = 0; j < 16; j++)
+ for (int j = 0; j < 16; ++j)
pieceList[WHITE][i][j] = pieceList[BLACK][i][j] = SQ_NONE;
}
for (Square s = SQ_A1; s <= SQ_H8; ++s)
if (type_of(piece_on(s)) == KING)
- kingCount[color_of(piece_on(s))]++;
+ ++kingCount[color_of(piece_on(s))];
if (kingCount[0] != 1 || kingCount[1] != 1)
return false;
int mc; // moveCount
// Init reductions array
- for (hd = 1; hd < 64; hd++) for (mc = 1; mc < 64; mc++)
+ for (hd = 1; hd < 64; ++hd) for (mc = 1; mc < 64; ++mc)
{
double pvRed = log(double(hd)) * log(double(mc)) / 3.0;
double nonPVRed = 0.33 + log(double(hd)) * log(double(mc)) / 2.25;
}
// Init futility margins array
- for (d = 1; d < 16; d++) for (mc = 0; mc < 64; mc++)
+ for (d = 1; d < 16; ++d) for (mc = 0; mc < 64; ++mc)
FutilityMargins[d][mc] = Value(112 * int(log(double(d * d) / 2) / log(2.0) + 1.001) - 8 * mc + 45);
// Init futility move count array
- for (d = 0; d < 32; d++)
+ for (d = 0; d < 32; ++d)
{
FutilityMoveCounts[0][d] = int(3 + 0.3 * pow(double(d ), 1.8)) * 3/4 + (2 < d && d < 5);
FutilityMoveCounts[1][d] = int(3 + 0.3 * pow(double(d + 0.98), 1.8));
RootMoves[i].prevScore = RootMoves[i].score;
// MultiPV loop. We perform a full root search for each PV line
- for (PVIdx = 0; PVIdx < PVSize; PVIdx++)
+ for (PVIdx = 0; PVIdx < PVSize; ++PVIdx)
{
// Reset aspiration window starting size
if (depth >= 5)
splitPoint->mutex.unlock();
}
else
- moveCount++;
+ ++moveCount;
if (RootNode)
{
// Check for legality only before to do the move
if (!RootNode && !SpNode && !pos.legal(move, ci.pinned))
{
- moveCount--;
+ --moveCount;
continue;
}
// iteration. This information is used for time management: When
// the best move changes frequently, we allocate some more time.
if (!pvMove)
- BestMoveChanges++;
+ ++BestMoveChanges;
}
else
// All other moves but the PV are set to the lowest value, this
static RKISS rk;
// PRNG sequence should be not deterministic
- for (int i = Time::now() % 50; i > 0; i--)
+ for (int i = Time::now() % 50; i > 0; --i)
rk.rand<unsigned>();
// RootMoves are already sorted by score in descending order
<< " multipv " << i + 1
<< " pv";
- for (size_t j = 0; RootMoves[i].pv[j] != MOVE_NONE; j++)
+ for (size_t j = 0; RootMoves[i].pv[j] != MOVE_NONE; ++j)
s << " " << move_to_uci(RootMoves[i].pv[j], pos.is_chess960());
}
// Loop across all split points and sum accumulated SplitPoint nodes plus
// all the currently active positions nodes.
for (size_t i = 0; i < Threads.size(); ++i)
- for (int j = 0; j < Threads[i]->splitPointsSize; j++)
+ for (int j = 0; j < Threads[i]->splitPointsSize; ++j)
{
SplitPoint& sp = Threads[i]->splitPoints[j];
Threads.mutex.lock();
sp.mutex.lock();
- splitPointsSize++;
+ ++splitPointsSize;
activeSplitPoint = &sp;
activePosition = NULL;
}
searching = true;
- splitPointsSize--;
+ --splitPointsSize;
activeSplitPoint = sp.parentSplitPoint;
activePosition = &pos;
pos.set_nodes_searched(pos.nodes_searched() + sp.nodes);
// We calculate optimum time usage for different hypothetic "moves to go"-values and choose the
// minimum of calculated search time values. Usually the greatest hypMTG gives the minimum values.
- for (hypMTG = 1; hypMTG <= (limits.movestogo ? std::min(limits.movestogo, MoveHorizon) : MoveHorizon); hypMTG++)
+ for (hypMTG = 1; hypMTG <= (limits.movestogo ? std::min(limits.movestogo, MoveHorizon) : MoveHorizon); ++hypMTG)
{
// Calculate thinking time for hypothetic "moves to go"-value
hypMyTime = limits.time[us]
const TTEntry* tte = first_entry(key);
uint32_t key32 = key >> 32;
- for (unsigned i = 0; i < ClusterSize; ++i, tte++)
+ for (unsigned i = 0; i < ClusterSize; ++i, ++tte)
if (tte->key() == key32)
return tte;
tte = replace = first_entry(key);
- for (unsigned i = 0; i < ClusterSize; ++i, tte++)
+ for (unsigned i = 0; i < ClusterSize; ++i, ++tte)
{
if (!tte->key() || tte->key() == key32) // Empty or overwrite old
{
public:
~TranspositionTable() { free(mem); }
- void new_search() { generation++; }
+ void new_search() { ++generation; }
const TTEntry* probe(const Key key) const;
TTEntry* first_entry(const Key key) const;
std::ostream& operator<<(std::ostream& os, const OptionsMap& om) {
- for (size_t idx = 0; idx < om.size(); idx++)
+ for (size_t idx = 0; idx < om.size(); ++idx)
for (OptionsMap::const_iterator it = om.begin(); it != om.end(); ++it)
if (it->second.idx == idx)
{