1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 00:33:09 +00:00

Use prefix operators wherever possible

No functional change.
This commit is contained in:
Lucas Braesch 2013-10-03 12:01:38 +08:00 committed by Marco Costalba
parent bd1c3ed7e3
commit 7f142d6817
16 changed files with 43 additions and 43 deletions

View file

@ -87,17 +87,17 @@ void Bitbases::init_kpk() {
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);
}

View file

@ -197,7 +197,7 @@ void Bitboards::init() {
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]);

View file

@ -499,7 +499,7 @@ Value do_evaluate(const Position& pos, Value& margin) {
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)

View file

@ -113,7 +113,7 @@ namespace {
+ 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)
@ -121,7 +121,7 @@ namespace {
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];

View file

@ -63,9 +63,9 @@ const string engine_info(bool to_uci) {
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() {

View file

@ -62,7 +62,7 @@ namespace {
(mlist++)->move = make<CASTLE>(kfrom, rfrom);
if (Checks && !pos.gives_check((mlist - 1)->move, CheckInfo(pos)))
mlist--;
--mlist;
return mlist;
}
@ -359,7 +359,7 @@ ExtMove* generate<EVASIONS>(const Position& pos, ExtMove* 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);
@ -417,7 +417,7 @@ ExtMove* generate<LEGAL>(const Position& pos, ExtMove* mlist) {
&& !pos.legal(cur->move, pinned))
cur->move = (--end)->move;
else
cur++;
++cur;
return end;
}

View file

@ -42,7 +42,7 @@ template<GenType T>
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 {

View file

@ -299,7 +299,7 @@ Move MovePicker::next_move<false>() {
switch (stage) {
case MAIN_SEARCH: case EVASION: case QSEARCH_0: case QSEARCH_1: case PROBCUT:
cur++;
++cur;
return ttMove;
case CAPTURES_S1:

View file

@ -227,7 +227,7 @@ Value Entry::shelter_storm(const Position& pos, Square ksq) {
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;

View file

@ -128,7 +128,7 @@ void Position::init() {
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)
@ -345,7 +345,7 @@ const string Position::fen() const {
int emptyCnt = 1;
for ( ; file < FILE_H && empty(++sq); ++file)
emptyCnt++;
++emptyCnt;
ss << emptyCnt;
}
@ -718,7 +718,7 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
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
@ -734,9 +734,9 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
// 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;
@ -978,7 +978,7 @@ void Position::undo_move(Move m) {
// Finally point our state pointer back to the previous state
st = st->previous;
gamePly--;
--gamePly;
assert(pos_is_ok());
}
@ -1019,7 +1019,7 @@ void Position::do_null_move(StateInfo& newSt) {
st->key ^= Zobrist::side;
prefetch((char*)TT.first_entry(st->key));
st->rule50++;
++st->rule50;
st->pliesFromNull = 0;
sideToMove = ~sideToMove;
@ -1106,7 +1106,7 @@ int Position::see(Move m, int asymmThreshold) const {
// 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);
@ -1150,7 +1150,7 @@ void Position::clear() {
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;
}
@ -1368,7 +1368,7 @@ bool Position::pos_is_ok(int* failedStep) const {
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;

View file

@ -131,7 +131,7 @@ void Search::init() {
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;
@ -146,11 +146,11 @@ void Search::init() {
}
// 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));
@ -341,7 +341,7 @@ namespace {
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)
@ -810,7 +810,7 @@ moves_loop: // When in check and at SpNode search starts from here
splitPoint->mutex.unlock();
}
else
moveCount++;
++moveCount;
if (RootNode)
{
@ -919,7 +919,7 @@ moves_loop: // When in check and at SpNode search starts from here
// Check for legality only before to do the move
if (!RootNode && !SpNode && !pos.legal(move, ci.pinned))
{
moveCount--;
--moveCount;
continue;
}
@ -1017,7 +1017,7 @@ moves_loop: // When in check and at SpNode search starts from here
// 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
@ -1443,7 +1443,7 @@ moves_loop: // When in check and at SpNode search starts from here
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
@ -1514,7 +1514,7 @@ moves_loop: // When in check and at SpNode search starts from here
<< " 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());
}
@ -1730,7 +1730,7 @@ void check_time() {
// 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];

View file

@ -296,7 +296,7 @@ void Thread::split(Position& pos, const Stack* ss, Value alpha, Value beta, Valu
Threads.mutex.lock();
sp.mutex.lock();
splitPointsSize++;
++splitPointsSize;
activeSplitPoint = &sp;
activePosition = NULL;
@ -336,7 +336,7 @@ void Thread::split(Position& pos, const Stack* ss, Value alpha, Value beta, Valu
}
searching = true;
splitPointsSize--;
--splitPointsSize;
activeSplitPoint = sp.parentSplitPoint;
activePosition = &pos;
pos.set_nodes_searched(pos.nodes_searched() + sp.nodes);

View file

@ -114,7 +114,7 @@ void TimeManager::init(const Search::LimitsType& limits, int currentPly, Color u
// 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]

View file

@ -73,7 +73,7 @@ const TTEntry* TranspositionTable::probe(const Key key) const {
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;
@ -97,7 +97,7 @@ void TranspositionTable::store(const Key key, Value v, Bound b, Depth d, Move m,
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
{

View file

@ -78,7 +78,7 @@ class TranspositionTable {
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;

View file

@ -94,7 +94,7 @@ void init(OptionsMap& o) {
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)
{