A* and goal optimization