public void findPath(){
        while (open.size() > 0){
            Node best = findBestNode();
            open.remove (best);
            close.add (best);

            if (best.isEnd()){          //if the best square is the end square
                //insert code here for what to do after path is fouind
                //System.out.println ("Path Found");

                setPath (best);
                return;
            }
            else{
                ArrayList<Node> adj = best.getAdj();

                for (Node neighbour: adj){
                    if (open.contains (neighbour)){
                        Node temp = new Node (neighbour.getX(), neighbour.getY(), this, true);
                        temp.setParent (best);
                        if (temp.getFinalCost() >= neighbour.getFinalCost()){
                            continue;
                        }
                    }

                    if (close.contains (neighbour)){
                        Node temp = new Node (neighbour.getX(), neighbour.getY(), this, true);
                        temp.setParent (best);
                        if (temp.getFinalCost() >= neighbour.getFinalCost()){
                            continue;
                        }
                    }

                    neighbour.setParent (best);
                    open.remove (neighbour);
                    close.remove (neighbour);
                    open.add (0, neighbour);    //changes behaviour for pathfinding
                    //open.add (neighbour);         //this one makes it go down first
                }
            }
        }
        //insert code for finding no path
        // System.out.println ("No path" + startX + " " + endX);
        path = null;
        intPath = null;
    }