AI planning code