Improved AI heuristic