Exemplo n.º 1
0
        //	Generate moves for this piece assuming it is of the given
        //	type (which it usually is.)  This function is useful for polymorphic
        //	piece types that can move as other types of pieces.
        public void GenerateMoves(PieceType pieceType, MoveList list, bool capturesOnly)
        {
            //	if the piece type has a custom move generator, run that first.
            //	it will determine if we proceed to standard generation
            if (pieceType.CustomMoveGenerator != null)
            {
                if (!pieceType.CustomMoveGenerator(pieceType, this, list, capturesOnly))
                {
                    //	custom generator returned false, so we don't
                    //	proceed to standard move generation
                    return;
                }
            }

            MoveCapability[] moves;
            int nMoves = pieceType.GetMoveCapabilities(out moves);

            for (int nMove = 0; nMove < nMoves; nMove++)
            {
                if (moves[nMove].ConditionalBySquare == null || moves[nMove].ConditionalBySquare[Player][Square])
                {
                    GenerateMovesForCapability(pieceType.SimpleMoveGeneration, ref moves[nMove], list, capturesOnly);
                }
            }
        }
Exemplo n.º 2
0
        public void AddMovesOf(PieceType other)
        {
            MoveCapability[] otherMoves;
            int nmoves = other.GetMoveCapabilities(out otherMoves);

            for (int x = 0; x < nmoves; x++)
            {
                AddMoveCapability(otherMoves[x]);
            }
        }