public void setForStack(){
        Level [] temps =new Level[10];

        NodeStack arrange = new NodeStack();
        Stack stack = new Stack();
        TermS start = new TermS(levels[levelNo].getStaY(), levels[levelNo].getStaX());
        start.setLevel(levelNo);
        stack.StackFllow(levels, start);
        NodeStack finalPath = stack.path;
        int pathCost = finalPath.size();
        System.out.println("Path cost ="+pathCost);
        while(!finalPath.isEmpty()){
            TermS current=(TermS) finalPath.pop();
            if(arrange.isEmpty()){
                arrange.push(current.getLevel());
            }else{
//                if(current.getLevel()!=arrange.top()){
//                     arrange.push(current.getLevel());
//                }
            }if(levels[current.getLevel()].getLevel()[current.getPositionI()][current.getPositionJ()]==' '||levels[current.getLevel()].getLevel()[current.getPositionI()][current.getPositionJ()]=='r'){
            if(current.getDirection()=='a'){

                levels[current.getLevel()].getLevel()[current.getPositionI()][current.getPositionJ()]='h';
            }else if(current.getDirection()=='b'){
                 levels[current.getLevel()].getLevel()[current.getPositionI()][current.getPositionJ()]='n';
            }
            else if(current.getDirection()=='c'){
                 levels[current.getLevel()].getLevel()[current.getPositionI()][current.getPositionJ()]='k';
            }
            else if(current.getDirection()=='f'){
                 levels[current.getLevel()].getLevel()[current.getPositionI()][current.getPositionJ()]='e';
            }
            else if(current.getDirection()=='i'){
                 levels[current.getLevel()].getLevel()[current.getPositionI()][current.getPositionJ()]='l';
            }
            else if(current.getDirection()=='h'){
                 levels[current.getLevel()].getLevel()[current.getPositionI()][current.getPositionJ()]='s';
            }else if(current.getDirection()=='g'){
                 levels[current.getLevel()].getLevel()[current.getPositionI()][current.getPositionJ()]='j';
            }else if(current.getDirection()=='d'){
                 levels[current.getLevel()].getLevel()[current.getPositionI()][current.getPositionJ()]='w';
            }
            }
        }
         for(int index=0;index<levels.length&&!arrange.isEmpty();index++){
                int newPlace = (Integer) arrange.pop();
               
temps[index]=levels[newPlace];



        }

levelNo=0;

        levels=temps;

    }