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

Better interface to get the current move type

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2008-10-06 05:32:09 +01:00
parent a3477af2a1
commit bbf7a94d76
3 changed files with 15 additions and 11 deletions

View file

@ -38,7 +38,6 @@ namespace {
/// Variables /// Variables
MovePicker::MovegenPhase PhaseTable[32];
int MainSearchPhaseIndex; int MainSearchPhaseIndex;
int EvasionsPhaseIndex; int EvasionsPhaseIndex;
int QsearchWithChecksPhaseIndex; int QsearchWithChecksPhaseIndex;
@ -46,6 +45,9 @@ namespace {
} }
// Static array definition
MovePicker::MovegenPhase MovePicker::PhaseTable[32];
//// ////
//// Functions //// Functions
@ -92,7 +94,7 @@ MovePicker::MovePicker(Position &p, bool pvnode, Move ttm, Move mk,
/// class. It returns a new legal move every time it is called, until there /// class. It returns a new legal move every time it is called, until there
/// are no more moves left of the types we are interested in. /// are no more moves left of the types we are interested in.
Move MovePicker::get_next_move(MovegenPhase* moveType) { Move MovePicker::get_next_move() {
Move move; Move move;
while(true) { while(true) {
@ -106,9 +108,6 @@ Move MovePicker::get_next_move(MovegenPhase* moveType) {
// Next phase: // Next phase:
phaseIndex++; phaseIndex++;
if (moveType)
*moveType = PhaseTable[phaseIndex];
switch(PhaseTable[phaseIndex]) { switch(PhaseTable[phaseIndex]) {
case PH_TT_MOVE: case PH_TT_MOVE:

View file

@ -61,11 +61,12 @@ public:
MovePicker(Position &p, bool pvnode, Move ttm, Move mk, Move k1, Move k2, MovePicker(Position &p, bool pvnode, Move ttm, Move mk, Move k1, Move k2,
Depth dpth); Depth dpth);
Move get_next_move(MovegenPhase* moveType = NULL); Move get_next_move();
Move get_next_move(Lock &lock); Move get_next_move(Lock &lock);
int number_of_moves() const; int number_of_moves() const;
int current_move_score() const; int current_move_score() const;
Bitboard discovered_check_candidates(); MovegenPhase current_move_type() const;
Bitboard discovered_check_candidates() const;
static void init_phase_table(); static void init_phase_table();
@ -80,6 +81,7 @@ private:
Move ttMove, mateKiller, killer1, killer2; Move ttMove, mateKiller, killer1, killer2;
Bitboard pinned, dc; Bitboard pinned, dc;
MoveStack moves[256], badCaptures[64]; MoveStack moves[256], badCaptures[64];
static MovegenPhase PhaseTable[32];
bool pvNode; bool pvNode;
Depth depth; Depth depth;
int phaseIndex; int phaseIndex;
@ -97,7 +99,11 @@ private:
/// all pieces which can possibly give discovered check. This bitboard is /// all pieces which can possibly give discovered check. This bitboard is
/// computed by the constructor function. /// computed by the constructor function.
inline Bitboard MovePicker::discovered_check_candidates() { inline MovePicker::MovegenPhase MovePicker::current_move_type() const {
return PhaseTable[phaseIndex];
}
inline Bitboard MovePicker::discovered_check_candidates() const {
return dc; return dc;
} }

View file

@ -1147,7 +1147,6 @@ namespace {
Value value, bestValue = -VALUE_INFINITE; Value value, bestValue = -VALUE_INFINITE;
Bitboard dcCandidates = mp.discovered_check_candidates(); Bitboard dcCandidates = mp.discovered_check_candidates();
Value futilityValue = VALUE_NONE; Value futilityValue = VALUE_NONE;
MovePicker::MovegenPhase moveType;
bool isCheck = pos.is_check(); bool isCheck = pos.is_check();
bool useFutilityPruning = UseFutilityPruning bool useFutilityPruning = UseFutilityPruning
&& depth < SelectiveDepth && depth < SelectiveDepth
@ -1156,14 +1155,14 @@ namespace {
// Loop through all legal moves until no moves remain or a beta cutoff // Loop through all legal moves until no moves remain or a beta cutoff
// occurs. // occurs.
while ( bestValue < beta while ( bestValue < beta
&& (move = mp.get_next_move(&moveType)) != MOVE_NONE && (move = mp.get_next_move()) != MOVE_NONE
&& !thread_should_stop(threadID)) && !thread_should_stop(threadID))
{ {
assert(move_is_ok(move)); assert(move_is_ok(move));
bool singleReply = (isCheck && mp.number_of_moves() == 1); bool singleReply = (isCheck && mp.number_of_moves() == 1);
bool moveIsCheck = pos.move_is_check(move, dcCandidates); bool moveIsCheck = pos.move_is_check(move, dcCandidates);
bool moveIsGoodCapture = (moveType == MovePicker::PH_GOOD_CAPTURES); bool moveIsGoodCapture = (mp.current_move_type() == MovePicker::PH_GOOD_CAPTURES);
bool moveIsPassedPawnPush = pos.move_is_passed_pawn_push(move); bool moveIsPassedPawnPush = pos.move_is_passed_pawn_push(move);
movesSearched[moveCount++] = ss[ply].currentMove = move; movesSearched[moveCount++] = ss[ply].currentMove = move;