Seems more conventional.
No functional change.
move = make<PROMOTION>(from_sq(move), to_sq(move), PieceType(pt + 1));
// Add 'special move' flags and verify it is legal
move = make<PROMOTION>(from_sq(move), to_sq(move), PieceType(pt + 1));
// Add 'special move' flags and verify it is legal
- for (MoveList<LEGAL> ml(pos); !ml.end(); ++ml)
- if (move == (ml.move() ^ type_of(ml.move())))
- return ml.move();
+ for (MoveList<LEGAL> it(pos); !it.end(); ++it)
+ if (move == (*it ^ type_of(*it)))
+ return *it;
explicit MoveList(const Position& pos) : cur(mlist), last(generate<T>(pos, mlist)) {}
void operator++() { cur++; }
explicit MoveList(const Position& pos) : cur(mlist), last(generate<T>(pos, mlist)) {}
void operator++() { cur++; }
+ Move operator*() const { return cur->move; }
bool end() const { return cur == last; }
bool end() const { return cur == last; }
- Move move() const { return cur->move; }
size_t size() const { return last - mlist; }
bool contains(Move m) const {
for (const MoveStack* it(mlist); it != last; ++it) if (it->move == m) return true;
size_t size() const { return last - mlist; }
bool contains(Move m) const {
for (const MoveStack* it(mlist); it != last; ++it) if (it->move == m) return true;
if (str.length() == 5) // Junior could send promotion piece in uppercase
str[4] = char(tolower(str[4]));
if (str.length() == 5) // Junior could send promotion piece in uppercase
str[4] = char(tolower(str[4]));
- for (MoveList<LEGAL> ml(pos); !ml.end(); ++ml)
- if (str == move_to_uci(ml.move(), pos.is_chess960()))
- return ml.move();
+ for (MoveList<LEGAL> it(pos); !it.end(); ++it)
+ if (str == move_to_uci(*it, pos.is_chess960()))
+ return *it;
ss << square_to_string(pop_lsb(&b)) << " ";
ss << "\nLegal moves: ";
ss << square_to_string(pop_lsb(&b)) << " ";
ss << "\nLegal moves: ";
- for (MoveList<LEGAL> ml(*this); !ml.end(); ++ml)
- ss << move_to_san(*const_cast<Position*>(this), ml.move()) << " ";
+ for (MoveList<LEGAL> it(*this); !it.end(); ++it)
+ ss << move_to_san(*const_cast<Position*>(this), *it) << " ";
size_t cnt = 0;
CheckInfo ci(pos);
size_t cnt = 0;
CheckInfo ci(pos);
- for (MoveList<LEGAL> ml(pos); !ml.end(); ++ml)
+ for (MoveList<LEGAL> it(pos); !it.end(); ++it)
- pos.do_move(ml.move(), st, ci, pos.move_gives_check(ml.move(), ci));
+ pos.do_move(*it, st, ci, pos.move_gives_check(*it, ci));
cnt += perft(pos, depth - ONE_PLY);
cnt += perft(pos, depth - ONE_PLY);
- pos.undo_move(ml.move());
SetupStates = states; // Ownership transfer here
RootMoves.clear();
SetupStates = states; // Ownership transfer here
RootMoves.clear();
- for (MoveList<LEGAL> ml(pos); !ml.end(); ++ml)
+ for (MoveList<LEGAL> it(pos); !it.end(); ++it)
- || std::count(searchMoves.begin(), searchMoves.end(), ml.move()))
- RootMoves.push_back(RootMove(ml.move()));
+ || std::count(searchMoves.begin(), searchMoves.end(), *it))
+ RootMoves.push_back(RootMove(*it));
main_thread()->thinking = true;
main_thread()->notify_one(); // Starts main thread
main_thread()->thinking = true;
main_thread()->notify_one(); // Starts main thread