本文整理汇总了C#中Portfish.Position.psq_score方法的典型用法代码示例。如果您正苦于以下问题:C# Position.psq_score方法的具体用法?C# Position.psq_score怎么用?C# Position.psq_score使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Portfish.Position
的用法示例。
在下文中一共展示了Position.psq_score方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: do_evaluate
//.........这里部分代码省略.........
{
var s = evaluate_space(ColorC.WHITE, pos, ei) - evaluate_space(ColorC.BLACK, pos, ei);
score += ((((((((s * ei.mi.spaceWeight) << 16) + 32768) & ~0xffff) / 0x10000
* (((Weights[EvalWeightC.Space] + 32768) & ~0xffff) / 0x10000)) / 0x100) << 16)
+ (((short)(((s * ei.mi.spaceWeight) << 16) & 0xffff)
* ((short)(Weights[EvalWeightC.Space] & 0xffff))) / 0x100));
}
// Scale winning side if position is more drawish that what it appears
var sf = ((short)(score & 0xffff)) > ValueC.VALUE_DRAW
? ei.mi.scale_factor_WHITE(pos)
: ei.mi.scale_factor_BLACK(pos);
// If we don't already have an unusual scale factor, check for opposite
// colored bishop endgames, and use a lower scale for those.
if (ei.mi.gamePhase < PhaseC.PHASE_MIDGAME
&& (pos.pieceCount[ColorC.WHITE][PieceTypeC.BISHOP] == 1
&& pos.pieceCount[ColorC.BLACK][PieceTypeC.BISHOP] == 1
&& (((((pos.pieceList[ColorC.WHITE][PieceTypeC.BISHOP][0]
^ pos.pieceList[ColorC.BLACK][PieceTypeC.BISHOP][0]) >> 3)
^ (pos.pieceList[ColorC.WHITE][PieceTypeC.BISHOP][0]
^ pos.pieceList[ColorC.BLACK][PieceTypeC.BISHOP][0])) & 1) != 0))
&& sf == ScaleFactorC.SCALE_FACTOR_NORMAL)
{
// Only the two bishops ?
if (pos.st.npMaterialWHITE == Constants.BishopValueMidgame
&& pos.st.npMaterialBLACK == Constants.BishopValueMidgame)
{
// Check for KBP vs KB with only a single pawn that is almost
// certainly a draw or at least two pawns.
sf = (pos.pieceCount[ColorC.WHITE][PieceTypeC.PAWN] + pos.pieceCount[ColorC.BLACK][PieceTypeC.PAWN]
== 1)
? (8)
: (32);
}
else
{
// Endgame with opposite-colored bishops, but also other pieces. Still
// a bit drawish, but not as drawish as with only the two bishops.
sf = (50);
}
}
// Interpolate between the middle game and the endgame score
margin = pos.sideToMove == ColorC.WHITE ? marginsWHITE : marginsBLACK;
// interpolate
//Value v = interpolate(score, ei.mi.game_phase(), sf);
var ev = (((short)(score & 0xffff)) * sf) / ScaleFactorC.SCALE_FACTOR_NORMAL;
var result = ((((score + 32768) & ~0xffff) / 0x10000) * ei.mi.gamePhase + ev * (128 - ei.mi.gamePhase)) / 128;
var v = ((result + GrainSize / 2) & ~(GrainSize - 1));
// In case of tracing add all single evaluation contributions for both white and black
if (Trace)
{
trace_add(TracedTypeC.PST, pos.psq_score());
trace_add(TracedTypeC.IMBALANCE, ei.mi.material_value());
trace_add(PieceTypeC.PAWN, ei.pi.pawns_value());
trace_add(
TracedTypeC.MOBILITY,
Utils.apply_weight(mobilityWhite, Weights[EvalWeightC.Mobility]),
Utils.apply_weight(mobilityBlack, Weights[EvalWeightC.Mobility]));
trace_add(
TracedTypeC.THREAT,
evaluate_threats(ColorC.WHITE, pos, ei),
evaluate_threats(ColorC.BLACK, pos, ei));
trace_add(
TracedTypeC.PASSED,
evaluate_passed_pawns(ColorC.WHITE, pos, ei),
evaluate_passed_pawns(ColorC.BLACK, pos, ei));
trace_add(TracedTypeC.UNSTOPPABLE, evaluate_unstoppable_pawns(pos, ei));
var w = Utils.make_score(ei.mi.space_weight() * evaluate_space(ColorC.WHITE, pos, ei), 0);
var b = Utils.make_score(ei.mi.space_weight() * evaluate_space(ColorC.BLACK, pos, ei), 0);
trace_add(
TracedTypeC.SPACE,
Utils.apply_weight(w, Weights[EvalWeightC.Space]),
Utils.apply_weight(b, Weights[EvalWeightC.Space]));
trace_add(TracedTypeC.TOTAL, score);
TraceStream.Append("\nUncertainty margin: White: ");
TraceStream.Append(FormatDouble(to_cp(marginsWHITE), null, true));
TraceStream.Append(", Black: ");
TraceStream.Append(FormatDouble(to_cp(marginsBLACK), null, true));
TraceStream.Append("\nScaling: ");
TraceStream.Append(FormatDouble((100.0 * ei.mi.game_phase() / 128.0), 6, false));
TraceStream.Append("% MG, ");
TraceStream.Append(FormatDouble((100.0 * (1.0 - ei.mi.game_phase() / 128.0)), 6, false));
TraceStream.Append("% * ");
TraceStream.Append(FormatDouble(((100.0 * sf) / ScaleFactorC.SCALE_FACTOR_NORMAL), 6, false));
TraceStream.Append("% EG.\n");
TraceStream.Append("Total evaluation: ");
TraceStream.Append(FormatDouble(to_cp(v), null, false));
}
ei.pi = null;
ei.mi = null;
EvalInfoBroker.Free();
return pos.sideToMove == ColorC.WHITE ? v : -v;
}