本文整理汇总了C#中Portfish.Position.do_null_move方法的典型用法代码示例。如果您正苦于以下问题:C# Position.do_null_move方法的具体用法?C# Position.do_null_move怎么用?C# Position.do_null_move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Portfish.Position
的用法示例。
在下文中一共展示了Position.do_null_move方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: search
//.........这里部分代码省略.........
// Step 7. Static null move pruning (is omitted in PV nodes)
// We're betting that the opponent doesn't have a move that will reduce
// the score by more than futility_margin(depth) if we do a null move.
if (!PvNode && !inCheck
&& (ss[ssPos].skipNullMove == 0)
&& depth < RazorDepth
&& Math.Abs(beta) < ValueC.VALUE_MATE_IN_MAX_PLY
&& refinedValue - futility_margin(depth, 0) >= beta
&& (pos.non_pawn_material(pos.sideToMove) != 0))
{
MovesSearchedBroker.Free();
return refinedValue - futility_margin(depth, 0);
}
// Step 8. Null move search with verification search (is omitted in PV nodes)
if (!PvNode && !inCheck
&& (ss[ssPos].skipNullMove == 0)
&& depth > DepthC.ONE_PLY
&& refinedValue >= beta
&& Math.Abs(beta) < ValueC.VALUE_MATE_IN_MAX_PLY
&& (pos.non_pawn_material(pos.sideToMove) != 0))
{
ss[ssPos].currentMove = MoveC.MOVE_NULL;
// Null move dynamic reduction based on depth
int R = 3 + (depth >= 5 * DepthC.ONE_PLY ? depth / 8 : 0);
// Null move dynamic reduction based on value
if (refinedValue - Constants.PawnValueMidgame > beta)
R++;
if (st == null) { st = StateInfoBroker.GetObject(); }
pos.do_null_move(true, st);
ss[ssPos + 1].skipNullMove = 1;
nullValue = depth - R * DepthC.ONE_PLY < DepthC.ONE_PLY ? -qsearch(NodeTypeC.NonPV, pos, ss, ssPos + 1, -beta, -alpha, DepthC.DEPTH_ZERO)
: -search(NodeTypeC.NonPV, pos, ss, ssPos + 1, -beta, -alpha, depth - R * DepthC.ONE_PLY);
ss[ssPos + 1].skipNullMove = 0;
pos.do_null_move(false, st);
if (nullValue >= beta)
{
// Do not return unproven mate scores
if (nullValue >= ValueC.VALUE_MATE_IN_MAX_PLY)
nullValue = beta;
if (depth < 6 * DepthC.ONE_PLY)
{
if (st != null) { st.previous = null; StateInfoBroker.Free(); }
MovesSearchedBroker.Free();
return nullValue;
}
// Do verification search at high depths
ss[ssPos].skipNullMove = 1;
Value v = search(NodeTypeC.NonPV, pos, ss, ssPos, alpha, beta, depth - R * DepthC.ONE_PLY);
ss[ssPos].skipNullMove = 0;
if (v >= beta)
{
if (st != null) { st.previous = null; StateInfoBroker.Free(); }
MovesSearchedBroker.Free();
return nullValue;
}
}
else
示例2: search
//.........这里部分代码省略.........
}
}
// Step 7. Static null move pruning (is omitted in PV nodes)
// We're betting that the opponent doesn't have a move that will reduce
// the score by more than futility_margin(depth) if we do a null move.
if (!PvNode && !inCheck && (ss[ssPos].skipNullMove == 0) && depth < 4 * DepthC.ONE_PLY
&& Math.Abs(beta) < ValueC.VALUE_MATE_IN_MAX_PLY && eval - FutilityMargins[depth][0] >= beta
&& (pos.non_pawn_material(pos.sideToMove) != 0))
{
MovesSearchedBroker.Free();
return eval - FutilityMargins[depth][0];
}
// Step 8. Null move search with verification search (is omitted in PV nodes)
if (!PvNode && !inCheck && (ss[ssPos].skipNullMove == 0) && depth > DepthC.ONE_PLY && eval >= beta
&& Math.Abs(beta) < ValueC.VALUE_MATE_IN_MAX_PLY && (pos.non_pawn_material(pos.sideToMove) != 0))
{
ss[ssPos].currentMove = MoveC.MOVE_NULL;
// Null move dynamic reduction based on depth
Depth R = 3 * DepthC.ONE_PLY + depth / 4;
// Null move dynamic reduction based on value
if (eval - Constants.PawnValueMidgame > beta)
{
R += DepthC.ONE_PLY;
}
if (st == null)
{
st = StateInfoBroker.GetObject();
}
pos.do_null_move(st);
ss[ssPos + 1].skipNullMove = 1;
nullValue = depth - R < DepthC.ONE_PLY ? -qsearch(NodeTypeC.NonPV, false, pos, ss, ssPos + 1, -beta, -alpha, DepthC.DEPTH_ZERO)
: -search(NodeTypeC.NonPV, pos, ss, ssPos + 1, -beta, -alpha, depth - R);
ss[ssPos + 1].skipNullMove = 0;
pos.undo_null_move(st);
if (nullValue >= beta)
{
// Do not return unproven mate scores
if (nullValue >= ValueC.VALUE_MATE_IN_MAX_PLY)
{
nullValue = beta;
}
if (depth < 6 * DepthC.ONE_PLY)
{
if (st != null)
{
st.previous = null;
StateInfoBroker.Free();
}
MovesSearchedBroker.Free();
return nullValue;
}
// Do verification search at high depths
ss[ssPos].skipNullMove = 1;
var v = search(NodeTypeC.NonPV, pos, ss, ssPos, alpha, beta, depth - R);
ss[ssPos].skipNullMove = 0;