Implemented ai action choosing.