private static CollectionView CreateCollectionViewForEnumeration <TEnum>() where TEnum : struct
 {
     return(EnumFactotum
            .GetAllValues <TEnum>()
            .Select(value => DescriptiveItem.Create(value, ((Enum)(object)value).GetTranslation()))
            .ToArray()
            .ToCollectionView());
 }
コード例 #2
0
        private static InternalCastlingInfo2[] InitializeKingCastlingInfos()
        {
            var castlingTypes = EnumFactotum.GetAllValues <CastlingType>();

            var result = new InternalCastlingInfo2[(int)castlingTypes.Max() + 1];

            foreach (var castlingType in castlingTypes)
            {
                var info = ChessHelper.CastlingTypeToInfoMap2[castlingType];

                var index = GetCastlingTypeArrayIndexInternal(castlingType);
                result[index] = new InternalCastlingInfo2(
                    info.KingMove,
                    new Bitboard(info.EmptySquares.Concat(info.PassedSquare.AsArray())));
            }

            return(result);
        }
コード例 #3
0
        private static Bitboard[] InitializeKingAttacksOrMoves()
        {
            var result = new Bitboard[ChessConstants.SquareCount * ChessConstants.SquareCount];

            var directions = EnumFactotum.GetAllValues <ShiftDirection>();

            for (var squareIndex = 0; squareIndex < ChessConstants.SquareCount; squareIndex++)
            {
                var sourceBitboard = Bitboard.FromSquareIndex(squareIndex);

                var movesBitboard = directions
                                    .Select(sourceBitboard.Shift)
                                    .Aggregate(Bitboard.None, (current, bitboard) => current | bitboard);

                result[squareIndex] = movesBitboard;
            }

            return(result);
        }