mirror of
https://github.com/sockspls/badfish
synced 2025-05-02 17:49:35 +00:00
Templetize make_move() helpers
No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
ebe8009aff
commit
dc88cd691f
3 changed files with 11 additions and 18 deletions
|
@ -442,7 +442,7 @@ Move Book::probe(const Position& pos, const string& fName, bool pickBest) {
|
||||||
// the special Move's flags (bit 14-15) that are not supported by PolyGlot.
|
// the special Move's flags (bit 14-15) that are not supported by PolyGlot.
|
||||||
int pt = (move >> 12) & 7;
|
int pt = (move >> 12) & 7;
|
||||||
if (pt)
|
if (pt)
|
||||||
move = make_promotion(from_sq(move), to_sq(move), PieceType(pt + 1));
|
move = make<PROMOTION>(from_sq(move), to_sq(move), PieceType(pt + 1));
|
||||||
|
|
||||||
// Add 'special move' flags and verify it is legal
|
// Add 'special move' flags and verify it is legal
|
||||||
for (MoveList<LEGAL> ml(pos); !ml.end(); ++ml)
|
for (MoveList<LEGAL> ml(pos); !ml.end(); ++ml)
|
||||||
|
|
|
@ -59,7 +59,7 @@ namespace {
|
||||||
&& (pos.attackers_to(kto, pos.pieces() ^ rfrom) & enemies))
|
&& (pos.attackers_to(kto, pos.pieces() ^ rfrom) & enemies))
|
||||||
return mlist;
|
return mlist;
|
||||||
|
|
||||||
(*mlist++).move = make_castle(kfrom, rfrom);
|
(*mlist++).move = make<CASTLE>(kfrom, rfrom);
|
||||||
|
|
||||||
if (OnlyChecks && !pos.move_gives_check((mlist - 1)->move, CheckInfo(pos)))
|
if (OnlyChecks && !pos.move_gives_check((mlist - 1)->move, CheckInfo(pos)))
|
||||||
mlist--;
|
mlist--;
|
||||||
|
@ -90,19 +90,19 @@ namespace {
|
||||||
Square to = pop_1st_bit(&b);
|
Square to = pop_1st_bit(&b);
|
||||||
|
|
||||||
if (Type == CAPTURES || Type == EVASIONS || Type == NON_EVASIONS)
|
if (Type == CAPTURES || Type == EVASIONS || Type == NON_EVASIONS)
|
||||||
(*mlist++).move = make_promotion(to - Delta, to, QUEEN);
|
(*mlist++).move = make<PROMOTION>(to - Delta, to, QUEEN);
|
||||||
|
|
||||||
if (Type == QUIETS || Type == EVASIONS || Type == NON_EVASIONS)
|
if (Type == QUIETS || Type == EVASIONS || Type == NON_EVASIONS)
|
||||||
{
|
{
|
||||||
(*mlist++).move = make_promotion(to - Delta, to, ROOK);
|
(*mlist++).move = make<PROMOTION>(to - Delta, to, ROOK);
|
||||||
(*mlist++).move = make_promotion(to - Delta, to, BISHOP);
|
(*mlist++).move = make<PROMOTION>(to - Delta, to, BISHOP);
|
||||||
(*mlist++).move = make_promotion(to - Delta, to, KNIGHT);
|
(*mlist++).move = make<PROMOTION>(to - Delta, to, KNIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Knight-promotion is the only one that can give a direct check not
|
// Knight-promotion is the only one that can give a direct check not
|
||||||
// already included in the queen-promotion.
|
// already included in the queen-promotion.
|
||||||
if (Type == QUIET_CHECKS && (StepAttacksBB[W_KNIGHT][to] & ksq))
|
if (Type == QUIET_CHECKS && (StepAttacksBB[W_KNIGHT][to] & ksq))
|
||||||
(*mlist++).move = make_promotion(to - Delta, to, KNIGHT);
|
(*mlist++).move = make<PROMOTION>(to - Delta, to, KNIGHT);
|
||||||
else
|
else
|
||||||
(void)ksq; // Silence a warning under MSVC
|
(void)ksq; // Silence a warning under MSVC
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ namespace {
|
||||||
assert(b1);
|
assert(b1);
|
||||||
|
|
||||||
while (b1)
|
while (b1)
|
||||||
(*mlist++).move = make_enpassant(pop_1st_bit(&b1), pos.ep_square());
|
(*mlist++).move = make<ENPASSANT>(pop_1st_bit(&b1), pos.ep_square());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
13
src/types.h
13
src/types.h
|
@ -447,16 +447,9 @@ inline Move make_move(Square from, Square to) {
|
||||||
return Move(to | (from << 6));
|
return Move(to | (from << 6));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Move make_promotion(Square from, Square to, PieceType pt) {
|
template<MoveType T>
|
||||||
return Move(to | (from << 6) | (1 << 14) | ((pt - 2) << 12)) ;
|
inline Move make(Square from, Square to, PieceType pt = KNIGHT) {
|
||||||
}
|
return Move(to | (from << 6) | T | ((pt - KNIGHT) << 12)) ;
|
||||||
|
|
||||||
inline Move make_enpassant(Square from, Square to) {
|
|
||||||
return Move(to | (from << 6) | (2 << 14));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Move make_castle(Square from, Square to) {
|
|
||||||
return Move(to | (from << 6) | (3 << 14));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool is_ok(Move m) {
|
inline bool is_ok(Move m) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue