Original A* implementation, modified to automate