private bool CanCastle(ECastleling type) { // ReSharper disable once SwitchStatementMissingSomeCases switch (type) { case ECastleling.Short: case ECastleling.Long: return((CastlelingRights & type.GetCastleAllowedMask(SideToMove)) != 0 && IsCastleAllowed(type.GetKingCastleTo(SideToMove))); default: throw new ArgumentException("Illegal castleling type."); } }
internal static ECastlelingRights GetCastleAllowedMask(this ECastleling castleType, Player side) { switch (castleType) { case ECastleling.Short: return(OoAllowedMask[side.Side]); case ECastleling.Long: return(OooAllowedMask[side.Side]); default: throw new ArgumentOutOfRangeException(nameof(castleType), castleType, null); } }
public static Square GetKingCastleTo(this ECastleling castleType, Player side) { switch (castleType) { case ECastleling.Short: return(OoKingTo[side.Side]); case ECastleling.Long: return(OooKingTo[side.Side]); default: throw new ArgumentOutOfRangeException(nameof(castleType), castleType, null); } }
public Square GetKingCastleFrom(Player side, ECastleling castleType) { switch (castleType) { case ECastleling.Short: return(_castleShortKingFrom[side.Side]); case ECastleling.Long: return(_castleLongKingFrom[side.Side]); default: throw new ArgumentOutOfRangeException(nameof(castleType), castleType, null); } }
internal static int GetCastleAllowedMask(this ECastleling castleType, Player side) { // ReSharper disable once SwitchStatementMissingSomeCases switch (castleType) { case ECastleling.Short: return(OoAllowedMask[side.Side]); case ECastleling.Long: return(OooAllowedMask[side.Side]); default: throw new ArgumentOutOfRangeException(nameof(castleType), castleType, null); } }
public static Square GetKingCastleTo(this ECastleling castleType, Player side) { // ReSharper disable once SwitchStatementMissingSomeCases switch (castleType) { case ECastleling.Short: return(OoKingTo[side.Side]); case ECastleling.Long: return(OooKingTo[side.Side]); default: throw new ArgumentOutOfRangeException(nameof(castleType), castleType, null); } }
public void SetKingCastleFrom(Player side, Square square, ECastleling castleType) { switch (castleType) { case ECastleling.Short: _castleShortKingFrom[side.Side] = square; break; case ECastleling.Long: _castleLongKingFrom[side.Side] = square; break; default: throw new ArgumentOutOfRangeException(nameof(castleType), castleType, null); } }
public static string GetCastlelingString(this ECastleling @this) { switch (@this) { case ECastleling.Short: return("O-O"); case ECastleling.Long: return("O-O-O"); case ECastleling.None: return(string.Empty); case ECastleling.CastleNb: return(string.Empty); default: throw new ArgumentOutOfRangeException(nameof(@this), @this, null); } }
public static bool HasFlagFast(this ECastleling value, ECastleling flag) => (value & flag) != 0;
public void Hash(ECastleling castleling, ERank rank) => Value ^= Zobrist.GetZobristCastleling((int)rank);