1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-07-11 19:49:14 +00:00

Rename MoveStack to ExtMove

Stack has no meaning here, while ExtMove (extended move),
better clarifies that we have a move + a score.

No functional change.
This commit is contained in:
Marco Costalba 2013-07-19 10:27:15 +02:00
parent 110644d918
commit 99e547f4cb
5 changed files with 33 additions and 33 deletions

View file

@ -32,7 +32,7 @@
namespace { namespace {
template<CastlingSide Side, bool Checks, bool Chess960> template<CastlingSide Side, bool Checks, bool Chess960>
MoveStack* generate_castle(const Position& pos, MoveStack* mlist, Color us) { ExtMove* generate_castle(const Position& pos, ExtMove* mlist, Color us) {
if (pos.castle_impeded(us, Side) || !pos.can_castle(make_castle_right(us, Side))) if (pos.castle_impeded(us, Side) || !pos.can_castle(make_castle_right(us, Side)))
return mlist; return mlist;
@ -69,8 +69,8 @@ namespace {
template<GenType Type, Square Delta> template<GenType Type, Square Delta>
inline MoveStack* generate_promotions(MoveStack* mlist, Bitboard pawnsOn7, inline ExtMove* generate_promotions(ExtMove* mlist, Bitboard pawnsOn7,
Bitboard target, const CheckInfo* ci) { Bitboard target, const CheckInfo* ci) {
Bitboard b = shift_bb<Delta>(pawnsOn7) & target; Bitboard b = shift_bb<Delta>(pawnsOn7) & target;
@ -101,8 +101,8 @@ namespace {
template<Color Us, GenType Type> template<Color Us, GenType Type>
MoveStack* generate_pawn_moves(const Position& pos, MoveStack* mlist, ExtMove* generate_pawn_moves(const Position& pos, ExtMove* mlist,
Bitboard target, const CheckInfo* ci) { Bitboard target, const CheckInfo* ci) {
// Compute our parametrized parameters at compile time, named according to // Compute our parametrized parameters at compile time, named according to
// the point of view of white side. // the point of view of white side.
@ -206,8 +206,8 @@ namespace {
template<PieceType Pt, bool Checks> FORCE_INLINE template<PieceType Pt, bool Checks> FORCE_INLINE
MoveStack* generate_moves(const Position& pos, MoveStack* mlist, Color us, ExtMove* generate_moves(const Position& pos, ExtMove* mlist, Color us,
Bitboard target, const CheckInfo* ci) { Bitboard target, const CheckInfo* ci) {
assert(Pt != KING && Pt != PAWN); assert(Pt != KING && Pt != PAWN);
@ -238,8 +238,8 @@ namespace {
template<GenType Type> FORCE_INLINE template<GenType Type> FORCE_INLINE
MoveStack* generate_all(const Position& pos, MoveStack* mlist, Color us, ExtMove* generate_all(const Position& pos, ExtMove* mlist, Color us,
Bitboard target, const CheckInfo* ci = NULL) { Bitboard target, const CheckInfo* ci = NULL) {
const bool Checks = Type == QUIET_CHECKS; const bool Checks = Type == QUIET_CHECKS;
@ -289,7 +289,7 @@ namespace {
/// non-captures. Returns a pointer to the end of the move list. /// non-captures. Returns a pointer to the end of the move list.
template<GenType Type> template<GenType Type>
MoveStack* generate(const Position& pos, MoveStack* mlist) { ExtMove* generate(const Position& pos, ExtMove* mlist) {
assert(Type == CAPTURES || Type == QUIETS || Type == NON_EVASIONS); assert(Type == CAPTURES || Type == QUIETS || Type == NON_EVASIONS);
assert(!pos.checkers()); assert(!pos.checkers());
@ -304,15 +304,15 @@ MoveStack* generate(const Position& pos, MoveStack* mlist) {
} }
// Explicit template instantiations // Explicit template instantiations
template MoveStack* generate<CAPTURES>(const Position&, MoveStack*); template ExtMove* generate<CAPTURES>(const Position&, ExtMove*);
template MoveStack* generate<QUIETS>(const Position&, MoveStack*); template ExtMove* generate<QUIETS>(const Position&, ExtMove*);
template MoveStack* generate<NON_EVASIONS>(const Position&, MoveStack*); template ExtMove* generate<NON_EVASIONS>(const Position&, ExtMove*);
/// generate<QUIET_CHECKS> generates all pseudo-legal non-captures and knight /// generate<QUIET_CHECKS> generates all pseudo-legal non-captures and knight
/// underpromotions that give check. Returns a pointer to the end of the move list. /// underpromotions that give check. Returns a pointer to the end of the move list.
template<> template<>
MoveStack* generate<QUIET_CHECKS>(const Position& pos, MoveStack* mlist) { ExtMove* generate<QUIET_CHECKS>(const Position& pos, ExtMove* mlist) {
assert(!pos.checkers()); assert(!pos.checkers());
@ -342,7 +342,7 @@ MoveStack* generate<QUIET_CHECKS>(const Position& pos, MoveStack* mlist) {
/// generate<EVASIONS> generates all pseudo-legal check evasions when the side /// generate<EVASIONS> generates all pseudo-legal check evasions when the side
/// to move is in check. Returns a pointer to the end of the move list. /// to move is in check. Returns a pointer to the end of the move list.
template<> template<>
MoveStack* generate<EVASIONS>(const Position& pos, MoveStack* mlist) { ExtMove* generate<EVASIONS>(const Position& pos, ExtMove* mlist) {
assert(pos.checkers()); assert(pos.checkers());
@ -404,9 +404,9 @@ MoveStack* generate<EVASIONS>(const Position& pos, MoveStack* mlist) {
/// generate<LEGAL> generates all the legal moves in the given position /// generate<LEGAL> generates all the legal moves in the given position
template<> template<>
MoveStack* generate<LEGAL>(const Position& pos, MoveStack* mlist) { ExtMove* generate<LEGAL>(const Position& pos, ExtMove* mlist) {
MoveStack *end, *cur = mlist; ExtMove *end, *cur = mlist;
Bitboard pinned = pos.pinned_pieces(); Bitboard pinned = pos.pinned_pieces();
Square ksq = pos.king_square(pos.side_to_move()); Square ksq = pos.king_square(pos.side_to_move());

View file

@ -34,7 +34,7 @@ enum GenType {
class Position; class Position;
template<GenType> template<GenType>
MoveStack* generate(const Position& pos, MoveStack* mlist); ExtMove* generate(const Position& pos, ExtMove* mlist);
/// The MoveList struct is a simple wrapper around generate(), sometimes comes /// The MoveList struct is a simple wrapper around generate(), sometimes comes
/// handy to use this class instead of the low level generate() function. /// handy to use this class instead of the low level generate() function.
@ -46,13 +46,13 @@ struct MoveList {
Move operator*() const { return cur->move; } Move operator*() const { return cur->move; }
size_t size() const { return last - mlist; } size_t size() const { return last - mlist; }
bool contains(Move m) const { bool contains(Move m) const {
for (const MoveStack* it(mlist); it != last; ++it) if (it->move == m) return true; for (const ExtMove* it(mlist); it != last; ++it) if (it->move == m) return true;
return false; return false;
} }
private: private:
MoveStack mlist[MAX_MOVES]; ExtMove mlist[MAX_MOVES];
MoveStack *cur, *last; ExtMove *cur, *last;
}; };
#endif // !defined(MOVEGEN_H_INCLUDED) #endif // !defined(MOVEGEN_H_INCLUDED)

View file

@ -36,9 +36,9 @@ namespace {
}; };
// Our insertion sort, guaranteed to be stable, as is needed // Our insertion sort, guaranteed to be stable, as is needed
void insertion_sort(MoveStack* begin, MoveStack* end) void insertion_sort(ExtMove* begin, ExtMove* end)
{ {
MoveStack tmp, *p, *q; ExtMove tmp, *p, *q;
for (p = begin + 1; p < end; ++p) for (p = begin + 1; p < end; ++p)
{ {
@ -51,12 +51,12 @@ namespace {
// Unary predicate used by std::partition to split positive scores from remaining // Unary predicate used by std::partition to split positive scores from remaining
// ones so to sort separately the two sets, and with the second sort delayed. // ones so to sort separately the two sets, and with the second sort delayed.
inline bool has_positive_score(const MoveStack& ms) { return ms.score > 0; } inline bool has_positive_score(const ExtMove& ms) { return ms.score > 0; }
// Picks and moves to the front the best move in the range [begin, end), // Picks and moves to the front the best move in the range [begin, end),
// it is faster than sorting all the moves in advance when moves are few, as // it is faster than sorting all the moves in advance when moves are few, as
// normally are the possible captures. // normally are the possible captures.
inline MoveStack* pick_best(MoveStack* begin, MoveStack* end) inline ExtMove* pick_best(ExtMove* begin, ExtMove* end)
{ {
std::swap(*begin, *std::max_element(begin, end)); std::swap(*begin, *std::max_element(begin, end));
return begin; return begin;
@ -170,7 +170,7 @@ void MovePicker::score<CAPTURES>() {
// some SEE calls in case we get a cutoff (idea from Pablo Vazquez). // some SEE calls in case we get a cutoff (idea from Pablo Vazquez).
Move m; Move m;
for (MoveStack* it = moves; it != end; ++it) for (ExtMove* it = moves; it != end; ++it)
{ {
m = it->move; m = it->move;
it->score = PieceValue[MG][pos.piece_on(to_sq(m))] it->score = PieceValue[MG][pos.piece_on(to_sq(m))]
@ -189,7 +189,7 @@ void MovePicker::score<QUIETS>() {
Move m; Move m;
for (MoveStack* it = moves; it != end; ++it) for (ExtMove* it = moves; it != end; ++it)
{ {
m = it->move; m = it->move;
it->score = history[pos.piece_moved(m)][to_sq(m)]; it->score = history[pos.piece_moved(m)][to_sq(m)];
@ -204,7 +204,7 @@ void MovePicker::score<EVASIONS>() {
Move m; Move m;
int seeScore; int seeScore;
for (MoveStack* it = moves; it != end; ++it) for (ExtMove* it = moves; it != end; ++it)
{ {
m = it->move; m = it->move;
if ((seeScore = pos.see_sign(m)) < 0) if ((seeScore = pos.see_sign(m)) < 0)

View file

@ -100,11 +100,11 @@ private:
Move* countermoves; Move* countermoves;
Depth depth; Depth depth;
Move ttMove; Move ttMove;
MoveStack killers[4]; ExtMove killers[4];
Square recaptureSquare; Square recaptureSquare;
int captureThreshold, phase; int captureThreshold, phase;
MoveStack *cur, *end, *endQuiets, *endBadCaptures; ExtMove *cur, *end, *endQuiets, *endBadCaptures;
MoveStack moves[MAX_MOVES]; ExtMove moves[MAX_MOVES];
}; };
#endif // !defined(MOVEPICK_H_INCLUDED) #endif // !defined(MOVEPICK_H_INCLUDED)

View file

@ -313,12 +313,12 @@ inline Score operator/(Score s, int i) {
extern Value PieceValue[PHASE_NB][PIECE_NB]; extern Value PieceValue[PHASE_NB][PIECE_NB];
struct MoveStack { struct ExtMove {
Move move; Move move;
int score; int score;
}; };
inline bool operator<(const MoveStack& f, const MoveStack& s) { inline bool operator<(const ExtMove& f, const ExtMove& s) {
return f.score < s.score; return f.score < s.score;
} }