saving ai state