private int pathFind(Pos start, int danger) throws Exception {
//        ArrayList<String> sTypes;
//        for(int i = 1; i < 5; i++)
//        {
//            for(int j = 1; j < 5; j++)
//            {
//                //just debugging to see the map and how it is represented from prolog
//                sTypes = m_Logic.locateAllAt(j, i);
//                m_Map.add(sTypes);
//            }
//        }
        //If there exist a goal to be reached no need to search again. 
        if(m_Path == null || m_Path.isEmpty())
        {
            Pos goal = findGoalPos();
            
            m_Path = aStarPath(start.x, start.y, goal.x, goal.y, danger);
            while(m_Path == null)
            {
                //if a route to a square was not reached, decrease the dangerlevel 
                //and try again.
                m_Path = aStarPath(start.x, start.y, goal.x, goal.y, danger--);
                if(danger <= 0)
                    break;
            }
        }
        return danger;
    }