diff options
Diffstat (limited to 'src')
| -rwxr-xr-x | src/chess.h | 7 | ||||
| -rwxr-xr-x | src/generate.c | 8 | ||||
| -rwxr-xr-x | src/search.c | 7 | ||||
| -rw-r--r-- | src/searchsup.c | 51 | ||||
| -rwxr-xr-x | src/split.c | 5 |
5 files changed, 74 insertions, 4 deletions
diff --git a/src/chess.h b/src/chess.h index e47279d..fe5cd2b 100755 --- a/src/chess.h +++ b/src/chess.h @@ -689,6 +689,8 @@ POSITION; #define MVF_EXTEND_MOVE (2) #define MVF_REDUCE_MOVE (4) #define MVF_PRUNE_SUBTREE (8) +#define MVF_SEE_KNOWN (16) // SEE(pos, mv) was already computed +#define MVF_SEE_NONNEGATIVE (32) // ...and its sign was >= 0 typedef struct _MOVE_STACK_MOVE_VALUE_FLAGS { @@ -2357,6 +2359,11 @@ ComputeReactionToCheckExtension(IN OUT SEARCHER_THREAD_CONTEXT *ctx, IN OUT INT *piExtend, IN OUT INT *piOrigExtend); +SCORE +GetCheckSee(IN SEARCHER_THREAD_CONTEXT *ctx, + IN MOVE mv, + IN ULONG uMoveNum); + void ComputeMoveExtension(IN OUT SEARCHER_THREAD_CONTEXT *ctx, IN SCORE iAlpha, diff --git a/src/generate.c b/src/generate.c index f1ebab8..7d7778f 100755 --- a/src/generate.c +++ b/src/generate.c @@ -2522,6 +2522,7 @@ Return value: // // Captures and promotions, use SEE // + pStack->mvf[u].bvFlags &= ~(MVF_SEE_KNOWN | MVF_SEE_NONNEGATIVE); if (IS_CAPTURE_OR_PROMOTION(mv)) { ASSERT((mv.pCaptured) || (mv.pPromoted)); @@ -2530,6 +2531,8 @@ Return value: if ((s <= 0) || mv.pPromoted) { s = SEE(pos, mv); + pStack->mvf[u].bvFlags |= MVF_SEE_KNOWN | + ((s >= 0) ? MVF_SEE_NONNEGATIVE : 0); } if (s >= 0) @@ -2568,7 +2571,7 @@ Return value: s |= (IS_SAME_MOVE(sKillers[1].mv, mv) * sKillers[1].uBonus); s |= (IS_SAME_MOVE(sKillers[2].mv, mv) * sKillers[2].uBonus); s |= (IS_SAME_MOVE(sKillers[3].mv, mv) * sKillers[3].uBonus); - s |= ((GOOD_MOVE + PIECE_VALUE(mv.pMoved) / 2) * + s |= ((GOOD_MOVE + PIECE_VALUE(mv.pMoved) / 2) * (mv.cFrom == cEnprise)); ASSERT(s >= 0); } @@ -2683,6 +2686,7 @@ Return value: // // Captures and promotions, use SEE // + pStack->mvf[u].bvFlags &= ~(MVF_SEE_KNOWN | MVF_SEE_NONNEGATIVE); if (IS_CAPTURE_OR_PROMOTION(mv)) { ASSERT((mv.pCaptured) || (mv.pPromoted)); @@ -2691,6 +2695,8 @@ Return value: if ((s <= 0) || mv.pPromoted) { s = SEE(pos, mv); + pStack->mvf[u].bvFlags |= MVF_SEE_KNOWN | + ((s >= 0) ? MVF_SEE_NONNEGATIVE : 0); } if (s > 0) diff --git a/src/search.c b/src/search.c index 97cc850..0f814ea 100755 --- a/src/search.c +++ b/src/search.c @@ -534,7 +534,10 @@ Search(IN SEARCHER_THREAD_CONTEXT *ctx, iCheckSee = 0; if (IS_CHECKING_MOVE(mv)) { - iCheckSee = SEE(pos, mv); + iCheckSee = GetCheckSee(ctx, + mv, + (uStage == TRY_GENERATED_MOVES) ? + (x - 1) : (ULONG)-1); } if (TRUE == MakeMove(ctx, mv)) @@ -866,7 +869,7 @@ _ShouldWeConsiderThisMove(IN SEARCHER_THREAD_CONTEXT *ctx, { return(TRUE); } - return(SEE(&ctx->sPosition, mv) >= 0); + return(GetCheckSee(ctx, mv, uMoveNum) >= 0); } return(FALSE); } diff --git a/src/searchsup.c b/src/searchsup.c index 37eca66..9a2cc50 100644 --- a/src/searchsup.c +++ b/src/searchsup.c @@ -270,6 +270,57 @@ ComputeMoveScore(IN SEARCHER_THREAD_CONTEXT *ctx, } +SCORE +GetCheckSee(IN SEARCHER_THREAD_CONTEXT *ctx, + IN MOVE mv, + IN ULONG uMoveNum) +/** + +Routine description: + + SEE for a checking move, used by ComputeMoveExtension's callers + (Search, HelpSearch, and eventually QSearch) to decide how much to + extend/reduce a check. Must be computed on the PRE-move position -- + see.c's exchange walk needs the piece still sitting on cFrom. + + Move generation/scoring (_ScoreAllMoves, _ScoreAllEscapes in + generate.c) already runs a real SEE on this same (pos, mv) pair + whenever it scores an ambiguous capture or promotion, and stashes + the sign in the move's MVF_SEE_KNOWN/MVF_SEE_NONNEGATIVE flags. + Reuse that instead of walking the exchange (GetAttacks()) again. + Only the sign matters to any caller of ComputeMoveExtension, so the + cached value is coarsened to 0/-1. + +Parameters: + + SEARCHER_THREAD_CONTEXT *ctx : searcher thread context + MOVE mv : the checking move + ULONG uMoveNum : mv's index in ctx->sMoveStack.mvf[], or (ULONG)-1 + if mv did not come from the move stack (e.g. the hash move) + +Return value: + + SCORE + +**/ +{ + BITV bvFlags; + + ASSERT(IS_CHECKING_MOVE(mv)); + if (uMoveNum != (ULONG)-1) + { + ASSERT(uMoveNum < MAX_MOVE_STACK); + ASSERT(IS_SAME_MOVE(mv, ctx->sMoveStack.mvf[uMoveNum].mv)); + bvFlags = ctx->sMoveStack.mvf[uMoveNum].bvFlags; + if (bvFlags & MVF_SEE_KNOWN) + { + return((bvFlags & MVF_SEE_NONNEGATIVE) ? 0 : -1); + } + } + return(SEE(&ctx->sPosition, mv)); +} + + void ComputeMoveExtension(IN SEARCHER_THREAD_CONTEXT *ctx, IN SCORE iAlpha, diff --git a/src/split.c b/src/split.c index 703f6a8..bbaa518 100755 --- a/src/split.c +++ b/src/split.c @@ -1085,7 +1085,10 @@ Return value: iCheckSee = 0; if (IS_CHECKING_MOVE(mv)) { - iCheckSee = SEE(&ctx->sPosition, mv); + iCheckSee = GetCheckSee(ctx, + mv, + ctx->sMoveStack.uBegin[ctx->uPly] + + uMoveNum); } if (MakeMove(ctx, mv)) |
