Added win checking to heuristic.