mirror of
https://github.com/sockspls/badfish
synced 2025-07-11 19:49:14 +00:00
Implicit conversion from ExtMove to Move
Verified with perft there is no speed regression, and code is simpler. It is also conceptually correct becuase an extended move is just a move that happens to have also a score. No functional change.
This commit is contained in:
parent
81d6c4a0d6
commit
65f46794af
5 changed files with 15 additions and 13 deletions
|
@ -36,6 +36,8 @@ enum GenType {
|
||||||
struct ExtMove {
|
struct ExtMove {
|
||||||
Move move;
|
Move move;
|
||||||
Value value;
|
Value value;
|
||||||
|
|
||||||
|
operator Move() const { return move; }
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool operator<(const ExtMove& f, const ExtMove& s) {
|
inline bool operator<(const ExtMove& f, const ExtMove& s) {
|
||||||
|
@ -54,8 +56,8 @@ struct MoveList {
|
||||||
const ExtMove* begin() const { return moveList; }
|
const ExtMove* begin() const { return moveList; }
|
||||||
const ExtMove* end() const { return last; }
|
const ExtMove* end() const { return last; }
|
||||||
size_t size() const { return last - moveList; }
|
size_t size() const { return last - moveList; }
|
||||||
bool contains(Move m) const {
|
bool contains(Move move) const {
|
||||||
for (const ExtMove& ms : *this) if (ms.move == m) return true;
|
for (const auto& m : *this) if (m == move) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,19 +152,19 @@ uint64_t Search::perft(Position& pos, Depth depth) {
|
||||||
CheckInfo ci(pos);
|
CheckInfo ci(pos);
|
||||||
const bool leaf = (depth == 2 * ONE_PLY);
|
const bool leaf = (depth == 2 * ONE_PLY);
|
||||||
|
|
||||||
for (const ExtMove& ms : MoveList<LEGAL>(pos))
|
for (const auto& m : MoveList<LEGAL>(pos))
|
||||||
{
|
{
|
||||||
if (Root && depth <= ONE_PLY)
|
if (Root && depth <= ONE_PLY)
|
||||||
cnt = 1, nodes++;
|
cnt = 1, nodes++;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pos.do_move(ms.move, st, ci, pos.gives_check(ms.move, ci));
|
pos.do_move(m, st, ci, pos.gives_check(m, ci));
|
||||||
cnt = leaf ? MoveList<LEGAL>(pos).size() : perft<false>(pos, depth - ONE_PLY);
|
cnt = leaf ? MoveList<LEGAL>(pos).size() : perft<false>(pos, depth - ONE_PLY);
|
||||||
nodes += cnt;
|
nodes += cnt;
|
||||||
pos.undo_move(ms.move);
|
pos.undo_move(m);
|
||||||
}
|
}
|
||||||
if (Root)
|
if (Root)
|
||||||
sync_cout << UCI::move(ms.move, pos.is_chess960()) << ": " << cnt << sync_endl;
|
sync_cout << UCI::move(m, pos.is_chess960()) << ": " << cnt << sync_endl;
|
||||||
}
|
}
|
||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -365,10 +365,10 @@ void ThreadPool::start_thinking(const Position& pos, const LimitsType& limits,
|
||||||
assert(!states.get());
|
assert(!states.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const ExtMove& ms : MoveList<LEGAL>(pos))
|
for (const auto& m : MoveList<LEGAL>(pos))
|
||||||
if ( limits.searchmoves.empty()
|
if ( limits.searchmoves.empty()
|
||||||
|| std::count(limits.searchmoves.begin(), limits.searchmoves.end(), ms.move))
|
|| std::count(limits.searchmoves.begin(), limits.searchmoves.end(), m))
|
||||||
RootMoves.push_back(RootMove(ms.move));
|
RootMoves.push_back(RootMove(m));
|
||||||
|
|
||||||
main()->thinking = true;
|
main()->thinking = true;
|
||||||
main()->notify_one(); // Starts main thread
|
main()->notify_one(); // Starts main thread
|
||||||
|
|
|
@ -272,9 +272,9 @@ Move UCI::to_move(const Position& pos, string& str) {
|
||||||
if (str.length() == 5) // Junior could send promotion piece in uppercase
|
if (str.length() == 5) // Junior could send promotion piece in uppercase
|
||||||
str[4] = char(tolower(str[4]));
|
str[4] = char(tolower(str[4]));
|
||||||
|
|
||||||
for (const ExtMove& ms : MoveList<LEGAL>(pos))
|
for (const auto& m : MoveList<LEGAL>(pos))
|
||||||
if (str == UCI::move(ms.move, pos.is_chess960()))
|
if (str == UCI::move(m, pos.is_chess960()))
|
||||||
return ms.move;
|
return m;
|
||||||
|
|
||||||
return MOVE_NONE;
|
return MOVE_NONE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ void init(OptionsMap& o) {
|
||||||
std::ostream& operator<<(std::ostream& os, const OptionsMap& om) {
|
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 (auto& it : om)
|
for (const auto& it : om)
|
||||||
if (it.second.idx == idx)
|
if (it.second.idx == idx)
|
||||||
{
|
{
|
||||||
const Option& o = it.second;
|
const Option& o = it.second;
|
||||||
|
|
Loading…
Add table
Reference in a new issue