Ejemplo n.º 1
0
        public override bool[,] PossibleMoves()
        {
            bool[,] mat = new bool[Board.Rows, Board.Columns];

            Position position = new Position(0, 0);

            // NO
            position.SetValues(Position.Row - 1, Position.Column - 1);
            while (Board.ValidPosition(position) && CanMove(position))
            {
                mat[position.Row, position.Column] = true;
                if (Board.Piece(position) != null && Board.Piece(position).Color != Color)
                {
                    break;
                }
                position.Row--;
                position.Column--;
            }

            // NE
            position.SetValues(Position.Row - 1, Position.Column + 1);
            while (Board.ValidPosition(position) && CanMove(position))
            {
                mat[position.Row, position.Column] = true;
                if (Board.Piece(position) != null && Board.Piece(position).Color != Color)
                {
                    break;
                }
                position.Row--;
                position.Column++;
            }

            // SE
            position.SetValues(Position.Row + 1, Position.Column + 1);
            while (Board.ValidPosition(position) && CanMove(position))
            {
                mat[position.Row, position.Column] = true;
                if (Board.Piece(position) != null && Board.Piece(position).Color != Color)
                {
                    break;
                }
                position.Row++;
                position.Column++;
            }

            // SO
            position.SetValues(Position.Row + 1, Position.Column - 1);
            while (Board.ValidPosition(position) && CanMove(position))
            {
                mat[position.Row, position.Column] = true;
                if (Board.Piece(position) != null && Board.Piece(position).Color != Color)
                {
                    break;
                }
                position.Row++;
                position.Column--;
            }

            return(mat);
        }
Ejemplo n.º 2
0
        public override bool[,] PossiblesMovements()
        {
            bool[,] mat = new bool[Bat.Line, Bat.Collum];

            Position position = new Position(0, 0);

            //Above
            position.SetValues(position.Line - 1, position.Collum);
            while (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
                if (Bat.piece(position) != null && Bat.piece(position).color != color)
                {
                    break;
                }
                position.Line = position.Line - 1;
            }

            //Below
            position.SetValues(position.Line + 1, position.Collum);
            while (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
                if (Bat.piece(position) != null && Bat.piece(position).color != color)
                {
                    break;
                }
                position.Line = position.Line + 1;
            }

            //Right
            position.SetValues(position.Line, position.Collum + 1);
            while (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
                if (Bat.piece(position) != null && Bat.piece(position).color != color)
                {
                    break;
                }
                position.Collum = position.Collum + 1;
            }

            //Left
            position.SetValues(position.Line, position.Collum - 1);
            while (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
                if (Bat.piece(position) != null && Bat.piece(position).color != color)
                {
                    break;
                }
                position.Collum = position.Collum - 1;
            }

            return(mat);
        }
Ejemplo n.º 3
0
        public override bool[,] PossibleMoves()
        {
            bool[,] matrix = new bool[Board.Rows, Board.Columns];
            Position pos = new Position(0, 0);

            //Up position (N)
            pos.SetValues(Position.Row - 1, Position.Column);
            while (Board.ValidPosition(pos) && CanMove(pos))
            {
                matrix[pos.Row, pos.Column] = true;
                if (Board.Piece(pos) != null && Board.Piece(pos).Color != Color)
                {
                    break;
                }
                pos.Row--;
            }

            //Down position (S)
            pos.SetValues(Position.Row + 1, Position.Column);
            while (Board.ValidPosition(pos) && CanMove(pos))
            {
                matrix[pos.Row, pos.Column] = true;
                if (Board.Piece(pos) != null && Board.Piece(pos).Color != Color)
                {
                    break;
                }
                pos.Row++;
            }

            //Right position (E)
            pos.SetValues(Position.Row, Position.Column + 1);
            while (Board.ValidPosition(pos) && CanMove(pos))
            {
                matrix[pos.Row, pos.Column] = true;
                if (Board.Piece(pos) != null && Board.Piece(pos).Color != Color)
                {
                    break;
                }
                pos.Column++;
            }

            //Left position
            pos.SetValues(Position.Row, Position.Column - 1);
            while (Board.ValidPosition(pos) && CanMove(pos))
            {
                matrix[pos.Row, pos.Column] = true;
                if (Board.Piece(pos) != null && Board.Piece(pos).Color != Color)
                {
                    break;
                }
                pos.Column--;
            }

            return(matrix);
        }
