Skip to content

Commit

Permalink
- Remove cutNode condition : official-stockfish/Stockfish@7a8bcfc
Browse files Browse the repository at this point in the history
  - 不要なコード掃除
  - 探索パラメーター、いくつか復活
  • Loading branch information
yaneurao committed Dec 5, 2023
1 parent 376b10d commit ebcd645
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 30 deletions.
18 changes: 12 additions & 6 deletions source/engine/yaneuraou-engine/yaneuraou-param.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ PARAM_DEFINE PARAM_FUTILITY_MARGIN_BETA = 108;

// 静止探索でのfutility pruning
// 重要度 ★★★★☆
// 1つ前のバージョンの値 = 118。
// 元の値 = 200 , step = 10
// 元の値 = Stockfish 14 : 200 , Stockfish 16 : 200 , step = 20
// [PARAM] min:50,max:300,step:30,interval:1,time_rate:1,
PARAM_DEFINE PARAM_FUTILITY_MARGIN_QUIET = 170;

Expand All @@ -92,17 +91,18 @@ PARAM_DEFINE PARAM_FUTILITY_RETURN_DEPTH = 9;
// 親nodeでのfutilityの適用depth。
// 重要度 ★★★☆☆
// この枝刈り、depthの制限自体が要らないような気がする。→ そうでもなかった。→こんなdepthいじらんほうがマシ
// 元の値 = 13
// 元の値 = Stockfish 14 : 12 , Stockfish 16 : 13
// [PARAM] min:5,max:20,step:1,interval:1,time_rate:1,fixed
PARAM_DEFINE PARAM_FUTILITY_AT_PARENT_NODE_DEPTH = 13;

// 親nodeでのfutility margin
// 重要度 ★★★☆☆
// 元の値 = 127 , step = 10
// 元の値 = Stockfish 14 : 112 , Stockfish 16 : 127 , step = 10
// [PARAM] min:100,max:400,step:10,interval:1,time_rate:1,fixed
PARAM_DEFINE PARAM_FUTILITY_AT_PARENT_NODE_ALPHA = 127;

// 重要度 ★★★★☆
// 元の値 = 26 , step = 2
// 元の値 = Stockfish 14 : 31 , Stockfish 16 : 26 , step = 2
// [PARAM] min:15,max:50,step:2,interval:1,time_rate:1,fixed
PARAM_DEFINE PARAM_FUTILITY_AT_PARENT_NODE_GAMMA1 = 26;

Expand All @@ -121,7 +121,7 @@ PARAM_DEFINE PARAM_LMR_SEE_MARGIN1 = 175;
//

// 重要度 ★★★☆☆
// 元の値 = 152 , step = 10
// 元の値 = Stockfish 14 : 173 , Stockfish 16 : 152 , step = 10
// [PARAM] min:50,max:400,step:10,interval:1,time_rate:1,
PARAM_DEFINE PARAM_NULL_MOVE_DYNAMIC_GAMMA = 132;

Expand Down Expand Up @@ -174,6 +174,12 @@ PARAM_DEFINE PARAM_PROBCUT_MARGIN3 = 416;
// singular extension
//

// singular extensionの前提depth。
// これ変更すると他のパラメーターががらっと変わるので固定しておく。
// 元の値 = Stockfish 14 : 4 , Stockfish 16 : 4 , step = 1
// [PARAM] min:2,max:13,step:1,interval:2,time_rate:1,fixed
PARAM_DEFINE PARAM_SINGULAR_EXTENSION_DEPTH = 4;

