本文整理汇总了C#中Portfish.Position.pawn_is_passed方法的典型用法代码示例。如果您正苦于以下问题:C# Position.pawn_is_passed方法的具体用法?C# Position.pawn_is_passed怎么用?C# Position.pawn_is_passed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Portfish.Position
的用法示例。
在下文中一共展示了Position.pawn_is_passed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: evaluate_passed_pawns
// evaluate_passed_pawns<>() evaluates the passed pawns of the given color
private static int evaluate_passed_pawns(int Us, Position pos, EvalInfo ei)
{
var Them = (Us == ColorC.WHITE ? ColorC.BLACK : ColorC.WHITE);
ulong b, squaresToQueen, defendedSquares, unsafeSquares, supportingPawns;
var score = ScoreC.SCORE_ZERO;
b = (Us == ColorC.WHITE) ? ei.pi.passedPawnsWHITE : ei.pi.passedPawnsBLACK;
if (b == 0)
{
return ScoreC.SCORE_ZERO;
}
do
{
#if X64
Bitboard bb = b;
b &= (b - 1);
Square s = (Utils.BSFTable[((bb & (0xffffffffffffffff - bb + 1)) * DeBruijn_64) >> 58]);
#else
var s = Utils.pop_lsb(ref b);
#endif
Debug.Assert(pos.pawn_is_passed(Us, s));
var r = ((s >> 3) ^ (Us * 7)) - RankC.RANK_2;
var rr = r * (r - 1);
// Base bonus based on rank
var mbonus = (20 * rr);
var ebonus = (10 * (rr + r + 1));
if (rr != 0)
{
var blockSq = s + (Us == ColorC.WHITE ? SquareC.DELTA_N : SquareC.DELTA_S);
// Adjust bonus based on kings proximity
ebonus += (Utils.SquareDistance[pos.pieceList[Them][PieceTypeC.KING][0]][blockSq] * 5 * rr);
ebonus -= (Utils.SquareDistance[pos.pieceList[Us][PieceTypeC.KING][0]][blockSq] * 2 * rr);
// If blockSq is not the queening square then consider also a second push
if ((blockSq >> 3) != (Us == ColorC.WHITE ? RankC.RANK_8 : RankC.RANK_1))
{
ebonus -=
(Utils.SquareDistance[pos.pieceList[Us][PieceTypeC.KING][0]][
blockSq + (Us == ColorC.WHITE ? SquareC.DELTA_N : SquareC.DELTA_S)] * rr);
}
// If the pawn is free to advance, increase bonus
if (pos.board[blockSq] == PieceC.NO_PIECE)
{
squaresToQueen = Utils.ForwardBB[Us][s];
defendedSquares = squaresToQueen & ei.attackedBy[Us][0];
// If there is an enemy rook or queen attacking the pawn from behind,
// add all X-ray attacks by the rook or queen. Otherwise consider only
// the squares in the pawn's path attacked or occupied by the enemy.
if (((Utils.ForwardBB[Them][s]
& ((pos.byTypeBB[PieceTypeC.ROOK] | pos.byTypeBB[PieceTypeC.QUEEN]) & pos.byColorBB[Them]))
!= 0)
&& ((Utils.ForwardBB[Them][s]
& ((pos.byTypeBB[PieceTypeC.ROOK] | pos.byTypeBB[PieceTypeC.QUEEN])
& pos.byColorBB[Them]) & pos.attacks_from_ROOK(s)) != 0))
{
unsafeSquares = squaresToQueen;
}
else
{
unsafeSquares = squaresToQueen & (ei.attackedBy[Them][0] | pos.byColorBB[Them]);
}
// If there aren't enemy attacks or pieces along the path to queen give
// huge bonus. Even bigger if we protect the pawn's path.
if (unsafeSquares == 0)
{
ebonus += (rr * (squaresToQueen == defendedSquares ? 17 : 15));
}
else
{
// OK, there are enemy attacks or pieces (but not pawns). Are those
// squares which are attacked by the enemy also attacked by us ?
// If yes, big bonus (but smaller than when there are no enemy attacks),
// if no, somewhat smaller bonus.
ebonus += (rr * ((unsafeSquares & defendedSquares) == unsafeSquares ? 13 : 8));
}
}
} // rr != 0
// Increase the bonus if the passed pawn is supported by a friendly pawn
// on the same rank and a bit smaller if it's on the previous rank.
supportingPawns = (pos.byTypeBB[PieceTypeC.PAWN] & pos.byColorBB[Us]) & Utils.AdjacentFilesBB[s & 7];
if ((supportingPawns & Utils.RankBB[s >> 3]) != 0)
{
ebonus += (r * 20);
}
else if ((supportingPawns
& Utils.RankBB[(s - (Us == ColorC.WHITE ? SquareC.DELTA_N : SquareC.DELTA_S)) >> 3]) != 0)
{
ebonus += (r * 12);
//.........这里部分代码省略.........
示例2: Endgame_KRPPKRP
/// K, rook and two pawns vs K, rook and one pawn. There is only a single
/// pattern: If the stronger side has no passed pawns and the defending king
/// is actively placed, the position is drawish.
internal static ScaleFactor Endgame_KRPPKRP(Color strongerSide, Position pos)
{
Color weakerSide = strongerSide ^ 1;
Debug.Assert(pos.non_pawn_material(strongerSide) == Constants.RookValueMidgame);
Debug.Assert(pos.piece_count(strongerSide, PieceTypeC.PAWN) == 2);
Debug.Assert(pos.non_pawn_material(weakerSide) == Constants.RookValueMidgame);
Debug.Assert(pos.piece_count(weakerSide, PieceTypeC.PAWN) == 1);
Square wpsq1 = pos.pieceList[strongerSide][PieceTypeC.PAWN][0];
Square wpsq2 = pos.pieceList[strongerSide][PieceTypeC.PAWN][1];
Square bksq = pos.king_square(weakerSide);
// Does the stronger side have a passed pawn?
if (pos.pawn_is_passed(strongerSide, wpsq1)
|| pos.pawn_is_passed(strongerSide, wpsq2))
return ScaleFactorC.SCALE_FACTOR_NONE;
Rank r = Math.Max(Utils.relative_rank_CS(strongerSide, wpsq1), Utils.relative_rank_CS(strongerSide, wpsq2));
if (Utils.file_distance(bksq, wpsq1) <= 1
&& Utils.file_distance(bksq, wpsq2) <= 1
&& Utils.relative_rank_CS(strongerSide, bksq) > r)
{
switch (r)
{
case RankC.RANK_2: return (10);
case RankC.RANK_3: return (10);
case RankC.RANK_4: return (15);
case RankC.RANK_5: return (20);
case RankC.RANK_6: return (40);
default: Debug.Assert(false); break;
}
}
return ScaleFactorC.SCALE_FACTOR_NONE;
}