public void resolve() {
        try {
            Stack<Coordinates> actualStack = new Stack<Coordinates>();
            Stack<Coordinates> shortestStack = new Stack<Coordinates>();

            Random randomGenerator = new Random();
            Coordinates actual = new Coordinates(startX, startY);
            cellsVisited = 0;
            while (cellsVisited < cells) {
                if (this.getNeighboursOpen(actual) != null) {
                    Coordinates[] neighbours = this.getNeighboursOpen(actual);
                    int nbr = neighbours.length;
                    int rand = randomGenerator.nextInt(nbr);
                    Coordinates target = new Coordinates(neighbours[rand].getX(), neighbours[rand].getY());
                    caseArray[neighbours[rand].getX()][neighbours[rand].getY()].setSolverVisited(true);

                    actualStack.push(actual);
                    actual = new Coordinates(target.getX(), target.getY());

                    cellsVisited++;
                } else {
                    if (actual.getX() == this.getEndX() && actual.getY() == this.getEndY()) {
                        shortestStack = (Stack<Coordinates>) actualStack.clone();
                        Coordinates temp = actualStack.pop();
                        actual = new Coordinates(temp.getX(), temp.getY());
                    } else {
                        Coordinates temp = actualStack.pop();
                        actual = new Coordinates(temp.getX(), temp.getY());
                    }
                }
            }
            solvedPath = (Stack<Coordinates>) shortestStack.clone();
            int i = shortestStack.size();
            for (int j = 0; j < i; j++) {

                Coordinates temp = shortestStack.pop();
                caseArray[temp.getX()][temp.getY()].setFinalPath(true);
            }
            this.isSolved = true;
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("Unknown Error !");
        }
    }