Beispiel #1
0
        static List <MGMove> MovesByPieceTypeThatTakeOnSquare(MGPositionConstants.MCChessPositionPieceEnum piece, byte toSquare, MGMoveList moves)
        {
            List <MGMove> matchingMoves = new List <MGMove>(0);

            foreach (MGMove move in moves.MovesArray)
            {
                if (move.Piece == piece && move.ToSquareIndex == toSquare)
                {
                    matchingMoves.Add(move);
                }
            }
            return(matchingMoves);
        }
Beispiel #2
0
        /// <summary>
        /// Constructor (with piece specified).
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="piece"></param>
        /// <param name="flags">optional flags other than piece</param>
        public MGMove(byte from, byte to, MGPositionConstants.MCChessPositionPieceEnum piece, MGChessMoveFlags flags)
        {
            Debug.Assert(from < 64);
            Debug.Assert(to < 64);
            Debug.Assert(from != to);
            Debug.Assert((flags & MGChessMoveFlags.Piece) == 0); // not expected to have already set

            FromSquareIndex = from;
            ToSquareIndex   = to;
            Flags           = flags;

            // Obviate requirement of definite assignment to all fields
            Unsafe.SkipInit <short>(out FromAndToCombined);

            Piece = piece;
        }