本文整理汇总了C#中Portfish.Position.castle_impeded方法的典型用法代码示例。如果您正苦于以下问题:C# Position.castle_impeded方法的具体用法?C# Position.castle_impeded怎么用?C# Position.castle_impeded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Portfish.Position
的用法示例。
在下文中一共展示了Position.castle_impeded方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: generate_castle
private static void generate_castle(
int Side,
bool Checks,
Position pos,
MoveStack[] ms,
ref int mpos,
int us)
{
if (pos.castle_impeded(us, Side) || (pos.can_castle_CR(Utils.make_castle_right(us, Side)) == 0))
{
return;
}
// After castling, the rook and king final positions are the same in Chess960
// as they would be in standard chess.
var kfrom = pos.king_square(us);
var rfrom = pos.castle_rook_square(us, Side);
var kto = Utils.relative_square(us, Side == CastlingSideC.KING_SIDE ? SquareC.SQ_G1 : SquareC.SQ_C1);
var enemies = pos.pieces_C(us ^ 1);
Debug.Assert(!pos.in_check());
int K = pos.chess960 ? kto > kfrom ? -1 : 1 : Side == CastlingSideC.KING_SIDE ? -1 : 1;
for (Square s = kto; s != kfrom; s += (Square)K)
{
if ((pos.attackers_to(s) & enemies) != 0)
{
return;
}
}
// Because we generate only legal castling moves we need to verify that
// when moving the castling rook we do not discover some hidden checker.
// For instance an enemy queen in SQ_A1 when castling rook is in SQ_B1.
if (pos.chess960 && ((pos.attackers_to(kto, Utils.xor_bit(pos.occupied_squares, rfrom)) & enemies) != 0))
{
return;
}
var m = Utils.make(kfrom, rfrom, MoveTypeC.CASTLING);
if (Checks)
{
var ci = CheckInfoBroker.GetObject();
ci.CreateCheckInfo(pos);
var givesCheck = pos.move_gives_check(m, ci);
CheckInfoBroker.Free();
if (!givesCheck)
{
return;
}
}
ms[mpos++].move = m;
}
示例2: generate_castle
private static void generate_castle(CastlingSide Side, bool OnlyChecks, Position pos, MoveStack[] ms, ref int mpos, Color us)
{
if (pos.castle_impeded(us, Side) || (pos.can_castle_CR(Utils.make_castle_right(us, Side))==0) )
return;
// After castling, the rook and king final positions are the same in Chess960
// as they would be in standard chess.
Square kfrom = pos.king_square(us);
Square rfrom = pos.castle_rook_square(us, Side);
Square kto = Utils.relative_square(us, Side == CastlingSideC.KING_SIDE ? SquareC.SQ_G1 : SquareC.SQ_C1);
Bitboard enemies = pos.pieces_C(us ^ 1);
Debug.Assert(!pos.in_check());
for (Square s = Math.Min(kfrom, kto), e = Math.Max(kfrom, kto); s <= e; s++)
if (s != kfrom // We are not in check
&& ((pos.attackers_to(s) & enemies) != 0))
return;
// Because we generate only legal castling moves we need to verify that
// when moving the castling rook we do not discover some hidden checker.
// For instance an enemy queen in SQ_A1 when castling rook is in SQ_B1.
if (pos.chess960
&& ((pos.attackers_to(kto, Utils.xor_bit(pos.occupied_squares, rfrom)) & enemies) != 0))
return;
Move m = Utils.make_castle(kfrom, rfrom);
if (OnlyChecks)
{
CheckInfo ci = CheckInfoBroker.GetObject();
ci.CreateCheckInfo(pos);
bool givesCheck = pos.move_gives_check(m, ci);
CheckInfoBroker.Free();
if (!givesCheck) return;
}
ms[mpos++].move = m;
}