Ejemplo n.º 4
0
        public override bool[,] PosibleMoves()
        {
            bool[,] mat = new bool[board.Rows, board.Columns];
            Position pos = new Position(0, 0);

            //acima
            pos.SetValues(pos.row - 1, pos.column);
            while (board.PositionIsValid(pos) && CanMove(pos))
            {
                mat[pos.row, pos.column] = true;
                if (board.piece(pos) != null && board.piece(pos).color != color)
                {
                    break;
                }
                pos.row = pos.row - 1;
            }
            //direita
            pos.SetValues(pos.row, pos.column + 1);
            while (board.PositionIsValid(pos) && CanMove(pos))
            {
                mat[pos.row, pos.column] = true;
                if (board.piece(pos) != null && board.piece(pos).color != color)
                {
                    break;
                }
                pos.row = pos.column + 1;
            }
            //abaixo
            pos.SetValues(pos.row + 1, pos.column);
            while (board.PositionIsValid(pos) && CanMove(pos))
            {
                mat[pos.row, pos.column] = true;
                if (board.piece(pos) != null && board.piece(pos).color != color)
                {
                    break;
                }
                pos.row = pos.row + 1;
            }
            //esquerda
            pos.SetValues(pos.row, pos.column - 1);
            while (board.PositionIsValid(pos) && CanMove(pos))
            {
                mat[pos.row, pos.column] = true;
                if (board.piece(pos) != null && board.piece(pos).color != color)
                {
                    break;
                }
                pos.row = pos.row - 1;
            }
            return(mat);
        }
Ejemplo n.º 5
0
        public override bool[,] PossiblesMovements()
        {
            bool[,] mat = new bool[Bat.Line, Bat.Collum];

            Position position = new Position(0, 0);

            position.SetValues(position.Line - 1, position.Collum - 2);
            if (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
            }

            position.SetValues(position.Line - 2, position.Collum - 1);
            if (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
            }

            position.SetValues(position.Line - 2, position.Collum + 1);
            if (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
            }

            position.SetValues(position.Line - 1, position.Collum + 2);
            if (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
            }

            position.SetValues(position.Line + 1, position.Collum + 2);
            if (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
            }

            position.SetValues(position.Line + 2, position.Collum + 1);
            if (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
            }

            position.SetValues(position.Line + 2, position.Collum - 1);
            if (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
            }

            position.SetValues(position.Line + 1, position.Collum - 2);
            if (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
            }

            return(mat);
        }
Ejemplo n.º 6
0
        public override bool[,] PossibleMoves()
        {
            bool[,] mat = new bool[Board.Rows, Board.Columns];

            Position position = new Position(0, 0);

            position.SetValues(Position.Row - 1, Position.Column + 2);
            if (Board.ValidPosition(position) && CanMove(position))
            {
                mat[position.Row, position.Column] = true;
            }

            position.SetValues(Position.Row - 1, Position.Column - 2);
            if (Board.ValidPosition(position) && CanMove(position))
            {
                mat[position.Row, position.Column] = true;
            }

            position.SetValues(Position.Row - 2, Position.Column + 1);
            if (Board.ValidPosition(position) && CanMove(position))
            {
                mat[position.Row, position.Column] = true;
            }

            position.SetValues(Position.Row - 2, Position.Column - 1);
            if (Board.ValidPosition(position) && CanMove(position))
            {
                mat[position.Row, position.Column] = true;
            }

            position.SetValues(Position.Row + 1, Position.Column + 2);
            if (Board.ValidPosition(position) && CanMove(position))
            {
                mat[position.Row, position.Column] = true;
            }

            position.SetValues(Position.Row + 1, Position.Column - 2);
            if (Board.ValidPosition(position) && CanMove(position))
            {
                mat[position.Row, position.Column] = true;
            }

            position.SetValues(Position.Row + 2, Position.Column + 1);
            if (Board.ValidPosition(position) && CanMove(position))
            {
                mat[position.Row, position.Column] = true;
            }

            position.SetValues(Position.Row + 2, Position.Column - 1);
            if (Board.ValidPosition(position) && CanMove(position))
            {
                mat[position.Row, position.Column] = true;
            }

            return(mat);
        }
