Exemple #1
0
        public override bool[,] possibleMoves()
        {
            bool[,] mat = new bool[board.Lines, board.Rows];
            Position pos = new Position(0, 0);

            // N
            pos.defineValues(position.line - 1, position.row);
            while (board.validPosition(pos) && canMove(pos))
            {
                mat[pos.line, pos.row] = true;
                if (board.piece(pos) != null && board.piece(pos).color != color)
                {
                    break;
                }
                pos.line -= 1;
            }

            // S
            pos.defineValues(position.line + 1, position.row);
            while (board.validPosition(pos) && canMove(pos))
            {
                mat[pos.line, pos.row] = true;
                if (board.piece(pos) != null && board.piece(pos).color != color)
                {
                    break;
                }
                pos.line += 1;
            }

            // E
            pos.defineValues(position.line, position.row + 1);
            while (board.validPosition(pos) && canMove(pos))
            {
                mat[pos.line, pos.row] = true;
                if (board.piece(pos) != null && board.piece(pos).color != color)
                {
                    break;
                }
                pos.row += 1;
            }

            // W
            pos.defineValues(position.line, position.row - 1);
            while (board.validPosition(pos) && canMove(pos))
            {
                mat[pos.line, pos.row] = true;
                if (board.piece(pos) != null && board.piece(pos).color != color)
                {
                    break;
                }
                pos.row -= 1;
            }

            return(mat);
        }
Exemple #2
0
        public override bool[,] possibleMoves()
        {
            bool[,] mat = new bool[board.Lines, board.Rows];
            Position pos = new Position(0, 0);

            pos.defineValues(position.line - 1, position.row - 2);
            if (board.validPosition(pos) && canMove(pos))
            {
                mat[pos.line, pos.row] = true;
            }
            pos.defineValues(position.line - 2, position.row - 1);
            if (board.validPosition(pos) && canMove(pos))
            {
                mat[pos.line, pos.row] = true;
            }
            pos.defineValues(position.line - 2, position.row + 1);
            if (board.validPosition(pos) && canMove(pos))
            {
                mat[pos.line, pos.row] = true;
            }
            pos.defineValues(position.line - 1, position.row + 2);
            if (board.validPosition(pos) && canMove(pos))
            {
                mat[pos.line, pos.row] = true;
            }
            pos.defineValues(position.line + 1, position.row + 2);
            if (board.validPosition(pos) && canMove(pos))
            {
                mat[pos.line, pos.row] = true;
            }
            pos.defineValues(position.line + 2, position.row + 1);
            if (board.validPosition(pos) && canMove(pos))
            {
                mat[pos.line, pos.row] = true;
            }
            pos.defineValues(position.line + 2, position.row - 1);
            if (board.validPosition(pos) && canMove(pos))
            {
                mat[pos.line, pos.row] = true;
            }
            pos.defineValues(position.line + 1, position.row - 2);
            if (board.validPosition(pos) && canMove(pos))
            {
                mat[pos.line, pos.row] = true;
            }

            return(mat);
        }
