本文整理汇总了C#中Portfish.Position.captured_piece_type方法的典型用法代码示例。如果您正苦于以下问题:C# Position.captured_piece_type方法的具体用法?C# Position.captured_piece_type怎么用?C# Position.captured_piece_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Portfish.Position
的用法示例。
在下文中一共展示了Position.captured_piece_type方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: search
//.........这里部分代码省略.........
&& (ttMove != 0)
&& !pos.is_capture_or_promotion(ttMove)
&& ttMove != ss[ssPos].killers0)
{
ss[ssPos].killers1 = ss[ssPos].killers0;
ss[ssPos].killers0 = ttMove;
}
MovesSearchedBroker.Free();
return ttValue;
}
// Step 5. Evaluate the position statically and update parent's gain statistics
if (inCheck)
ss[ssPos].eval = ss[ssPos].evalMargin = ValueC.VALUE_NONE;
else if (tteHasValue)
{
Debug.Assert(tte.static_value() != ValueC.VALUE_NONE);
ss[ssPos].eval = tte.static_value();
ss[ssPos].evalMargin = tte.static_value_margin();
refinedValue = refine_eval(tte, ttValue, ss[ssPos].eval);
}
else
{
refinedValue = ss[ssPos].eval = Evaluate.do_evaluate(false, pos, ref ss[ssPos].evalMargin);
TT.store(posKey, ValueC.VALUE_NONE, Bound.BOUND_NONE, DepthC.DEPTH_NONE, MoveC.MOVE_NONE, ss[ssPos].eval, ss[ssPos].evalMargin);
}
// Update gain for the parent non-capture move given the static position
// evaluation before and after the move.
if ((move = ss[ssPos - 1].currentMove) != MoveC.MOVE_NULL
&& ss[ssPos - 1].eval != ValueC.VALUE_NONE
&& ss[ssPos].eval != ValueC.VALUE_NONE
&& (pos.captured_piece_type() == 0)
&& !Utils.is_special(move))
{
Square to = Utils.to_sq(move);
H.update_gain(pos.piece_on(to), to, -ss[ssPos - 1].eval - ss[ssPos].eval);
}
// Step 6. Razoring (is omitted in PV nodes)
if (!PvNode && !inCheck
&& depth < RazorDepth
&& refinedValue + razor_margin(depth) < beta
&& ttMove == MoveC.MOVE_NONE
&& Math.Abs(beta) < ValueC.VALUE_MATE_IN_MAX_PLY
&& !pos.pawn_on_7th(pos.sideToMove))
{
Value rbeta = beta - razor_margin(depth);
Value v = qsearch(NodeTypeC.NonPV, pos, ss, ssPos, rbeta - 1, rbeta, DepthC.DEPTH_ZERO);
if (v < rbeta)
{
// Logically we should return (v + razor_margin(depth)), but
// surprisingly this did slightly weaker in tests.
MovesSearchedBroker.Free();
return v;
}
}
// 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
示例2: search
//.........这里部分代码省略.........
// Never assume anything on values stored in TT
if ((ss[ssPos].staticEval = eval = tte.eval_value()) == ValueC.VALUE_NONE
|| (ss[ssPos].evalMargin = tte.eval_margin()) == ValueC.VALUE_NONE)
{
eval = ss[ssPos].staticEval = Evaluate.do_evaluate(false, pos, ref ss[ssPos].evalMargin);
}
// Can ttValue be used as a better position evaluation?
if (ttValue != ValueC.VALUE_NONE)
{
if ((((tte.type() & Bound.BOUND_LOWER) != 0) && ttValue > eval)
|| (((tte.type() & Bound.BOUND_UPPER) != 0) && ttValue < eval))
{
eval = ttValue;
}
}
}
else
{
eval = ss[ssPos].staticEval = Evaluate.do_evaluate(false, pos, ref ss[ssPos].evalMargin);
TT.store(
posKey,
ValueC.VALUE_NONE,
Bound.BOUND_NONE,
DepthC.DEPTH_NONE,
MoveC.MOVE_NONE,
ss[ssPos].staticEval,
ss[ssPos].evalMargin);
}
// Update gain for the parentSplitPoint non-capture move given the static position
// evaluation before and after the move.
if ((move = ss[ssPos - 1].currentMove) != MoveC.MOVE_NULL && ss[ssPos - 1].staticEval != ValueC.VALUE_NONE
&& ss[ssPos].staticEval != ValueC.VALUE_NONE && (pos.captured_piece_type() == 0) && Utils.type_of_move(move) == MoveTypeC.NORMAL)
{
var to = Utils.to_sq(move);
H.update_gain(pos.piece_on(to), to, -ss[ssPos - 1].staticEval - ss[ssPos].staticEval);
}
// Step 6. Razoring (is omitted in PV nodes)
if (!PvNode && !inCheck && depth < 4 * DepthC.ONE_PLY && eval + razor_margin(depth) < beta
&& ttMove == MoveC.MOVE_NONE && Math.Abs(beta) < ValueC.VALUE_MATE_IN_MAX_PLY
&& !pos.pawn_on_7th(pos.sideToMove))
{
var rbeta = beta - razor_margin(depth);
var v = qsearch(NodeTypeC.NonPV, false, pos, ss, ssPos, rbeta - 1, rbeta, DepthC.DEPTH_ZERO);
if (v < rbeta)
{
// Logically we should return (v + razor_margin(depth)), but
// surprisingly this did slightly weaker in tests.
MovesSearchedBroker.Free();
return v;
}
}
// 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];
}
示例3: id_loop
//.........这里部分代码省略.........
// If search has been stopped exit the aspiration window loop.
// Sorting and writing PV back to TT is safe becuase RootMoves
// is still valid, although refers to previous iteration.
if (SignalsStop)
break;
// Send full PV info to GUI if we are going to leave the loop or
// if we have a fail high/low and we are deep in the search.
if ((bestValue > alpha && bestValue < beta) || SearchTime.ElapsedMilliseconds > 2000)
pv_info_to_uci(pos, depth, alpha, beta);
// In case of failing high/low increase aspiration window and
// research, otherwise exit the fail high/low loop.
if (bestValue >= beta)
{
beta += delta;
delta += delta / 2;
}
else if (bestValue <= alpha)
{
SignalsFailedLowAtRoot = true;
SignalsStopOnPonderhit = false;
alpha -= delta;
delta += delta / 2;
}
else
break;
Debug.Assert(alpha >= -ValueC.VALUE_INFINITE && beta <= ValueC.VALUE_INFINITE);
} while (Math.Abs(bestValue) < ValueC.VALUE_KNOWN_WIN);
}
// Skills: Do we need to pick now the best move ?
if (SkillLevelEnabled && depth == 1 + SkillLevel)
skillBest = do_skill_level();
// Filter out startup noise when monitoring best move stability
if (depth > 2 && (BestMoveChanges != 0))
bestMoveNeverChanged = false;
// Do we have time for the next iteration? Can we stop searching now?
if (!SignalsStop && !SignalsStopOnPonderhit && Limits.use_time_management())
{
bool stop = false; // Local variable, not the volatile Signals.stop
// Take in account some extra time if the best move has changed
if (depth > 4 && depth < 50)
TimeMgr.pv_instability(BestMoveChanges, prevBestMoveChanges);
// Stop search if most of available time is already consumed. We
// probably don't have enough time to search the first move at the
// next iteration anyway.
if (SearchTime.ElapsedMilliseconds > (TimeMgr.available_time() * 62) / 100)
stop = true;
// Stop search early if one move seems to be much better than others
if (depth >= 12
&& !stop
&& ((bestMoveNeverChanged && (pos.captured_piece_type() != 0))
|| SearchTime.ElapsedMilliseconds > (TimeMgr.available_time() * 40) / 100))
{
Value rBeta = bestValue - EasyMoveMargin;
ss[ssPos + 1].excludedMove = RootMoves[0].pv[0];
ss[ssPos + 1].skipNullMove = 1;
Value v = search(NodeTypeC.NonPV, pos, ss, ssPos + 1, rBeta - 1, rBeta, (depth - 3) * DepthC.ONE_PLY);
ss[ssPos + 1].skipNullMove = 0;
ss[ssPos + 1].excludedMove = MoveC.MOVE_NONE;
if (v < rBeta)
stop = true;
}
if (stop)
{
// If we are allowed to ponder do not stop the search now but
// keep pondering until GUI sends "ponderhit" or "stop".
if (Limits.ponder)
SignalsStopOnPonderhit = true;
else
SignalsStop = true;
}
}
}
// When using skills swap best PV line with the sub-optimal one
if (SkillLevelEnabled)
{
if (skillBest == MoveC.MOVE_NONE) // Still unassigned ?
skillBest = do_skill_level();
int bestpos = find(RootMoves, 0, RootMoves.Count, skillBest);
RootMove temp = RootMoves[0];
RootMoves[0] = RootMoves[bestpos];
RootMoves[bestpos] = temp;
}
LoopStackBroker.Free(ls);
}
示例4: id_loop
//.........这里部分代码省略.........
delta += delta / 2;
}
Debug.Assert(alpha >= -ValueC.VALUE_INFINITE && beta <= ValueC.VALUE_INFINITE);
}
// Sort the PV lines searched so far and update the GUI
Utils.sort(RootMoves, 0, PVIdx + 1);
if (PVIdx + 1 == PVSize || SearchTime.ElapsedMilliseconds > 3000)
{
pv_info_to_uci(pos, depth, alpha, beta);
}
}
// Do we need to pick now the sub-optimal best move ?
if (skill.enabled() && skill.time_to_pick(depth))
{
skill.pick_move();
}
// Filter out startup noise when monitoring best move stability
if (depth > 2 && (BestMoveChanges != 0))
{
bestMoveNeverChanged = false;
}
// Do we have found a "mate in x"?
if (Limits.mate != 0
&& bestValue >= ValueC.VALUE_MATE_IN_MAX_PLY
&& ValueC.VALUE_MATE - bestValue <= 2 * Limits.mate)
{
SignalsStop = true;
}
// Do we have time for the next iteration? Can we stop searching now?
if (Limits.use_time_management() && !SignalsStopOnPonderhit)
{
var stop = false; // Local variable, not the volatile Signals.stop
// Take in account some extra time if the best move has changed
if (depth > 4 && depth < 50 && PVSize == 1)
{
TimeMgr.pv_instability(BestMoveChanges, prevBestMoveChanges);
}
// Stop search if most of available time is already consumed. We
// probably don't have enough time to search the first move at the
// next iteration anyway.
if (SearchTime.ElapsedMilliseconds > (TimeMgr.available_time() * 62) / 100)
{
stop = true;
}
// Stop search early if one move seems to be much better than others
if (depth >= 12
&& !stop
&& PVSize == 1
&& ((bestMoveNeverChanged && (pos.captured_piece_type() != 0))
|| SearchTime.ElapsedMilliseconds > (TimeMgr.available_time() * 40) / 100))
{
var rBeta = bestValue - 2 * Constants.PawnValueMidgame;
ss[ssPos + 1].excludedMove = RootMoves[0].pv[0];
ss[ssPos + 1].skipNullMove = 1;
var v = search(
NodeTypeC.NonPV,
pos,
ss,
ssPos + 1,
rBeta - 1,
rBeta,
(depth - 3) * DepthC.ONE_PLY);
ss[ssPos + 1].skipNullMove = 0;
ss[ssPos + 1].excludedMove = MoveC.MOVE_NONE;
if (v < rBeta)
{
stop = true;
}
}
if (stop)
{
// If we are allowed to ponder do not stop the search now but
// keep pondering until GUI sends "ponderhit" or "stop".
if (Limits.ponder)
{
SignalsStopOnPonderhit = true;
}
else
{
SignalsStop = true;
}
}
}
}
}
LoopStackBroker.Free(ls);
}