Ejemplo n.º 7
0
        public override bool[,] PosibleMoves()
        {
            bool[,] mat = new bool[board.Rows, board.Columns];
            Position pos = new Position(0, 0);

            //acima
            pos.SetValues(pos.row - 1, pos.column);
            if (board.PositionIsValid(pos) && CanMove(pos))
            {
                mat[pos.row, pos.column] = true;
            }
            //ne
            pos.SetValues(pos.row - 1, pos.column + 1);
            if (board.PositionIsValid(pos) && CanMove(pos))
            {
                mat[pos.row, pos.column] = true;
            }
            //direita
            pos.SetValues(pos.row, pos.column + 1);
            if (board.PositionIsValid(pos) && CanMove(pos))
            {
                mat[pos.row, pos.column] = true;
            }
            //se
            pos.SetValues(pos.row + 1, pos.column + 1);
            if (board.PositionIsValid(pos) && CanMove(pos))
            {
                mat[pos.row, pos.column] = true;
            }
            //abaixo
            pos.SetValues(pos.row - 1, pos.column - 1);
            if (board.PositionIsValid(pos) && CanMove(pos))
            {
                mat[pos.row, pos.column] = true;
            }
            //so
            pos.SetValues(pos.row + 1, pos.column - 1);
            if (board.PositionIsValid(pos) && CanMove(pos))
            {
                mat[pos.row, pos.column] = true;
            }
            //esquerda
            pos.SetValues(pos.row, pos.column - 1);
            if (board.PositionIsValid(pos) && CanMove(pos))
            {
                mat[pos.row, pos.column] = true;
            }
            //no
            pos.SetValues(pos.row + 1, pos.column - 1);
            if (board.PositionIsValid(pos) && CanMove(pos))
            {
                mat[pos.row, pos.column] = true;
            }
            return(mat);
        }
Ejemplo n.º 8
0
        public override bool[,] PossiblesMovements()
        {
            bool[,] mat = new bool[Bat.Line, Bat.Collum];

            Position position = new Position(0, 0);

            if (color == Color.White)
            {
                position.SetValues(position.Line - 1, position.Collum);
                if (Bat.ValidPosition(position) && Free(position))
                {
                    mat[position.Line, position.Collum] = true;
                }

                position.SetValues(position.Line - 2, position.Collum - 1);
                Position p2 = new Position(position.Line - 1, position.Collum);
                if (Bat.ValidPosition(p2) && Free(p2) && Bat.ValidPosition(position) && Movement == 0)
                {
                }

                position.SetValues(position.Line - 1, position.Collum - 1);
                if (Bat.ValidPosition(position) && EnemySpotted(position))
                {
                    mat[position.Line, position.Collum] = true;
                }

                position.SetValues(position.Line - 1, position.Collum + 1);
                if (Bat.ValidPosition(position) && EnemySpotted(position))
                {
                    mat[position.Line, position.Collum] = true;
                }

                //Especial Play En Passant
                if (position.Line == 3)
                {
                    Position Left = new Position(position.Line, position.Collum - 1);
                    if (Bat.ValidPosition(Left) && EnemySpotted(Left) && Bat.piece(Left) == chessParty.VulnerableEnPassant)
                    {
                        mat[Left.Line - 1, Left.Collum] = true;
                    }

                    Position Right = new Position(position.Line, position.Collum + 1);
                    if (Bat.ValidPosition(Right) && EnemySpotted(Right) && Bat.piece(Right) == chessParty.VulnerableEnPassant)
                    {
                        mat[Right.Line - 1, Right.Collum] = true;
                    }
                }

                else
                {
                    position.SetValues(position.Line + 1, position.Collum);
                    if (Bat.ValidPosition(position) && Free(position))
                    {
                        mat[position.Line, position.Collum] = true;
                    }

                    position.SetValues(position.Line + 2, position.Collum);
                    Position pp2 = new Position(position.Line + 1, position.Collum);
                    if (Bat.ValidPosition(position) && Free(position))
                    {
                        mat[position.Line, position.Collum] = true;
                    }

                    position.SetValues(position.Line + 1, position.Collum);
                    if (Bat.ValidPosition(position) && Free(position))
                    {
                        mat[position.Line, position.Collum] = true;
                    }

                    position.SetValues(position.Line + 1, position.Collum);
                    if (Bat.ValidPosition(position) && Free(position))
                    {
                        mat[position.Line, position.Collum] = true;
                    }
                }

                //Especial Play En Passant
                if (position.Line == 4)
                {
                    Position Left = new Position(position.Line, position.Collum - 1);
                    if (Bat.ValidPosition(Left) && EnemySpotted(Left) && Bat.piece(Left) == chessParty.VulnerableEnPassant)
                    {
                        mat[Left.Line + 1, Left.Collum] = true;
                    }

                    Position Right = new Position(position.Line, position.Collum + 1);
                    if (Bat.ValidPosition(Right) && EnemySpotted(Right) && Bat.piece(Right) == chessParty.VulnerableEnPassant)
                    {
                        mat[Right.Line + 1, Left.Collum] = true;
                    }
                }
            }

            return(mat);
        }