// singular extensionのsingular betaを計算するときのマージン
// 重要度 ★★★★☆
// 元の値 = 64 , step = 8
Expand Down
32 changes: 8 additions & 24 deletions source/engine/yaneuraou-engine/yaneuraou-search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2139,7 +2139,7 @@ Value search(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth, boo

// Null move dynamic reduction based on depth and eval
// 残り探索深さと評価値によってnull moveの深さを動的に減らす
Depth R = std::min(int(eval - beta) / PARAM_NULL_MOVE_DYNAMIC_GAMMA/*152*/, 6) + depth / 3 + 4;
Depth R = std::min(int(eval - beta) / PARAM_NULL_MOVE_DYNAMIC_GAMMA, 6) + depth / 3 + 4;


ss->currentMove = MOVE_NULL;
Expand Down Expand Up @@ -2505,7 +2505,7 @@ Value search(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth, boo
}

// SEE based pruning for captures and checks (~11 Elo)
if (!pos.see_ge(move, - Value(PARAM_LMR_SEE_MARGIN1 /*185*/) * depth))
if (!pos.see_ge(move, - Value(PARAM_LMR_SEE_MARGIN1) * depth))
continue;
}
else
Expand Down Expand Up @@ -2551,7 +2551,8 @@ Value search(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth, boo
lmrDepth = std::max(lmrDepth, 0);

// Prune moves with negative SEE (~4 Elo)
if (!pos.see_ge(move, Value(- PARAM_FUTILITY_AT_PARENT_NODE_GAMMA1 /*26*/ * lmrDepth * lmrDepth)))
// lmrDepthの2乗に比例するのでこのパラメーターの影響はすごく大きい。
if (!pos.see_ge(move, Value(- PARAM_FUTILITY_AT_PARENT_NODE_GAMMA1 * lmrDepth * lmrDepth)))
continue;
}
}
Expand Down Expand Up @@ -2599,7 +2600,7 @@ Value search(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth, boo
if (!rootNode
&& move == ttMove
&& !excludedMove // 再帰的なsingular延長を除外する。
&& depth >= 4 - (thisThread->completedDepth > 24) + 2 * (PvNode && tte->is_pv())
&& depth >= PARAM_SINGULAR_EXTENSION_DEPTH - (thisThread->completedDepth > 24) + 2 * (PvNode && tte->is_pv())
/* && ttValue != VALUE_NONE Already implicit in the next condition */
&& abs(ttValue) < VALUE_TB_WIN_IN_MAX_PLY // 詰み絡みのスコアはsingular extensionはしない。(Stockfish 10~)
&& (tte->bound() & BOUND_LOWER)
Expand Down Expand Up @@ -2794,7 +2795,6 @@ Value search(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth, boo
// 相手の(1手前の)move countが大きければ、reductionを減らす。
// 相手の指し手をたくさん読んでいるのにこちらだけreductionするとバランスが悪いから。

// TODO : この > 7 の 7は調整が必要かも。
if ((ss - 1)->moveCount > 7)
r--;

Expand Down Expand Up @@ -2931,10 +2931,10 @@ Value search(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth, boo

else if (!PvNode || moveCount > 1)
{
// Increase reduction for cut nodes and not ttMove (~1 Elo)
// cut nodeのためにreductionを増やす。ttMove以外。

if (!ttMove && cutNode)
// Increase reduction if ttMove is not present (~1 Elo)
// ttMoveが存在しないならreductionを増やす。
if (!ttMove)
r += 2;

// Note that if expected reduction is high, we reduce search depth by 1 here
Expand Down Expand Up @@ -3718,29 +3718,13 @@ Value qsearch(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth)

// ここ、わりと棋力に影響する。下手なことするとR30ぐらい変わる。

#if 1
// If static exchange evaluation is much worse than what is needed to not
// fall below alpha we can prune this move
if (futilityBase > alpha && !pos.see_ge(move, (alpha - futilityBase) * 4))
{
bestValue = alpha;
continue;
}
#else
// 以下は、Stockfishの古いコードだが、⇓こちらの方が将棋に適合するかも。
// 無駄な王手回避を抑制できる。
//
// TODO :
// ここで生成されている指し手は、成りと歩の成りだけだが、SEEで歩の成りに加点していないので、
// ここでcontinueしてしまう。
// そもそもqsearchで歩の成りは生成しなくていいような気もする。
// Do not search moves with negative SEE values (~5 Elo)
// captureでも駒損する指し手は枝刈りする。
if ( bestValue > VALUE_TB_LOSS_IN_MAX_PLY
&& !pos.see_ge(move))
continue;
#endif
}

// movecount pruning for quiet check evasions
Expand Down

0 comments on commit ebcd645

Please sign in to comment.