Retire mate threat extension
It seems we have a lot of totally useless code ! After 8577 games 1504 - 1451 - 5622 ELO +2 (+- 4.4) Signed-off-by: Marco Costalba <mcostalba@gmail.com>sf_2.3.1_base
parent
9bee5f51d8
commit
8e71ee7ec6
|
@ -1689,46 +1689,6 @@ bool Position::is_mate() const {
|
|||
}
|
||||
|
||||
|
||||
/// Position::has_mate_threat() tests whether the side to move is under
|
||||
/// a threat of being mated in one from the current position.
|
||||
|
||||
bool Position::has_mate_threat() {
|
||||
|
||||
MoveStack mlist[MOVES_MAX], *last, *cur;
|
||||
StateInfo st1, st2;
|
||||
bool mateFound = false;
|
||||
|
||||
// If we are under check it's up to evasions to do the job
|
||||
if (is_check())
|
||||
return false;
|
||||
|
||||
// First pass the move to our opponent doing a null move
|
||||
do_null_move(st1);
|
||||
|
||||
// Then generate pseudo-legal moves that could give check
|
||||
last = generate<MV_NON_CAPTURE_CHECK>(*this, mlist);
|
||||
last = generate<MV_CAPTURE>(*this, last);
|
||||
|
||||
// Loop through the moves, and see if one of them gives mate
|
||||
Bitboard pinned = pinned_pieces(sideToMove);
|
||||
CheckInfo ci(*this);
|
||||
for (cur = mlist; !mateFound && cur != last; cur++)
|
||||
{
|
||||
Move move = cur->move;
|
||||
if ( !pl_move_is_legal(move, pinned)
|
||||
|| !move_is_check(move, ci))
|
||||
continue;
|
||||
|
||||
do_move(move, st2, ci, true);
|
||||
mateFound = is_mate();
|
||||
undo_move(move);
|
||||
}
|
||||
|
||||
undo_null_move();
|
||||
return mateFound;
|
||||
}
|
||||
|
||||
|
||||
/// Position::init_zobrist() is a static member function which initializes at
|
||||
/// startup the various arrays used to compute hash keys.
|
||||
|
||||
|
|
|
@ -231,9 +231,6 @@ public:
|
|||
bool is_mate() const;
|
||||
bool is_draw() const;
|
||||
|
||||
// Check if side to move could be mated in one
|
||||
bool has_mate_threat();
|
||||
|
||||
// Number of plies from starting position
|
||||
int startpos_ply_counter() const;
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ namespace {
|
|||
|
||||
template <bool Fake>
|
||||
void split(Position& pos, SearchStack* ss, int ply, Value* alpha, const Value beta, Value* bestValue,
|
||||
Depth depth, Move threatMove, bool mateThreat, int moveCount, MovePicker* mp, bool pvNode);
|
||||
Depth depth, Move threatMove, int moveCount, MovePicker* mp, bool pvNode);
|
||||
|
||||
private:
|
||||
Depth minimumSplitDepth;
|
||||
|
@ -192,8 +192,8 @@ namespace {
|
|||
|
||||
// Extensions. Configurable UCI options
|
||||
// Array index 0 is used at non-PV nodes, index 1 at PV nodes.
|
||||
Depth CheckExtension[2], PawnPushTo7thExtension[2], PassedPawnExtension[2];
|
||||
Depth PawnEndgameExtension[2], MateThreatExtension[2];
|
||||
Depth CheckExtension[2], PawnPushTo7thExtension[2];
|
||||
Depth PassedPawnExtension[2], PawnEndgameExtension[2];
|
||||
|
||||
// Minimum depth for use of singular extension
|
||||
const Depth SingularExtensionDepth[2] = { 8 * ONE_PLY /* non-PV */, 6 * ONE_PLY /* PV */};
|
||||
|
@ -280,7 +280,7 @@ namespace {
|
|||
}
|
||||
|
||||
template <NodeType PvNode>
|
||||
Depth extension(const Position& pos, Move m, bool captureOrPromotion, bool moveIsCheck, bool mateThreat, bool* dangerous);
|
||||
Depth extension(const Position& pos, Move m, bool captureOrPromotion, bool moveIsCheck, bool* dangerous);
|
||||
|
||||
bool check_is_dangerous(Position &pos, Move move, Value futilityBase, Value beta, Value *bValue);
|
||||
bool connected_moves(const Position& pos, Move m1, Move m2);
|
||||
|
@ -484,8 +484,6 @@ bool think(Position& pos, bool infinite, bool ponder, int time[], int increment[
|
|||
PassedPawnExtension[0] = Options["Passed Pawn Extension (non-PV nodes)"].value<Depth>();
|
||||
PawnEndgameExtension[1] = Options["Pawn Endgame Extension (PV nodes)"].value<Depth>();
|
||||
PawnEndgameExtension[0] = Options["Pawn Endgame Extension (non-PV nodes)"].value<Depth>();
|
||||
MateThreatExtension[1] = Options["Mate Threat Extension (PV nodes)"].value<Depth>();
|
||||
MateThreatExtension[0] = Options["Mate Threat Extension (non-PV nodes)"].value<Depth>();
|
||||
UCIMultiPV = Options["MultiPV"].value<int>();
|
||||
SkillLevel = Options["Skill level"].value<int>();
|
||||
UseLogFile = Options["Use Search Log"].value<bool>();
|
||||
|
@ -792,7 +790,6 @@ namespace {
|
|||
Value bestValue, value, oldAlpha;
|
||||
Value refinedValue, nullValue, futilityBase, futilityValueScaled; // Non-PV specific
|
||||
bool isPvMove, isCheck, singularExtensionNode, moveIsCheck, captureOrPromotion, dangerous, isBadCap;
|
||||
bool mateThreat = false;
|
||||
int moveCount = 0, playedMoveCount = 0;
|
||||
int threadID = pos.thread();
|
||||
SplitPoint* sp = NULL;
|
||||
|
@ -807,7 +804,6 @@ namespace {
|
|||
tte = NULL;
|
||||
ttMove = excludedMove = MOVE_NONE;
|
||||
threatMove = sp->threatMove;
|
||||
mateThreat = sp->mateThreat;
|
||||
goto split_point_start;
|
||||
}
|
||||
else if (Root)
|
||||
|
@ -957,9 +953,6 @@ namespace {
|
|||
// move which was reduced. If a connection is found, return a fail
|
||||
// low score (which will cause the reduced move to fail high in the
|
||||
// parent node, which will trigger a re-search with full depth).
|
||||
if (nullValue == value_mated_in(ply + 2))
|
||||
mateThreat = true;
|
||||
|
||||
threatMove = (ss+1)->bestMove;
|
||||
|
||||
if ( depth < ThreatDepth
|
||||
|
@ -985,10 +978,6 @@ namespace {
|
|||
tte = TT.retrieve(posKey);
|
||||
}
|
||||
|
||||
// Mate threat detection for PV nodes, otherwise we use null move search
|
||||
if (PvNode)
|
||||
mateThreat = pos.has_mate_threat();
|
||||
|
||||
split_point_start: // At split points actual search starts from here
|
||||
|
||||
// Initialize a MovePicker object for the current position
|
||||
|
@ -1055,7 +1044,7 @@ split_point_start: // At split points actual search starts from here
|
|||
captureOrPromotion = pos.move_is_capture_or_promotion(move);
|
||||
|
||||
// Step 11. Decide the new search depth
|
||||
ext = extension<PvNode>(pos, move, captureOrPromotion, moveIsCheck, mateThreat, &dangerous);
|
||||
ext = extension<PvNode>(pos, move, captureOrPromotion, moveIsCheck, &dangerous);
|
||||
|
||||
// Singular extension search. If all moves but one fail low on a search of
|
||||
// (alpha-s, beta-s), and just one fails high on (alpha, beta), then that move
|
||||
|
@ -1309,7 +1298,7 @@ split_point_start: // At split points actual search starts from here
|
|||
&& !StopRequest
|
||||
&& !ThreadsMgr.cutoff_at_splitpoint(threadID))
|
||||
ThreadsMgr.split<FakeSplit>(pos, ss, ply, &alpha, beta, &bestValue, depth,
|
||||
threatMove, mateThreat, moveCount, &mp, PvNode);
|
||||
threatMove, moveCount, &mp, PvNode);
|
||||
}
|
||||
|
||||
// Step 19. Check for mate and stalemate
|
||||
|
@ -1696,21 +1685,15 @@ split_point_start: // At split points actual search starts from here
|
|||
// the move is marked as 'dangerous' so, at least, we avoid to prune it.
|
||||
template <NodeType PvNode>
|
||||
Depth extension(const Position& pos, Move m, bool captureOrPromotion,
|
||||
bool moveIsCheck, bool mateThreat, bool* dangerous) {
|
||||
bool moveIsCheck, bool* dangerous) {
|
||||
|
||||
assert(m != MOVE_NONE);
|
||||
|
||||
Depth result = DEPTH_ZERO;
|
||||
*dangerous = moveIsCheck | mateThreat;
|
||||
*dangerous = moveIsCheck;
|
||||
|
||||
if (*dangerous)
|
||||
{
|
||||
if (moveIsCheck && pos.see_sign(m) >= 0)
|
||||
result += CheckExtension[PvNode];
|
||||
|
||||
if (mateThreat)
|
||||
result += MateThreatExtension[PvNode];
|
||||
}
|
||||
if (moveIsCheck && pos.see_sign(m) >= 0)
|
||||
result += CheckExtension[PvNode];
|
||||
|
||||
if (pos.type_of_piece_on(move_from(m)) == PAWN)
|
||||
{
|
||||
|
@ -2311,7 +2294,7 @@ split_point_start: // At split points actual search starts from here
|
|||
template <bool Fake>
|
||||
void ThreadsManager::split(Position& pos, SearchStack* ss, int ply, Value* alpha,
|
||||
const Value beta, Value* bestValue, Depth depth, Move threatMove,
|
||||
bool mateThreat, int moveCount, MovePicker* mp, bool pvNode) {
|
||||
int moveCount, MovePicker* mp, bool pvNode) {
|
||||
assert(pos.is_ok());
|
||||
assert(ply > 0 && ply < PLY_MAX);
|
||||
assert(*bestValue >= -VALUE_INFINITE);
|
||||
|
@ -2346,7 +2329,6 @@ split_point_start: // At split points actual search starts from here
|
|||
splitPoint.ply = ply;
|
||||
splitPoint.depth = depth;
|
||||
splitPoint.threatMove = threatMove;
|
||||
splitPoint.mateThreat = mateThreat;
|
||||
splitPoint.alpha = *alpha;
|
||||
splitPoint.beta = beta;
|
||||
splitPoint.pvNode = pvNode;
|
||||
|
|
|
@ -36,7 +36,7 @@ struct SplitPoint {
|
|||
SplitPoint* parent;
|
||||
const Position* pos;
|
||||
Depth depth;
|
||||
bool pvNode, mateThreat;
|
||||
bool pvNode;
|
||||
Value beta;
|
||||
int ply;
|
||||
int master;
|
||||
|
|
|
@ -81,8 +81,6 @@ void init_uci_options() {
|
|||
Options["Cowardice"] = Option(100, 0, 200);
|
||||
Options["Check Extension (PV nodes)"] = Option(2, 0, 2);
|
||||
Options["Check Extension (non-PV nodes)"] = Option(1, 0, 2);
|
||||
Options["Mate Threat Extension (PV nodes)"] = Option(2, 0, 2);
|
||||
Options["Mate Threat Extension (non-PV nodes)"] = Option(2, 0, 2);
|
||||
Options["Pawn Push to 7th Extension (PV nodes)"] = Option(1, 0, 2);
|
||||
Options["Pawn Push to 7th Extension (non-PV nodes)"] = Option(1, 0, 2);
|
||||
Options["Passed Pawn Extension (PV nodes)"] = Option(1, 0, 2);
|
||||
|
|
Loading…
Reference in New Issue