Ejemplo n.º 9
0
        public override bool[,] PossibleMoves()
        {
            bool[,] matrix = new bool[chessboard.lines, chessboard.columns];

            Position matrixPosition = new Position(0, 0);

            matrixPosition.SetValues(position.line - 1, position.column - 2);

            if (chessboard.PositionValidated(matrixPosition) && CanMove(matrixPosition))
            {
                matrix[matrixPosition.line, matrixPosition.column] = true;
            }

            matrixPosition.SetValues(position.line - 2, position.column - 1);

            if (chessboard.PositionValidated(matrixPosition) && CanMove(matrixPosition))
            {
                matrix[matrixPosition.line, matrixPosition.column] = true;
            }

            matrixPosition.SetValues(position.line - 2, position.column + 1);

            if (chessboard.PositionValidated(matrixPosition) && CanMove(matrixPosition))
            {
                matrix[matrixPosition.line, matrixPosition.column] = true;
            }

            matrixPosition.SetValues(position.line - 1, position.column + 2);

            if (chessboard.PositionValidated(matrixPosition) && CanMove(matrixPosition))
            {
                matrix[matrixPosition.line, matrixPosition.column] = true;
            }

            matrixPosition.SetValues(position.line + 1, position.column + 2);

            if (chessboard.PositionValidated(matrixPosition) && CanMove(matrixPosition))
            {
                matrix[matrixPosition.line, matrixPosition.column] = true;
            }

            matrixPosition.SetValues(position.line + 2, position.column + 1);

            if (chessboard.PositionValidated(matrixPosition) && CanMove(matrixPosition))
            {
                matrix[matrixPosition.line, matrixPosition.column] = true;
            }

            matrixPosition.SetValues(position.line + 2, position.column - 1);

            if (chessboard.PositionValidated(matrixPosition) && CanMove(matrixPosition))
            {
                matrix[matrixPosition.line, matrixPosition.column] = true;
            }

            matrixPosition.SetValues(position.line + 1, position.column - 2);

            if (chessboard.PositionValidated(matrixPosition) && CanMove(matrixPosition))
            {
                matrix[matrixPosition.line, matrixPosition.column] = true;
            }

            return(matrix);
        }
