Implementing A* in the game