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

Retire MovePicker::discovered_check_candidates()

It is now no more needed to know dc candidates
inside MovePicker, so avoid calculating there.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2009-11-04 14:46:16 +01:00
parent 0855d93de8
commit 94dcac1fee
6 changed files with 12 additions and 23 deletions

View file

@ -143,13 +143,14 @@ MoveStack* generate_noncaptures(const Position& pos, MoveStack* mlist) {
/// generate_non_capture_checks() generates all pseudo-legal non-captures and knight
/// underpromotions that give check. Returns a pointer to the end of the move list.
MoveStack* generate_non_capture_checks(const Position& pos, MoveStack* mlist, Bitboard dc) {
MoveStack* generate_non_capture_checks(const Position& pos, MoveStack* mlist) {
assert(pos.is_ok());
assert(!pos.is_check());
Color us = pos.side_to_move();
Square ksq = pos.king_square(opposite_color(us));
Bitboard dc = pos.discovered_check_candidates(us);
assert(pos.piece_on(ksq) == piece_of_color_and_type(opposite_color(us), KING));

View file

@ -34,7 +34,7 @@
extern MoveStack* generate_captures(const Position& pos, MoveStack* mlist);
extern MoveStack* generate_noncaptures(const Position& pos, MoveStack* mlist);
extern MoveStack* generate_non_capture_checks(const Position& pos, MoveStack* mlist, Bitboard dc);
extern MoveStack* generate_non_capture_checks(const Position& pos, MoveStack* mlist);
extern MoveStack* generate_evasions(const Position& pos, MoveStack* mlist);
extern MoveStack* generate_moves(const Position& pos, MoveStack* mlist, bool pseudoLegal = false);
extern bool move_is_legal(const Position& pos, const Move m, Bitboard pinned);

View file

@ -86,10 +86,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d,
} else
ttMoves[1].move = killers[0].move = killers[1].move = MOVE_NONE;
Color us = pos.side_to_move();
dc = p.discovered_check_candidates(us);
pinned = p.pinned_pieces(us);
pinned = p.pinned_pieces(pos.side_to_move());
if (p.is_check())
phasePtr = EvasionsPhaseTable;
@ -155,7 +152,7 @@ void MovePicker::go_next_phase() {
case PH_QCHECKS:
// Perhaps we should order moves move here? FIXME
lastMove = generate_non_capture_checks(pos, moves, dc);
lastMove = generate_non_capture_checks(pos, moves);
return;
case PH_STOP:

View file

@ -54,7 +54,6 @@ public:
Move get_next_move();
Move get_next_move(Lock& lock);
int number_of_evasions() const;
Bitboard discovered_check_candidates() const;
private:
void score_captures();
@ -69,7 +68,7 @@ private:
int phase;
const uint8_t* phasePtr;
MoveStack *curMove, *lastMove, *lastBadCapture;
Bitboard dc, pinned;
Bitboard pinned;
MoveStack moves[256], badCaptures[64];
};
@ -88,12 +87,4 @@ inline int MovePicker::number_of_evasions() const {
return int(lastMove - moves);
}
/// MovePicker::discovered_check_candidates() returns a bitboard containing
/// all pieces which can possibly give discovered check. This bitboard is
/// computed by the constructor function.
inline Bitboard MovePicker::discovered_check_candidates() const {
return dc;
}
#endif // !defined(MOVEPICK_H_INCLUDED)

View file

@ -1718,11 +1718,10 @@ bool Position::has_mate_threat(Color c) {
MoveStack mlist[120];
bool result = false;
Bitboard dc = discovered_check_candidates(sideToMove);
Bitboard pinned = pinned_pieces(sideToMove);
// Generate pseudo-legal non-capture and capture check moves
MoveStack* last = generate_non_capture_checks(*this, mlist, dc);
MoveStack* last = generate_non_capture_checks(*this, mlist);
last = generate_captures(*this, last);
// Loop through the moves, and see if one of them is mate

View file

@ -334,7 +334,7 @@ int perft(Position& pos, Depth depth)
{
Move move;
MovePicker mp = MovePicker(pos, MOVE_NONE, depth, H);
Bitboard dcCandidates = mp.discovered_check_candidates();
Bitboard dcCandidates = pos.discovered_check_candidates(pos.side_to_move());
int sum = 0;
// If we are at the last ply we don't need to do and undo
@ -1110,7 +1110,7 @@ namespace {
bool mateThreat = pos.has_mate_threat(opposite_color(us));
MovePicker mp = MovePicker(pos, ttMove, depth, H, &ss[ply]);
Bitboard dcCandidates = mp.discovered_check_candidates();
Bitboard dcCandidates = pos.discovered_check_candidates(us);
// Loop through all legal moves until no moves remain or a beta cutoff
// occurs.
@ -1363,7 +1363,8 @@ namespace {
Move move, movesSearched[256];
int moveCount = 0;
Value value, bestValue = -VALUE_INFINITE;
Bitboard dcCandidates = mp.discovered_check_candidates();
Color us = pos.side_to_move();
Bitboard dcCandidates = pos.discovered_check_candidates(us);
Value futilityValue = VALUE_NONE;
bool useFutilityPruning = depth < SelectiveDepth
&& !isCheck;
@ -1583,8 +1584,8 @@ namespace {
MovePicker mp = MovePicker(pos, ttMove, depth, H);
Move move;
int moveCount = 0;
Bitboard dcCandidates = mp.discovered_check_candidates();
Color us = pos.side_to_move();
Bitboard dcCandidates = pos.discovered_check_candidates(us);
bool enoughMaterial = pos.non_pawn_material(us) > RookValueMidgame;
// Loop through the moves until no moves remain or a beta cutoff