Ejemplo n.º 10
0
        public override bool[,] PossibleMoves()
        {
            bool[,] matrix = new bool[Board.Rows, Board.Columns];
            Position pos = new Position(0, 0);

            if (Color == Color.White)
            {
                pos.SetValues(Position.Row - 1, Position.Column);
                if (Board.ValidPosition(pos) && Free(pos))
                {
                    matrix[pos.Row, pos.Column] = true;
                }
                pos.SetValues(Position.Row - 2, Position.Column);
                Position pos2 = new Position(Position.Row - 1, Position.Column);
                if (Board.ValidPosition(pos2) && Free(pos2) && Board.ValidPosition(pos) && Free(pos) && TotalMoves == 0)
                {
                    matrix[pos.Row, pos.Column] = true;
                }
                pos.SetValues(Position.Row - 1, Position.Column - 1);
                if (Board.ValidPosition(pos) && isThereEnemy(pos))
                {
                    matrix[pos.Row, pos.Column] = true;
                }
                pos.SetValues(Position.Row - 1, Position.Column + 1);
                if (Board.ValidPosition(pos) && isThereEnemy(pos))
                {
                    matrix[pos.Row, pos.Column] = true;
                }
                //En Passant
                if (Position.Row == 3)
                {
                    Position left = new Position(Position.Row, Position.Column - 1);
                    if (Board.ValidPosition(left) && isThereEnemy(left) && Board.Piece(left) == match.vulnerableEnPassant)
                    {
                        matrix[left.Row - 1, left.Column] = true;
                    }
                    Position right = new Position(Position.Row, Position.Column + 1);
                    if (Board.ValidPosition(right) && isThereEnemy(right) && Board.Piece(right) == match.vulnerableEnPassant)
                    {
                        matrix[right.Row - 1, right.Column] = true;
                    }
                }
            }
            else
            {
                pos.SetValues(Position.Row + 1, Position.Column);
                if (Board.ValidPosition(pos) && Free(pos))
                {
                    matrix[pos.Row, pos.Column] = true;
                }
                pos.SetValues(Position.Row + 2, Position.Column);
                Position pos2 = new Position(Position.Row + 1, Position.Column);
                if (Board.ValidPosition(pos2) && Free(pos2) && Board.ValidPosition(pos) && Free(pos) && TotalMoves == 0)
                {
                    matrix[pos.Row, pos.Column] = true;
                }
                pos.SetValues(Position.Row + 1, Position.Column - 1);
                if (Board.ValidPosition(pos) && isThereEnemy(pos))
                {
                    matrix[pos.Row, pos.Column] = true;
                }
                pos.SetValues(Position.Row + 1, Position.Column + 1);
                if (Board.ValidPosition(pos) && isThereEnemy(pos))
                {
                    matrix[pos.Row, pos.Column] = true;
                }
                //En Passant
                if (Position.Row == 4)
                {
                    Position left = new Position(Position.Row, Position.Column - 1);
                    if (Board.ValidPosition(left) && isThereEnemy(left) && Board.Piece(left) == match.vulnerableEnPassant)
                    {
                        matrix[left.Row + 1, left.Column] = true;
                    }
                    Position right = new Position(Position.Row, Position.Column + 1);
                    if (Board.ValidPosition(right) && isThereEnemy(right) && Board.Piece(right) == match.vulnerableEnPassant)
                    {
                        matrix[right.Row + 1, right.Column] = true;
                    }
                }
            }

            return(matrix);
        }
