本文整理汇总了C#中Position.attacks_from_PS方法的典型用法代码示例。如果您正苦于以下问题:C# Position.attacks_from_PS方法的具体用法?C# Position.attacks_from_PS怎么用?C# Position.attacks_from_PS使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Position
的用法示例。
在下文中一共展示了Position.attacks_from_PS方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckInfo
internal CheckInfo(Position pos)
{
var them = Color.opposite(pos.side_to_move());
ksq = pos.square(PieceType.KING, them);
pinned = pos.pinned_pieces(pos.side_to_move());
dcCandidates = pos.discovered_check_candidates();
checkSquares[PieceType.PAWN] = pos.attacks_from_PS(PieceType.PAWN, ksq, them);
checkSquares[PieceType.KNIGHT] = pos.attacks_from_PtS(PieceType.KNIGHT, ksq);
checkSquares[PieceType.BISHOP] = pos.attacks_from_PtS(PieceType.BISHOP, ksq);
checkSquares[PieceType.ROOK] = pos.attacks_from_PtS(PieceType.ROOK, ksq);
checkSquares[PieceType.QUEEN] = checkSquares[PieceType.BISHOP] | checkSquares[PieceType.ROOK];
checkSquares[PieceType.KING] = Bitboard.Create(0);
}
示例2: GetScaleFactor
internal override ScaleFactor GetScaleFactor(Position pos)
{
Debug.Assert(verify_material(pos, strongSide, Value.QueenValueMg, 0));
Debug.Assert(pos.count(PieceType.ROOK, weakSide) == 1);
Debug.Assert(pos.count(PieceType.PAWN, weakSide) >= 1);
var kingSq = pos.square(PieceType.KING, weakSide);
var rsq = pos.square(PieceType.ROOK, weakSide);
if (Rank.relative_rank_CtSt(weakSide, kingSq) <= Rank.RANK_2
&& Rank.relative_rank_CtSt(weakSide, pos.square(PieceType.KING, strongSide)) >= Rank.RANK_4
&& Rank.relative_rank_CtSt(weakSide, rsq) == Rank.RANK_3
&& (pos.pieces_CtPt(weakSide, PieceType.PAWN) & pos.attacks_from_PtS(PieceType.KING, kingSq)
& pos.attacks_from_PS(PieceType.PAWN, rsq, strongSide))!=0)
{
return ScaleFactor.SCALE_FACTOR_DRAW;
}
return ScaleFactor.SCALE_FACTOR_NONE;
}
示例3: generate_pawn_moves
internal static ExtMoveArrayWrapper generate_pawn_moves(
ColorT Us,
GenType Type,
Position pos,
ExtMoveArrayWrapper moveList,
BitboardT target,
CheckInfo ci)
{
// Compute our parametrized parameters at compile time, named according to
// the point of view of white side.
var Them = (Us == Color.WHITE ? Color.BLACK : Color.WHITE);
var TRank8BB = (Us == Color.WHITE ? Bitboard.Rank8BB : Bitboard.Rank1BB);
var TRank7BB = (Us == Color.WHITE ? Bitboard.Rank7BB : Bitboard.Rank2BB);
var TRank3BB = (Us == Color.WHITE ? Bitboard.Rank3BB : Bitboard.Rank6BB);
var Up = (Us == Color.WHITE ? Square.DELTA_N : Square.DELTA_S);
var Right = (Us == Color.WHITE ? Square.DELTA_NE : Square.DELTA_SW);
var Left = (Us == Color.WHITE ? Square.DELTA_NW : Square.DELTA_SE);
var emptySquares = Bitboard.Create(0);
var pawnsOn7 = pos.pieces_CtPt(Us, PieceType.PAWN) & TRank7BB;
var pawnsNotOn7 = pos.pieces_CtPt(Us, PieceType.PAWN) & ~TRank7BB;
var enemies = (Type == GenType.EVASIONS
? pos.pieces_Ct(Them) & target
: Type == GenType.CAPTURES ? target : pos.pieces_Ct(Them));
// Single and double pawn pushes, no promotions
if (Type != GenType.CAPTURES)
{
emptySquares = (Type == GenType.QUIETS || Type == GenType.QUIET_CHECKS ? target : ~pos.pieces());
var b1 = Bitboard.shift_bb(Up, pawnsNotOn7) & emptySquares;
var b2 = Bitboard.shift_bb(Up, b1 & TRank3BB) & emptySquares;
if (Type == GenType.EVASIONS) // Consider only blocking squares
{
b1 &= target;
b2 &= target;
}
if (Type == GenType.QUIET_CHECKS)
{
b1 &= pos.attacks_from_PS(PieceType.PAWN, ci.ksq, Them);
b2 &= pos.attacks_from_PS(PieceType.PAWN, ci.ksq, Them);
// Add pawn pushes which give discovered check. This is possible only
// if the pawn is not on the same file as the enemy king, because we
// don't generate captures. Note that a possible discovery check
// promotion has been already generated amongst the captures.
if ((pawnsNotOn7 & ci.dcCandidates) != 0)
{
var dc1 = Bitboard.shift_bb(Up, pawnsNotOn7 & ci.dcCandidates) & emptySquares
& ~Utils.file_bb_St(ci.ksq);
var dc2 = Bitboard.shift_bb(Up, dc1 & TRank3BB) & emptySquares;
b1 |= dc1;
b2 |= dc2;
}
}
while (b1 != 0)
{
var to = Utils.pop_lsb(ref b1);
(moveList).Add(Move.make_move(to - Up, to));
}
while (b2 != 0)
{
var to = Utils.pop_lsb(ref b2);
(moveList).Add(Move.make_move(to - Up - Up, to));
}
}
// Promotions and underpromotions
if (pawnsOn7 != 0 && (Type != GenType.EVASIONS || ((target & TRank8BB) != 0)))
{
if (Type == GenType.CAPTURES)
{
emptySquares = ~pos.pieces();
}
if (Type == GenType.EVASIONS)
{
emptySquares &= target;
}
var b1 = Bitboard.shift_bb(Right, pawnsOn7) & enemies;
var b2 = Bitboard.shift_bb(Left, pawnsOn7) & enemies;
var b3 = Bitboard.shift_bb(Up, pawnsOn7) & emptySquares;
while (b1 != 0)
{
moveList = make_promotions(Type, Right, moveList, Utils.pop_lsb(ref b1), ci);
}
while (b2 != 0)
{
moveList = make_promotions(Type, Left, moveList, Utils.pop_lsb(ref b2), ci);
}
//.........这里部分代码省略.........