Now that we use pre-increment on enums, it
make sense, for code style uniformity, to
swith to pre-increment also for native types,
although there is no speed difference.
No functional change.
Search::StateStackPtr st;
Time::point elapsed = Time::now();
Search::StateStackPtr st;
Time::point elapsed = Time::now();
- for (size_t i = 0; i < fens.size(); i++)
+ for (size_t i = 0; i < fens.size(); ++i)
{
Position pos(fens[i], Options["UCI_Chess960"], Threads.main());
{
Position pos(fens[i], Options["UCI_Chess960"], Threads.main());
- for (int k = 0, i = 0; i < 8; i++)
+ for (int k = 0, i = 0; i < 8; ++i)
while (k < (2 << i))
MS1BTable[k++] = i;
while (k < (2 << i))
MS1BTable[k++] = i;
- for (int i = 0; i < 64; i++)
+ for (int i = 0; i < 64; ++i)
BSFTable[bsf_index(1ULL << i)] = Square(i);
for (Square s = SQ_A1; s <= SQ_H8; ++s)
BSFTable[bsf_index(1ULL << i)] = Square(i);
for (Square s = SQ_A1; s <= SQ_H8; ++s)
FileBB[FILE_A] = FileABB;
RankBB[RANK_1] = Rank1BB;
FileBB[FILE_A] = FileABB;
RankBB[RANK_1] = Rank1BB;
- for (int i = 1; i < 8; i++)
+ for (int i = 1; i < 8; ++i)
{
FileBB[i] = FileBB[i - 1] << 1;
RankBB[i] = RankBB[i - 1] << 8;
{
FileBB[i] = FileBB[i - 1] << 1;
RankBB[i] = RankBB[i - 1] << 8;
- for (int i = 0; i < 4; i++)
+ for (int i = 0; i < 4; ++i)
for (Square s = sq + deltas[i];
is_ok(s) && square_distance(s, s - deltas[i]) == 1;
s += deltas[i])
for (Square s = sq + deltas[i];
is_ok(s) && square_distance(s, s - deltas[i]) == 1;
s += deltas[i])
// looks up the correct sliding attack in the attacks[s] database.
// Note that we build up the database for square 's' as a side
// effect of verifying the magic.
// looks up the correct sliding attack in the attacks[s] database.
// Note that we build up the database for square 's' as a side
// effect of verifying the magic.
- for (i = 0; i < size; i++)
+ for (i = 0; i < size; ++i)
{
Bitboard& attack = attacks[s][index(s, occupancy[i])];
{
Bitboard& attack = attacks[s][index(s, occupancy[i])];
template<typename T> PolyglotBook& PolyglotBook::operator>>(T& n) {
n = 0;
template<typename T> PolyglotBook& PolyglotBook::operator>>(T& n) {
n = 0;
- for (size_t i = 0; i < sizeof(T); i++)
+ for (size_t i = 0; i < sizeof(T); ++i)
n = T((n << 8) + ifstream::get());
return *this;
n = T((n << 8) + ifstream::get());
return *this;
const int MaxSlope = 30;
const int Peak = 1280;
const int MaxSlope = 30;
const int Peak = 1280;
- for (int t = 0, i = 1; i < 100; i++)
+ for (int t = 0, i = 1; i < 100; ++i)
{
t = std::min(Peak, std::min(int(0.4 * i * i), t + MaxSlope));
{
t = std::min(Peak, std::min(int(0.4 * i * i), t + MaxSlope));
- for (int i = 1; i < argc; i++)
+ for (int i = 1; i < argc; ++i)
args += std::string(argv[i]) + " ";
UCI::loop(args);
args += std::string(argv[i]) + " ";
UCI::loop(args);
killers[2].move = killers[3].move = MOVE_NONE;
// Be sure countermoves are different from killers
killers[2].move = killers[3].move = MOVE_NONE;
// Be sure countermoves are different from killers
- for (int i = 0; i < 2; i++)
+ for (int i = 0; i < 2; ++i)
if (countermoves[i] != cur->move && countermoves[i] != (cur+1)->move)
(end++)->move = countermoves[i];
if (countermoves[i] != cur->move && countermoves[i] != (cur+1)->move)
(end++)->move = countermoves[i];
startState.epSquare = SQ_NONE;
st = &startState;
startState.epSquare = SQ_NONE;
st = &startState;
- for (int i = 0; i < PIECE_TYPE_NB; i++)
+ for (int i = 0; i < PIECE_TYPE_NB; ++i)
for (int j = 0; j < 16; j++)
pieceList[WHITE][i][j] = pieceList[BLACK][i][j] = SQ_NONE;
}
for (int j = 0; j < 16; j++)
pieceList[WHITE][i][j] = pieceList[BLACK][i][j] = SQ_NONE;
}
if ((*step)++, debugPieceList)
for (Color c = WHITE; c <= BLACK; ++c)
for (PieceType pt = PAWN; pt <= KING; ++pt)
if ((*step)++, debugPieceList)
for (Color c = WHITE; c <= BLACK; ++c)
for (PieceType pt = PAWN; pt <= KING; ++pt)
- for (int i = 0; i < pieceCount[c][pt]; i++)
+ for (int i = 0; i < pieceCount[c][pt]; ++i)
if ( board[pieceList[c][pt][i]] != make_piece(c, pt)
|| index[pieceList[c][pt][i]] != i)
return false;
if ( board[pieceList[c][pt][i]] != make_piece(c, pt)
|| index[pieceList[c][pt][i]] != i)
return false;
s.a = 0xf1ea5eed;
s.b = s.c = s.d = 0xd4e12c77;
s.a = 0xf1ea5eed;
s.b = s.c = s.d = 0xd4e12c77;
- for (int i = 0; i < seed; i++) // Scramble a few rounds
+ for (int i = 0; i < seed; ++i) // Scramble a few rounds
}
// Reset the threads, still sleeping: will be wake up at split time
}
// Reset the threads, still sleeping: will be wake up at split time
- for (size_t i = 0; i < Threads.size(); i++)
+ for (size_t i = 0; i < Threads.size(); ++i)
Threads[i]->maxPly = 0;
Threads.sleepWhileIdle = Options["Idle Threads Sleep"];
Threads[i]->maxPly = 0;
Threads.sleepWhileIdle = Options["Idle Threads Sleep"];
// Save last iteration's scores before first PV line is searched and all
// the move scores but the (new) PV are set to -VALUE_INFINITE.
// Save last iteration's scores before first PV line is searched and all
// the move scores but the (new) PV are set to -VALUE_INFINITE.
- for (size_t i = 0; i < RootMoves.size(); i++)
+ for (size_t i = 0; i < RootMoves.size(); ++i)
RootMoves[i].prevScore = RootMoves[i].score;
// MultiPV loop. We perform a full root search for each PV line
RootMoves[i].prevScore = RootMoves[i].score;
// MultiPV loop. We perform a full root search for each PV line
// Write PV back to transposition table in case the relevant
// entries have been overwritten during the search.
// Write PV back to transposition table in case the relevant
// entries have been overwritten during the search.
- for (size_t i = 0; i <= PVIdx; i++)
+ for (size_t i = 0; i <= PVIdx; ++i)
RootMoves[i].insert_pv_in_tt(pos);
// If search has been stopped return immediately. Sorting and
RootMoves[i].insert_pv_in_tt(pos);
// If search has been stopped return immediately. Sorting and
// played non-capture moves.
Value bonus = Value(int(depth) * int(depth));
History.update(pos.piece_moved(bestMove), to_sq(bestMove), bonus);
// played non-capture moves.
Value bonus = Value(int(depth) * int(depth));
History.update(pos.piece_moved(bestMove), to_sq(bestMove), bonus);
- for (int i = 0; i < quietCount - 1; i++)
+ for (int i = 0; i < quietCount - 1; ++i)
{
Move m = quietsSearched[i];
History.update(pos.piece_moved(m), to_sq(m), -bonus);
{
Move m = quietsSearched[i];
History.update(pos.piece_moved(m), to_sq(m), -bonus);
// Choose best move. For each move score we add two terms both dependent on
// weakness, one deterministic and bigger for weaker moves, and one random,
// then we choose the move with the resulting highest score.
// Choose best move. For each move score we add two terms both dependent on
// weakness, one deterministic and bigger for weaker moves, and one random,
// then we choose the move with the resulting highest score.
- for (size_t i = 0; i < PVSize; i++)
+ for (size_t i = 0; i < PVSize; ++i)
{
int s = RootMoves[i].score;
{
int s = RootMoves[i].score;
size_t uciPVSize = std::min((size_t)Options["MultiPV"], RootMoves.size());
int selDepth = 0;
size_t uciPVSize = std::min((size_t)Options["MultiPV"], RootMoves.size());
int selDepth = 0;
- for (size_t i = 0; i < Threads.size(); i++)
+ for (size_t i = 0; i < Threads.size(); ++i)
if (Threads[i]->maxPly > selDepth)
selDepth = Threads[i]->maxPly;
if (Threads[i]->maxPly > selDepth)
selDepth = Threads[i]->maxPly;
- for (size_t i = 0; i < uciPVSize; i++)
+ for (size_t i = 0; i < uciPVSize; ++i)
{
bool updated = (i <= PVIdx);
{
bool updated = (i <= PVIdx);
// Loop across all split points and sum accumulated SplitPoint nodes plus
// all the currently active positions nodes.
// 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 (size_t i = 0; i < Threads.size(); ++i)
for (int j = 0; j < Threads[i]->splitPointsSize; j++)
{
SplitPoint& sp = Threads[i]->splitPoints[j];
for (int j = 0; j < Threads[i]->splitPointsSize; j++)
{
SplitPoint& sp = Threads[i]->splitPoints[j];
int thisMoveImportance = move_importance(currentPly) * slowMover / 100;
int otherMovesImportance = 0;
int thisMoveImportance = move_importance(currentPly) * slowMover / 100;
int otherMovesImportance = 0;
- for (int i = 1; i < movesToGo; i++)
+ for (int i = 1; i < movesToGo; ++i)
otherMovesImportance += move_importance(currentPly + 2 * i);
float ratio1 = (TMaxRatio * thisMoveImportance) / float(TMaxRatio * thisMoveImportance + otherMovesImportance);
otherMovesImportance += move_importance(currentPly + 2 * i);
float ratio1 = (TMaxRatio * thisMoveImportance) / float(TMaxRatio * thisMoveImportance + otherMovesImportance);
const TTEntry* tte = first_entry(key);
uint32_t key32 = key >> 32;
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;
if (tte->key() == key32)
return tte;
tte = replace = first_entry(key);
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
{
{
if (!tte->key() || tte->key() == key32) // Empty or overwrite old
{