Ejemplo n.º 11
0
        public override bool[,] PossibleMoves()
        {
            bool[,] mat = new bool[Board.Rows, Board.Columns];

            Position position = new Position(0, 0);

            // Above
            position.SetValues(Position.Row - 1, Position.Column);
            if (Board.ValidPosition(position) && CanMove(position))
            {
                mat[position.Row, position.Column] = true;
            }

            // NE
            position.SetValues(Position.Row - 1, Position.Column + 1);
            if (Board.ValidPosition(position) && CanMove(position))
            {
                mat[position.Row, position.Column] = true;
            }

            // Right
            position.SetValues(Position.Row, Position.Column + 1);
            if (Board.ValidPosition(position) && CanMove(position))
            {
                mat[position.Row, position.Column] = true;
            }

            // SE
            position.SetValues(Position.Row + 1, Position.Column + 1);
            if (Board.ValidPosition(position) && CanMove(position))
            {
                mat[position.Row, position.Column] = true;
            }

            // Below
            position.SetValues(Position.Row + 1, Position.Column);
            if (Board.ValidPosition(position) && CanMove(position))
            {
                mat[position.Row, position.Column] = true;
            }

            // SO
            position.SetValues(Position.Row + 1, Position.Column - 1);
            if (Board.ValidPosition(position) && CanMove(position))
            {
                mat[position.Row, position.Column] = true;
            }

            // Left
            position.SetValues(Position.Row, Position.Column - 1);
            if (Board.ValidPosition(position) && CanMove(position))
            {
                mat[position.Row, position.Column] = true;
            }

            // NO
            position.SetValues(Position.Row - 1, Position.Column - 1);
            if (Board.ValidPosition(position) && CanMove(position))
            {
                mat[position.Row, position.Column] = true;
            }

            // #Special move - Castling
            if (MoveCount == 0 && !ChessMatch.Check)
            {
                // #Special move - Castling - Kingside Rook
                Position positionR1 = new Position(Position.Row, Position.Column + 3);
                if (TestRookCastling(positionR1))
                {
                    Position position1 = new Position(Position.Row, Position.Column + 1);
                    Position position2 = new Position(Position.Row, Position.Column + 2);

                    if (Board.Piece(position1) == null && Board.Piece(position2) == null)
                    {
                        mat[Position.Row, Position.Column + 2] = true;
                    }
                }

                // #Special move - Castling - Queenside Rook
                Position positionR2 = new Position(Position.Row, Position.Column - 4);
                if (TestRookCastling(positionR2))
                {
                    Position position1 = new Position(Position.Row, Position.Column - 1);
                    Position position2 = new Position(Position.Row, Position.Column - 2);
                    Position position3 = new Position(Position.Row, Position.Column - 3);

                    if (Board.Piece(position1) == null && Board.Piece(position2) == null && Board.Piece(position3) == null)
                    {
                        mat[Position.Row, Position.Column - 2] = true;
                    }
                }
            }

            return(mat);
        }
Ejemplo n.º 12
0
        public override bool[,] PossibleMoves()
        {
            bool[,] matrix = new bool[Board.Rows, Board.Columns];
            Position pos = new Position(0, 0);

            //Position 1
            pos.SetValues(Position.Row - 1, Position.Column - 2);
            if (Board.ValidPosition(pos) && CanMove(pos))
            {
                matrix[pos.Row, pos.Column] = true;
            }

            //Position 2
            pos.SetValues(Position.Row - 2, Position.Column - 1);
            if (Board.ValidPosition(pos) && CanMove(pos))
            {
                matrix[pos.Row, pos.Column] = true;
            }

            //Position 3
            pos.SetValues(Position.Row - 2, Position.Column + 1);
            if (Board.ValidPosition(pos) && CanMove(pos))
            {
                matrix[pos.Row, pos.Column] = true;
            }

            //Position 4
            pos.SetValues(Position.Row - 1, Position.Column + 2);
            if (Board.ValidPosition(pos) && CanMove(pos))
            {
                matrix[pos.Row, pos.Column] = true;
            }

            //Position 5
            pos.SetValues(Position.Row + 1, Position.Column + 2);
            if (Board.ValidPosition(pos) && CanMove(pos))
            {
                matrix[pos.Row, pos.Column] = true;
            }

            //Position 6
            pos.SetValues(Position.Row + 2, Position.Column + 1);
            if (Board.ValidPosition(pos) && CanMove(pos))
            {
                matrix[pos.Row, pos.Column] = true;
            }

            //Position 7
            pos.SetValues(Position.Row + 2, Position.Column - 1);
            if (Board.ValidPosition(pos) && CanMove(pos))
            {
                matrix[pos.Row, pos.Column] = true;
            }

            //Position 8
            pos.SetValues(Position.Row + 1, Position.Column - 2);
            if (Board.ValidPosition(pos) && CanMove(pos))
            {
                matrix[pos.Row, pos.Column] = true;
            }

            return(matrix);
        }
