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

Big renaming of move's helpers

The aim is to have shorter names without losing
readibility but, if possible, increasing it.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2012-01-01 16:00:00 +01:00
parent 8300ab149c
commit 67338e6f32
8 changed files with 88 additions and 92 deletions

View file

@ -404,7 +404,8 @@ Move Book::probe(const Position& pos, const string& fName, bool pickBest) {
BookEntry e; BookEntry e;
uint16_t best = 0; uint16_t best = 0;
unsigned sum = 0, bookMove = 0; unsigned sum = 0;
Move move = MOVE_NONE;
uint64_t key = book_key(pos); uint64_t key = book_key(pos);
if (fileName != fName && !open(fName.c_str())) if (fileName != fName && !open(fName.c_str()))
@ -422,10 +423,10 @@ Move Book::probe(const Position& pos, const string& fName, bool pickBest) {
// with lower score. Note that first entry is always chosen. // with lower score. Note that first entry is always chosen.
if ( (RKiss.rand<unsigned>() % sum < e.count) if ( (RKiss.rand<unsigned>() % sum < e.count)
|| (pickBest && e.count == best)) || (pickBest && e.count == best))
bookMove = e.move; move = Move(e.move);
} }
if (!bookMove) if (!move)
return MOVE_NONE; return MOVE_NONE;
// A PolyGlot book move is encoded as follows: // A PolyGlot book move is encoded as follows:
@ -438,16 +439,13 @@ Move Book::probe(const Position& pos, const string& fName, bool pickBest) {
// move is a promotion we have to convert to our representation, in all the // move is a promotion we have to convert to our representation, in all the
// other cases we can directly compare with a Move after having masked out // other cases we can directly compare with a Move after having masked out
// 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 promotion = (bookMove >> 12) & 7; int pt = (move >> 12) & 7;
if (pt)
move = make_promotion(from_sq(move), to_sq(move), PieceType(pt + 1));
if (promotion) // Add 'special move' flags and verify it is legal
bookMove = make_promotion_move(move_from(Move(bookMove)),
move_to(Move(bookMove)),
PieceType(promotion + 1));
// Convert bookMove to our internal Move format (and verify it is legal)
for (MoveList<MV_LEGAL> ml(pos); !ml.end(); ++ml) for (MoveList<MV_LEGAL> ml(pos); !ml.end(); ++ml)
if (bookMove == unsigned(ml.move() & ~(3 << 14))) if (move == (ml.move() & 0x3FFF))
return ml.move(); return ml.move();
return MOVE_NONE; return MOVE_NONE;

View file

@ -33,8 +33,8 @@ using std::string;
const string move_to_uci(Move m, bool chess960) { const string move_to_uci(Move m, bool chess960) {
Square from = move_from(m); Square from = from_sq(m);
Square to = move_to(m); Square to = to_sq(m);
string promotion; string promotion;
if (m == MOVE_NONE) if (m == MOVE_NONE)
@ -83,13 +83,13 @@ const string move_to_san(Position& pos, Move m) {
Bitboard attackers; Bitboard attackers;
bool ambiguousMove, ambiguousFile, ambiguousRank; bool ambiguousMove, ambiguousFile, ambiguousRank;
Square sq, from = move_from(m); Square sq, from = from_sq(m);
Square to = move_to(m); Square to = to_sq(m);
PieceType pt = type_of(pos.piece_on(from)); PieceType pt = type_of(pos.piece_on(from));
string san; string san;
if (is_castle(m)) if (is_castle(m))
san = (move_to(m) < move_from(m) ? "O-O-O" : "O-O"); san = (to_sq(m) < from_sq(m) ? "O-O-O" : "O-O");
else else
{ {
if (pt != PAWN) if (pt != PAWN)

View file

@ -372,20 +372,20 @@ namespace {
to = pop_1st_bit(&b); to = pop_1st_bit(&b);
if (Type == MV_CAPTURE || Type == MV_EVASION) if (Type == MV_CAPTURE || Type == MV_EVASION)
(*mlist++).move = make_promotion_move(to - Delta, to, QUEEN); (*mlist++).move = make_promotion(to - Delta, to, QUEEN);
if (Type == MV_NON_CAPTURE || Type == MV_EVASION) if (Type == MV_NON_CAPTURE || Type == MV_EVASION)
{ {
(*mlist++).move = make_promotion_move(to - Delta, to, ROOK); (*mlist++).move = make_promotion(to - Delta, to, ROOK);
(*mlist++).move = make_promotion_move(to - Delta, to, BISHOP); (*mlist++).move = make_promotion(to - Delta, to, BISHOP);
(*mlist++).move = make_promotion_move(to - Delta, to, KNIGHT); (*mlist++).move = make_promotion(to - Delta, to, KNIGHT);
} }
// This is the only possible under promotion that can give a check // This is the only possible under promotion that can give a check
// not already included in the queen-promotion. // not already included in the queen-promotion.
if ( Type == MV_CHECK if ( Type == MV_CHECK
&& bit_is_set(pos.attacks_from<KNIGHT>(to), pos.king_square(Delta > 0 ? BLACK : WHITE))) && bit_is_set(pos.attacks_from<KNIGHT>(to), pos.king_square(Delta > 0 ? BLACK : WHITE)))
(*mlist++).move = make_promotion_move(to - Delta, to, KNIGHT); (*mlist++).move = make_promotion(to - Delta, to, KNIGHT);
else (void)pos; // Silence a warning under MSVC else (void)pos; // Silence a warning under MSVC
} }
return mlist; return mlist;
@ -488,7 +488,7 @@ namespace {
while (b1) while (b1)
{ {
to = pop_1st_bit(&b1); to = pop_1st_bit(&b1);
(*mlist++).move = make_enpassant_move(to, pos.ep_square()); (*mlist++).move = make_enpassant(to, pos.ep_square());
} }
} }
return mlist; return mlist;
@ -535,7 +535,7 @@ namespace {
return mlist; return mlist;
} }
(*mlist++).move = make_castle_move(kfrom, rfrom); (*mlist++).move = make_castle(kfrom, rfrom);
return mlist; return mlist;
} }

View file

@ -254,8 +254,8 @@ void MovePicker::score_captures() {
for (MoveStack* cur = moves; cur != lastMove; cur++) for (MoveStack* cur = moves; cur != lastMove; cur++)
{ {
m = cur->move; m = cur->move;
cur->score = PieceValueMidgame[pos.piece_on(move_to(m))] cur->score = PieceValueMidgame[pos.piece_on(to_sq(m))]
- type_of(pos.piece_on(move_from(m))); - type_of(pos.piece_on(from_sq(m)));
if (is_promotion(m)) if (is_promotion(m))
cur->score += PieceValueMidgame[Piece(promotion_piece_type(m))]; cur->score += PieceValueMidgame[Piece(promotion_piece_type(m))];
@ -270,8 +270,8 @@ void MovePicker::score_noncaptures() {
for (MoveStack* cur = moves; cur != lastMove; cur++) for (MoveStack* cur = moves; cur != lastMove; cur++)
{ {
m = cur->move; m = cur->move;
from = move_from(m); from = from_sq(m);
cur->score = H.value(pos.piece_on(from), move_to(m)); cur->score = H.value(pos.piece_on(from), to_sq(m));
} }
} }
@ -293,10 +293,10 @@ void MovePicker::score_evasions() {
if ((seeScore = pos.see_sign(m)) < 0) if ((seeScore = pos.see_sign(m)) < 0)
cur->score = seeScore - History::MaxValue; // Be sure we are at the bottom cur->score = seeScore - History::MaxValue; // Be sure we are at the bottom
else if (pos.is_capture(m)) else if (pos.is_capture(m))
cur->score = PieceValueMidgame[pos.piece_on(move_to(m))] cur->score = PieceValueMidgame[pos.piece_on(to_sq(m))]
- type_of(pos.piece_on(move_from(m))) + History::MaxValue; - type_of(pos.piece_on(from_sq(m))) + History::MaxValue;
else else
cur->score = H.value(pos.piece_on(move_from(m)), move_to(m)); cur->score = H.value(pos.piece_on(from_sq(m)), to_sq(m));
} }
} }
@ -378,7 +378,7 @@ Move MovePicker::next_move() {
case PH_QRECAPTURES: case PH_QRECAPTURES:
move = (curMove++)->move; move = (curMove++)->move;
if (move_to(move) == recaptureSquare) if (to_sq(move) == recaptureSquare)
return move; return move;
break; break;

View file

@ -420,8 +420,8 @@ bool Position::move_attacks_square(Move m, Square s) const {
assert(square_is_ok(s)); assert(square_is_ok(s));
Bitboard occ, xray; Bitboard occ, xray;
Square from = move_from(m); Square from = from_sq(m);
Square to = move_to(m); Square to = to_sq(m);
Piece piece = piece_on(from); Piece piece = piece_on(from);
assert(!square_is_empty(from)); assert(!square_is_empty(from));
@ -451,7 +451,7 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
assert(pinned == pinned_pieces()); assert(pinned == pinned_pieces());
Color us = side_to_move(); Color us = side_to_move();
Square from = move_from(m); Square from = from_sq(m);
assert(color_of(piece_on(from)) == us); assert(color_of(piece_on(from)) == us);
assert(piece_on(king_square(us)) == make_piece(us, KING)); assert(piece_on(king_square(us)) == make_piece(us, KING));
@ -462,7 +462,7 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
if (is_enpassant(m)) if (is_enpassant(m))
{ {
Color them = flip(us); Color them = flip(us);
Square to = move_to(m); Square to = to_sq(m);
Square capsq = to + pawn_push(them); Square capsq = to + pawn_push(them);
Square ksq = king_square(us); Square ksq = king_square(us);
Bitboard b = occupied_squares(); Bitboard b = occupied_squares();
@ -484,13 +484,13 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
// square is attacked by the opponent. Castling moves are checked // square is attacked by the opponent. Castling moves are checked
// for legality during move generation. // for legality during move generation.
if (type_of(piece_on(from)) == KING) if (type_of(piece_on(from)) == KING)
return is_castle(m) || !(attackers_to(move_to(m)) & pieces(flip(us))); return is_castle(m) || !(attackers_to(to_sq(m)) & pieces(flip(us)));
// A non-king move is legal if and only if it is not pinned or it // A non-king move is legal if and only if it is not pinned or it
// is moving along the ray towards or away from the king. // is moving along the ray towards or away from the king.
return !pinned return !pinned
|| !bit_is_set(pinned, from) || !bit_is_set(pinned, from)
|| squares_aligned(from, move_to(m), king_square(us)); || squares_aligned(from, to_sq(m), king_square(us));
} }
@ -516,8 +516,8 @@ bool Position::is_pseudo_legal(const Move m) const {
Color us = sideToMove; Color us = sideToMove;
Color them = flip(sideToMove); Color them = flip(sideToMove);
Square from = move_from(m); Square from = from_sq(m);
Square to = move_to(m); Square to = to_sq(m);
Piece pc = piece_on(from); Piece pc = piece_on(from);
// Use a slower but simpler function for uncommon cases // Use a slower but simpler function for uncommon cases
@ -613,7 +613,7 @@ bool Position::is_pseudo_legal(const Move m) const {
{ {
Bitboard b = occupied_squares(); Bitboard b = occupied_squares();
clear_bit(&b, from); clear_bit(&b, from);
if (attackers_to(move_to(m), b) & pieces(flip(us))) if (attackers_to(to_sq(m), b) & pieces(flip(us)))
return false; return false;
} }
else else
@ -626,7 +626,7 @@ bool Position::is_pseudo_legal(const Move m) const {
// Our move must be a blocking evasion or a capture of the checking piece // Our move must be a blocking evasion or a capture of the checking piece
target = squares_between(checksq, king_square(us)) | checkers(); target = squares_between(checksq, king_square(us)) | checkers();
if (!bit_is_set(target, move_to(m))) if (!bit_is_set(target, to_sq(m)))
return false; return false;
} }
} }
@ -641,10 +641,10 @@ bool Position::move_gives_check(Move m, const CheckInfo& ci) const {
assert(is_ok(m)); assert(is_ok(m));
assert(ci.dcCandidates == discovered_check_candidates()); assert(ci.dcCandidates == discovered_check_candidates());
assert(color_of(piece_on(move_from(m))) == side_to_move()); assert(color_of(piece_on(from_sq(m))) == side_to_move());
Square from = move_from(m); Square from = from_sq(m);
Square to = move_to(m); Square to = to_sq(m);
PieceType pt = type_of(piece_on(from)); PieceType pt = type_of(piece_on(from));
// Direct check ? // Direct check ?
@ -766,8 +766,8 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
Color us = side_to_move(); Color us = side_to_move();
Color them = flip(us); Color them = flip(us);
Square from = move_from(m); Square from = from_sq(m);
Square to = move_to(m); Square to = to_sq(m);
Piece piece = piece_on(from); Piece piece = piece_on(from);
PieceType pt = type_of(piece); PieceType pt = type_of(piece);
PieceType capture = is_enpassant(m) ? PAWN : type_of(piece_on(to)); PieceType capture = is_enpassant(m) ? PAWN : type_of(piece_on(to));
@ -982,8 +982,8 @@ void Position::undo_move(Move m) {
Color us = side_to_move(); Color us = side_to_move();
Color them = flip(us); Color them = flip(us);
Square from = move_from(m); Square from = from_sq(m);
Square to = move_to(m); Square to = to_sq(m);
Piece piece = piece_on(to); Piece piece = piece_on(to);
PieceType pt = type_of(piece); PieceType pt = type_of(piece);
PieceType capture = st->capturedType; PieceType capture = st->capturedType;
@ -1077,8 +1077,8 @@ void Position::do_castle_move(Move m) {
Square kto, kfrom, rfrom, rto, kAfter, rAfter; Square kto, kfrom, rfrom, rto, kAfter, rAfter;
Color us = side_to_move(); Color us = side_to_move();
Square kBefore = move_from(m); Square kBefore = from_sq(m);
Square rBefore = move_to(m); Square rBefore = to_sq(m);
// Find after-castle squares for king and rook // Find after-castle squares for king and rook
if (rBefore > kBefore) // O-O if (rBefore > kBefore) // O-O
@ -1228,8 +1228,8 @@ int Position::see_sign(Move m) const {
assert(is_ok(m)); assert(is_ok(m));
Square from = move_from(m); Square from = from_sq(m);
Square to = move_to(m); Square to = to_sq(m);
// Early return if SEE cannot be negative because captured piece value // Early return if SEE cannot be negative because captured piece value
// is not less then capturing one. Note that king moves always return // is not less then capturing one. Note that king moves always return
@ -1256,8 +1256,8 @@ int Position::see(Move m) const {
if (is_castle(m)) if (is_castle(m))
return 0; return 0;
from = move_from(m); from = from_sq(m);
to = move_to(m); to = to_sq(m);
capturedType = type_of(piece_on(to)); capturedType = type_of(piece_on(to));
occ = occupied_squares(); occ = occupied_squares();

View file

@ -428,8 +428,8 @@ inline Value Position::non_pawn_material(Color c) const {
inline bool Position::is_passed_pawn_push(Move m) const { inline bool Position::is_passed_pawn_push(Move m) const {
return board[move_from(m)] == make_piece(sideToMove, PAWN) return board[from_sq(m)] == make_piece(sideToMove, PAWN)
&& pawn_is_passed(sideToMove, move_to(m)); && pawn_is_passed(sideToMove, to_sq(m));
} }
inline int Position::startpos_ply_counter() const { inline int Position::startpos_ply_counter() const {
@ -454,14 +454,14 @@ inline bool Position::is_chess960() const {
inline bool Position::is_capture_or_promotion(Move m) const { inline bool Position::is_capture_or_promotion(Move m) const {
assert(is_ok(m)); assert(is_ok(m));
return is_special(m) ? !is_castle(m) : !square_is_empty(move_to(m)); return is_special(m) ? !is_castle(m) : !square_is_empty(to_sq(m));
} }
inline bool Position::is_capture(Move m) const { inline bool Position::is_capture(Move m) const {
// Note that castle is coded as "king captures the rook" // Note that castle is coded as "king captures the rook"
assert(is_ok(m)); assert(is_ok(m));
return (!square_is_empty(move_to(m)) && !is_castle(m)) || is_enpassant(m); return (!square_is_empty(to_sq(m)) && !is_castle(m)) || is_enpassant(m);
} }
inline PieceType Position::captured_piece_type() const { inline PieceType Position::captured_piece_type() const {

View file

@ -197,19 +197,19 @@ namespace {
FORCE_INLINE bool is_dangerous(const Position& pos, Move m, bool captureOrPromotion) { FORCE_INLINE bool is_dangerous(const Position& pos, Move m, bool captureOrPromotion) {
// Test for a pawn pushed to 7th or a passed pawn move // Test for a pawn pushed to 7th or a passed pawn move
if (type_of(pos.piece_on(move_from(m))) == PAWN) if (type_of(pos.piece_on(from_sq(m))) == PAWN)
{ {
Color c = pos.side_to_move(); Color c = pos.side_to_move();
if ( relative_rank(c, move_to(m)) == RANK_7 if ( relative_rank(c, to_sq(m)) == RANK_7
|| pos.pawn_is_passed(c, move_to(m))) || pos.pawn_is_passed(c, to_sq(m)))
return true; return true;
} }
// Test for a capture that triggers a pawn endgame // Test for a capture that triggers a pawn endgame
if ( captureOrPromotion if ( captureOrPromotion
&& type_of(pos.piece_on(move_to(m))) != PAWN && type_of(pos.piece_on(to_sq(m))) != PAWN
&& ( pos.non_pawn_material(WHITE) + pos.non_pawn_material(BLACK) && ( pos.non_pawn_material(WHITE) + pos.non_pawn_material(BLACK)
- PieceValueMidgame[pos.piece_on(move_to(m))] == VALUE_ZERO) - PieceValueMidgame[pos.piece_on(to_sq(m))] == VALUE_ZERO)
&& !is_special(m)) && !is_special(m))
return true; return true;
@ -290,19 +290,17 @@ void Search::think() {
// Populate RootMoves with all the legal moves (default) or, if a SearchMoves // Populate RootMoves with all the legal moves (default) or, if a SearchMoves
// is given, with the subset of legal moves to search. // is given, with the subset of legal moves to search.
for (MoveList<MV_LEGAL> ml(pos); !ml.end(); ++ml) for (MoveList<MV_LEGAL> ml(pos); !ml.end(); ++ml)
if ( SearchMoves.empty() if (SearchMoves.empty() || count(SearchMoves.begin(), SearchMoves.end(), ml.move()))
|| count(SearchMoves.begin(), SearchMoves.end(), ml.move()))
RootMoves.push_back(RootMove(ml.move())); RootMoves.push_back(RootMove(ml.move()));
if (Options["OwnBook"]) if (Options["OwnBook"])
{ {
Move bookMove = book.probe(pos, Options["Book File"], Options["Best Book Move"]); Move bookMove = book.probe(pos, Options["Book File"], Options["Best Book Move"]);
if ( bookMove != MOVE_NONE if (bookMove && count(RootMoves.begin(), RootMoves.end(), bookMove))
&& count(RootMoves.begin(), RootMoves.end(), bookMove))
{ {
std::swap(RootMoves[0], *find(RootMoves.begin(), RootMoves.end(), bookMove)); std::swap(RootMoves[0], *find(RootMoves.begin(), RootMoves.end(), bookMove));
goto finish; goto finalize;
} }
} }
@ -372,7 +370,7 @@ void Search::think() {
pos.undo_move(RootMoves[0].pv[0]); pos.undo_move(RootMoves[0].pv[0]);
} }
finish: finalize:
// When we reach max depth we arrive here even without a StopRequest, but if // When we reach max depth we arrive here even without a StopRequest, but if
// we are pondering or in infinite search, we shouldn't print the best move // we are pondering or in infinite search, we shouldn't print the best move
@ -703,7 +701,7 @@ namespace {
&& pos.captured_piece_type() == NO_PIECE_TYPE && pos.captured_piece_type() == NO_PIECE_TYPE
&& !is_special(move)) && !is_special(move))
{ {
Square to = move_to(move); Square to = to_sq(move);
H.update_gain(pos.piece_on(to), to, -(ss-1)->eval - ss->eval); H.update_gain(pos.piece_on(to), to, -(ss-1)->eval - ss->eval);
} }
@ -968,7 +966,7 @@ split_point_start: // At split points actual search starts from here
// but fixing this made program slightly weaker. // but fixing this made program slightly weaker.
Depth predictedDepth = newDepth - reduction<PvNode>(depth, moveCount); Depth predictedDepth = newDepth - reduction<PvNode>(depth, moveCount);
futilityValue = futilityBase + futility_margin(predictedDepth, moveCount) futilityValue = futilityBase + futility_margin(predictedDepth, moveCount)
+ H.gain(pos.piece_on(move_from(move)), move_to(move)); + H.gain(pos.piece_on(from_sq(move)), to_sq(move));
if (futilityValue < beta) if (futilityValue < beta)
{ {
@ -1152,13 +1150,13 @@ split_point_start: // At split points actual search starts from here
// Increase history value of the cut-off move // Increase history value of the cut-off move
Value bonus = Value(int(depth) * int(depth)); Value bonus = Value(int(depth) * int(depth));
H.add(pos.piece_on(move_from(move)), move_to(move), bonus); H.add(pos.piece_on(from_sq(move)), to_sq(move), bonus);
// Decrease history of all the other played non-capture moves // Decrease history of all the other played non-capture moves
for (int i = 0; i < playedMoveCount - 1; i++) for (int i = 0; i < playedMoveCount - 1; i++)
{ {
Move m = movesSearched[i]; Move m = movesSearched[i];
H.add(pos.piece_on(move_from(m)), move_to(m), -bonus); H.add(pos.piece_on(from_sq(m)), to_sq(m), -bonus);
} }
} }
} }
@ -1264,7 +1262,7 @@ split_point_start: // At split points actual search starts from here
// to search the moves. Because the depth is <= 0 here, only captures, // to search the moves. Because the depth is <= 0 here, only captures,
// queen promotions and checks (only if depth >= DEPTH_QS_CHECKS) will // queen promotions and checks (only if depth >= DEPTH_QS_CHECKS) will
// be generated. // be generated.
MovePicker mp(pos, ttMove, depth, H, move_to((ss-1)->currentMove)); MovePicker mp(pos, ttMove, depth, H, to_sq((ss-1)->currentMove));
CheckInfo ci(pos); CheckInfo ci(pos);
// Loop through the moves until no moves remain or a beta cutoff occurs // Loop through the moves until no moves remain or a beta cutoff occurs
@ -1285,7 +1283,7 @@ split_point_start: // At split points actual search starts from here
&& !pos.is_passed_pawn_push(move)) && !pos.is_passed_pawn_push(move))
{ {
futilityValue = futilityBase futilityValue = futilityBase
+ PieceValueEndgame[pos.piece_on(move_to(move))] + PieceValueEndgame[pos.piece_on(to_sq(move))]
+ (is_enpassant(move) ? PawnValueEndgame : VALUE_ZERO); + (is_enpassant(move) ? PawnValueEndgame : VALUE_ZERO);
if (futilityValue < beta) if (futilityValue < beta)
@ -1389,8 +1387,8 @@ split_point_start: // At split points actual search starts from here
Color them; Color them;
Value futilityValue, bv = *bestValue; Value futilityValue, bv = *bestValue;
from = move_from(move); from = from_sq(move);
to = move_to(move); to = to_sq(move);
them = flip(pos.side_to_move()); them = flip(pos.side_to_move());
ksq = pos.king_square(them); ksq = pos.king_square(them);
kingAtt = pos.attacks_from<KING>(ksq); kingAtt = pos.attacks_from<KING>(ksq);
@ -1450,14 +1448,14 @@ split_point_start: // At split points actual search starts from here
assert(is_ok(m2)); assert(is_ok(m2));
// Case 1: The moving piece is the same in both moves // Case 1: The moving piece is the same in both moves
f2 = move_from(m2); f2 = from_sq(m2);
t1 = move_to(m1); t1 = to_sq(m1);
if (f2 == t1) if (f2 == t1)
return true; return true;
// Case 2: The destination square for m2 was vacated by m1 // Case 2: The destination square for m2 was vacated by m1
t2 = move_to(m2); t2 = to_sq(m2);
f1 = move_from(m1); f1 = from_sq(m1);
if (t2 == f1) if (t2 == f1)
return true; return true;
@ -1530,10 +1528,10 @@ split_point_start: // At split points actual search starts from here
Square mfrom, mto, tfrom, tto; Square mfrom, mto, tfrom, tto;
mfrom = move_from(m); mfrom = from_sq(m);
mto = move_to(m); mto = to_sq(m);
tfrom = move_from(threat); tfrom = from_sq(threat);
tto = move_to(threat); tto = to_sq(threat);
// Case 1: Don't prune moves which move the threatened piece // Case 1: Don't prune moves which move the threatened piece
if (mfrom == tto) if (mfrom == tto)

View file

@ -432,11 +432,11 @@ inline Square pawn_push(Color c) {
return c == WHITE ? DELTA_N : DELTA_S; return c == WHITE ? DELTA_N : DELTA_S;
} }
inline Square move_from(Move m) { inline Square from_sq(Move m) {
return Square((m >> 6) & 0x3F); return Square((m >> 6) & 0x3F);
} }
inline Square move_to(Move m) { inline Square to_sq(Move m) {
return Square(m & 0x3F); return Square(m & 0x3F);
} }
@ -464,20 +464,20 @@ inline Move make_move(Square from, Square to) {
return Move(to | (from << 6)); return Move(to | (from << 6));
} }
inline Move make_promotion_move(Square from, Square to, PieceType promotion) { inline Move make_promotion(Square from, Square to, PieceType pt) {
return Move(to | (from << 6) | (1 << 14) | ((promotion - 2) << 12)) ; return Move(to | (from << 6) | (1 << 14) | ((pt - 2) << 12)) ;
} }
inline Move make_enpassant_move(Square from, Square to) { inline Move make_enpassant(Square from, Square to) {
return Move(to | (from << 6) | (2 << 14)); return Move(to | (from << 6) | (2 << 14));
} }
inline Move make_castle_move(Square from, Square to) { inline Move make_castle(Square from, Square to) {
return Move(to | (from << 6) | (3 << 14)); return Move(to | (from << 6) | (3 << 14));
} }
inline bool is_ok(Move m) { inline bool is_ok(Move m) {
return move_from(m) != move_to(m); // Catches also MOVE_NULL and MOVE_NONE return from_sq(m) != to_sq(m); // Catches also MOVE_NULL and MOVE_NONE
} }
#include <string> #include <string>