public void setForQ() {
       Level[]temps= new Level[10];
this.setLevel(levels[levelNo].getLevel());
        TermQ Start = new TermQ(levels[levelNo].getStaY(), levels[levelNo].getStaX());

        Start.setLevel(levelNo);
        QueueAlgorithmFllow x = new QueueAlgorithmFllow();
        TermQ answer = x.QueueAlgoPath(levels, Start);
        autoSolve solveQ = new autoSolve();
        solveQ.makePath(levels, answer);
        this.solve = solveQ.path;
        int index = 0;
       int lastI=0;
        int lastJ=0;
        if(answer!=null){

         lastI=answer.positionI;
             lastJ=answer.positionI;
    }
        int count=0;
            if(answer!=null){
        while(answer.getParent()!=null){
            int i=answer.positionI;
            int j=answer.positionJ;
            int lev=answer.level;
            
           boolean[][]currentBoolean=solve[lev];
           char[][]currentChar=levels[lev].getLevel();
            char curr= currentChar[i][j];
                        if ((curr == ' ' ||curr=='r'||curr=='S')) {
                       
                            if (i - 1 >= 0 && currentBoolean[i - 1][j]) {

                                levels[lev].getLevel()[i][j] = 'q';
                            } else if (j - 1 >= 0 && currentBoolean[i][j - 1]) {
                               levels[lev].getLevel()[i][j] = 'q';
                            } else if (i + 1 < currentBoolean.length && currentBoolean[i + 1][j]) {
                              levels[lev].getLevel()[i][j] = 'q';

                            } else if (j + 1 < currentBoolean.length && currentBoolean[i][j + 1]) {
                                levels[lev].getLevel()[i][j] = 'q';

                            } else if (i - 1 >= 0 && j - 1 >= 0 && currentBoolean[i - 1][j - 1]) {
                                levels[lev].getLevel()[i][j] = 'q';

                            } else if (i - 1 >= 0 && j + 1 < currentBoolean.length && currentBoolean[i - 1][j + 1]) {
                            levels[lev].getLevel()[i][j]= 'q';

                            } //else if (i - 1 >= 0 && j - 1 >= 0 && currentBoolean[i - 1][j - 1]) {
                                //levels[lev].getLevel()[i][j] = 'h';

                        //    }
                        else if (i + 1 < currentBoolean.length && j - 1 >= 0 && currentBoolean[i + 1][j - 1]) {
                              levels[lev].getLevel()[i][j]= 'q';

                            } else if (i + 1 < currentBoolean.length && j + 1 < currentBoolean.length && currentBoolean[i + 1][j + 1]) {
                                levels[lev].getLevel()[i][j]= 'q';

                            }
                               currentBoolean[i][j]=false;

                        }
            lastI=i;
lastJ=j;
            answer=answer.getParent();
            count++;
    }
        System.out.println("pathCost ="+count);
    }
          for(index=0;index<levels.length&&!solveQ.s.isEmpty();index++){
                int newPlace = (Integer) solveQ.s.pop();
              
temps[index]=levels[newPlace];



        }

levelNo=0;

        levels=temps;


            }