Ejemplo n.º 13
0
        public override bool[,] PossibleMoves()
        {
            bool[,] mat = new bool[Board.Rows, Board.Columns];

            Position position = new Position(0, 0);

            if (Color == Color.White)
            {
                position.SetValues(Position.Row - 1, Position.Column);
                if (Board.ValidPosition(position) && EmptyPosition(position))
                {
                    mat[position.Row, position.Column] = true;
                }

                position.SetValues(Position.Row - 2, Position.Column);
                if (Board.ValidPosition(position) && EmptyPosition(position) && MoveCount == 0)
                {
                    mat[position.Row, position.Column] = true;
                }

                position.SetValues(Position.Row - 1, Position.Column - 1);
                if (Board.ValidPosition(position) && ThereIsAnEnemy(position))
                {
                    mat[position.Row, position.Column] = true;
                }

                position.SetValues(Position.Row - 1, Position.Column + 1);
                if (Board.ValidPosition(position) && ThereIsAnEnemy(position))
                {
                    mat[position.Row, position.Column] = true;
                }

                // #Special move - En Passant

                if (Position.Row == 3)
                {
                    Position left = new Position(Position.Row, Position.Column - 1);
                    if (Board.ValidPosition(left) && ThereIsAnEnemy(left) && Board.Piece(left) == ChessMatch.EnPassantVulnerable)
                    {
                        mat[left.Row - 1, left.Column] = true;
                    }
                    Position right = new Position(Position.Row, Position.Column + 1);
                    if (Board.ValidPosition(right) && ThereIsAnEnemy(right) && Board.Piece(right) == ChessMatch.EnPassantVulnerable)
                    {
                        mat[right.Row - 1, right.Column] = true;
                    }
                }
            }
            else
            {
                position.SetValues(Position.Row + 1, Position.Column);
                if (Board.ValidPosition(position) && EmptyPosition(position))
                {
                    mat[position.Row, position.Column] = true;
                }

                position.SetValues(Position.Row + 2, Position.Column);
                if (Board.ValidPosition(position) && EmptyPosition(position) && MoveCount == 0)
                {
                    mat[position.Row, position.Column] = true;
                }

                position.SetValues(Position.Row + 1, Position.Column - 1);
                if (Board.ValidPosition(position) && ThereIsAnEnemy(position))
                {
                    mat[position.Row, position.Column] = true;
                }

                position.SetValues(Position.Row + 1, Position.Column + 1);
                if (Board.ValidPosition(position) && ThereIsAnEnemy(position))
                {
                    mat[position.Row, position.Column] = true;
                }

                // #Special move - En Passant

                if (Position.Row == 4)
                {
                    Position left = new Position(Position.Row, Position.Column - 1);
                    if (Board.ValidPosition(left) && ThereIsAnEnemy(left) && Board.Piece(left) == ChessMatch.EnPassantVulnerable)
                    {
                        mat[left.Row + 1, left.Column] = true;
                    }
                    Position right = new Position(Position.Row, Position.Column + 1);
                    if (Board.ValidPosition(right) && ThereIsAnEnemy(right) && Board.Piece(right) == ChessMatch.EnPassantVulnerable)
                    {
                        mat[right.Row + 1, right.Column] = true;
                    }
                }
            }

            return(mat);
        }
Ejemplo n.º 14
0
        public override bool[,] PossiblesMovements()
        {
            bool[,] mat = new bool[Bat.Line, Bat.Collum];

            Position position = new Position(0, 0);

            //Above
            position.SetValues(position.Line - 1, position.Collum);
            if (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
            }

            //NE
            position.SetValues(position.Line - 1, position.Collum + 1);
            if (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
            }

            //Right
            position.SetValues(position.Line, position.Collum + 1);
            if (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
            }

            //SE
            position.SetValues(position.Line + 1, position.Collum + 1);
            if (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
            }

            //Below
            position.SetValues(position.Line + 1, position.Collum);
            if (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
            }

            //SO
            position.SetValues(position.Line + 1, position.Collum - 1);
            if (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
            }

            //Left
            position.SetValues(position.Line, position.Collum - 1);
            if (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
            }

            //NO
            position.SetValues(position.Line - 1, position.Collum - 1);
            if (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
            }

            //Especial Play Roque
            if (Movement == 0 && !chessParty.Check)
            {
                //Especial Play Little Roque
                Position position1 = new Position(position.Line, position.Collum + 3);
                if (TowertoRoquetest(position1))
                {
                    Position p1 = new Position(position.Line, position.Collum + 1);
                    Position p2 = new Position(position.Line, position.Collum + 2);
                    if (Bat.piece(p1) == null && Bat.piece(p2) == null)
                    {
                        mat[position.Line, position.Collum + 2] = true;
                    }
                }

                //Especial Play Big Roque
                Position position2 = new Position(position.Line, position.Collum - 4);
                if (TowertoRoquetest(position2))
                {
                    Position p1 = new Position(position.Line, position.Collum - 1);
                    Position p2 = new Position(position.Line, position.Collum - 2);
                    Position p3 = new Position(position.Line, position.Collum - 3);
                    if (Bat.piece(p1) == null && Bat.piece(p2) == null && Bat.piece(p3) == null)
                    {
                        mat[position.Line, position.Collum - 2] = true;
                    }
                }
            }

            return(mat);
        }