Exemple #3
0
        public override bool[,] possibleMoves()
        {
            bool[,] mat = new bool[board.Lines, board.Rows];
            Position pos = new Position(0, 0);

            // N
            pos.defineValues(position.line - 1, position.row);
            if (board.validPosition(pos) && canMove(pos))
            {
                mat[pos.line, pos.row] = true;
            }

            // NE
            pos.defineValues(position.line - 1, position.row + 1);
            if (board.validPosition(pos) && canMove(pos))
            {
                mat[pos.line, pos.row] = true;
            }

            // E
            pos.defineValues(position.line, position.row + 1);
            if (board.validPosition(pos) && canMove(pos))
            {
                mat[pos.line, pos.row] = true;
            }

            // SE
            pos.defineValues(position.line + 1, position.row + 1);
            if (board.validPosition(pos) && canMove(pos))
            {
                mat[pos.line, pos.row] = true;
            }

            // S
            pos.defineValues(position.line + 1, position.row);
            if (board.validPosition(pos) && canMove(pos))
            {
                mat[pos.line, pos.row] = true;
            }

            // SW
            pos.defineValues(position.line + 1, position.row - 1);
            if (board.validPosition(pos) && canMove(pos))
            {
                mat[pos.line, pos.row] = true;
            }

            // W
            pos.defineValues(position.line, position.row - 1);
            if (board.validPosition(pos) && canMove(pos))
            {
                mat[pos.line, pos.row] = true;
            }

            // NW
            pos.defineValues(position.line - 1, position.row - 1);
            if (board.validPosition(pos) && canMove(pos))
            {
                mat[pos.line, pos.row] = true;
            }

            // ROQUE

            if (qtsMoves == 0 && !match.check)
            {
                Position posT1 = new Position(position.line, position.row + 3);
                if (testRookToRoque(posT1))
                {
                    Position p1 = new Position(position.line, position.row + 1);
                    Position p2 = new Position(position.line, position.row + 2);
                    if (board.piece(p1) == null && board.piece(p2) == null)
                    {
                        mat[position.line, position.row + 2] = true;
                    }
                }

                Position posT2 = new Position(position.line, position.row - 4);
                if (testRookToRoque(posT2))
                {
                    Position p1 = new Position(position.line, position.row - 1);
                    Position p2 = new Position(position.line, position.row - 2);
                    Position p3 = new Position(position.line, position.row - 3);
                    if (board.piece(p1) == null && board.piece(p2) == null && board.piece(p3) == null)
                    {
                        mat[position.line, position.row - 2] = true;
                    }
                }
            }

            return(mat);
        }
Exemple #4
0
        public override bool[,] possibleMoves()
        {
            bool[,] mat = new bool[board.Lines, board.Rows];
            Position pos = new Position(0, 0);

            if (color == Color.White)
            {
                pos.defineValues(position.line - 1, position.row);
                if (board.validPosition(pos) && free(pos))
                {
                    mat[pos.line, pos.row] = true;
                }
                pos.defineValues(position.line - 2, position.row);
                Position p2 = new Position(position.line - 1, position.row);
                if (board.validPosition(p2) && free(p2) && board.validPosition(pos) && free(pos) && qtsMoves == 0)
                {
                    mat[pos.line, pos.row] = true;
                }
                pos.defineValues(position.line - 1, position.row - 1);
                if (board.validPosition(pos) && enemy(pos))
                {
                    mat[pos.line, pos.row] = true;
                }
                pos.defineValues(position.line - 1, position.row + 1);
                if (board.validPosition(pos) && enemy(pos))
                {
                    mat[pos.line, pos.row] = true;
                }

                // EN PASSANT

                if (position.line == 3)
                {
                    Position left = new Position(position.line, position.row - 1);
                    if (board.validPosition(left) && enemy(left) && board.piece(left) == match.enPassant)
                    {
                        mat[left.line - 1, left.row] = true;
                    }
                    Position right = new Position(position.line, position.row + 1);
                    if (board.validPosition(right) && enemy(right) && board.piece(right) == match.enPassant)
                    {
                        mat[right.line - 1, right.row] = true;
                    }
                }
            }

            else
            {
                pos.defineValues(position.line + 1, position.row);
                if (board.validPosition(pos) && free(pos))
                {
                    mat[pos.line, pos.row] = true;
                }
                pos.defineValues(position.line + 2, position.row);
                Position p2 = new Position(position.line + 1, position.row);
                if (board.validPosition(p2) && free(p2) && board.validPosition(pos) && free(pos) && qtsMoves == 0)
                {
                    mat[pos.line, pos.row] = true;
                }
                pos.defineValues(position.line + 1, position.row + 1);
                if (board.validPosition(pos) && enemy(pos))
                {
                    mat[pos.line, pos.row] = true;
                }
                pos.defineValues(position.line + 1, position.row - 1);
                if (board.validPosition(pos) && enemy(pos))
                {
                    mat[pos.line, pos.row] = true;
                }

                // EN PASSANT

                if (position.line == 4)
                {
                    Position left = new Position(position.line, position.row - 1);
                    if (board.validPosition(left) && enemy(left) && board.piece(left) == match.enPassant)
                    {
                        mat[left.line + 1, left.row] = true;
                    }
                    Position right = new Position(position.line, position.row + 1);
                    if (board.validPosition(right) && enemy(right) && board.piece(right) == match.enPassant)
                    {
                        mat[right.line + 1, right.row] = true;
                    }
                }
            }

            return(mat);
        }