Improved AI (A* pathfinding algorithm)