Ejemplo n.º 15
0
        public override bool[,] PossibleMoves()
        {
            bool[,] matrix = new bool[Board.Rows, Board.Columns];
            Position pos = new Position(0, 0);

            //Up position (N)
            pos.SetValues(Position.Row - 1, Position.Column);
            if (Board.ValidPosition(pos) && CanMove(pos))
            {
                matrix[pos.Row, pos.Column] = true;
            }

            //Up-right position (NE)
            pos.SetValues(Position.Row - 1, Position.Column + 1);
            if (Board.ValidPosition(pos) && CanMove(pos))
            {
                matrix[pos.Row, pos.Column] = true;
            }

            //Right position (E)
            pos.SetValues(Position.Row, Position.Column + 1);
            if (Board.ValidPosition(pos) && CanMove(pos))
            {
                matrix[pos.Row, pos.Column] = true;
            }

            //Down-right position (SE)
            pos.SetValues(Position.Row + 1, Position.Column + 1);
            if (Board.ValidPosition(pos) && CanMove(pos))
            {
                matrix[pos.Row, pos.Column] = true;
            }

            //Down position (S)
            pos.SetValues(Position.Row + 1, Position.Column);
            if (Board.ValidPosition(pos) && CanMove(pos))
            {
                matrix[pos.Row, pos.Column] = true;
            }

            //Down-left position (SW)
            pos.SetValues(Position.Row + 1, Position.Column - 1);
            if (Board.ValidPosition(pos) && CanMove(pos))
            {
                matrix[pos.Row, pos.Column] = true;
            }

            //Left position
            pos.SetValues(Position.Row, Position.Column - 1);
            if (Board.ValidPosition(pos) && CanMove(pos))
            {
                matrix[pos.Row, pos.Column] = true;
            }

            //Up-left position (NW)
            pos.SetValues(Position.Row - 1, Position.Column - 1);
            if (Board.ValidPosition(pos) && CanMove(pos))
            {
                matrix[pos.Row, pos.Column] = true;
            }

            if (TotalMoves == 0 && !match.Check)
            {
                //Little Castle
                Position posRook1 = new Position(Position.Row, Position.Column + 3);
                if (CastleRook(posRook1))
                {
                    Position p1 = new Position(Position.Row, Position.Column + 1);
                    Position p2 = new Position(Position.Row, Position.Column + 2);
                    if (Board.Piece(p1) == null && Board.Piece(p2) == null)
                    {
                        matrix[Position.Row, Position.Column + 2] = true;
                    }
                }
                //Big Castle
                Position posRook2 = new Position(Position.Row, Position.Column - 4);
                if (CastleRook(posRook2))
                {
                    Position p1 = new Position(Position.Row, Position.Column - 1);
                    Position p2 = new Position(Position.Row, Position.Column - 2);
                    Position p3 = new Position(Position.Row, Position.Column - 3);
                    if (Board.Piece(p1) == null && Board.Piece(p2) == null && Board.Piece(p3) == null)
                    {
                        matrix[Position.Row, Position.Column - 2] = true;
                    }
                }
            }

            return(matrix);
        }