예제 #1
0
        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.");
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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);
            }
        }
예제 #6
0
        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);
            }
        }
예제 #7
0
        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);
            }
        }
예제 #8
0
        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);
            }
        }
예제 #9
0
 public static bool HasFlagFast(this ECastleling value, ECastleling flag) => (value & flag) != 0;
예제 #10
0
 public void Hash(ECastleling castleling, ERank rank) => Value ^= Zobrist.GetZobristCastleling((int)rank);