|
|
|
|
|
|
from mlagents_envs.timers import timed, hierarchical_timer |
|
|
|
from mlagents_envs.exception import ( |
|
|
|
UnityEnvironmentException, |
|
|
|
UnityCommunicationException, |
|
|
|
UnityCommunicatorStoppedException, |
|
|
|
) |
|
|
|
|
|
|
|
from mlagents_envs.communicator_objects.command_pb2 import STEP, RESET |
|
|
|
|
|
|
if self._loaded: |
|
|
|
outputs = self.communicator.exchange(self._generate_reset_input()) |
|
|
|
if outputs is None: |
|
|
|
raise UnityCommunicationException("Communicator has stopped.") |
|
|
|
raise UnityCommunicatorStoppedException("Communicator has exited.") |
|
|
|
self._update_behavior_specs(outputs) |
|
|
|
rl_output = outputs.rl_output |
|
|
|
self._update_state(rl_output) |
|
|
|
|
|
|
with hierarchical_timer("communicator.exchange"): |
|
|
|
outputs = self.communicator.exchange(step_input) |
|
|
|
if outputs is None: |
|
|
|
raise UnityCommunicationException("Communicator has stopped.") |
|
|
|
raise UnityCommunicatorStoppedException("Communicator has exited.") |
|
|
|
self._update_behavior_specs(outputs) |
|
|
|
rl_output = outputs.rl_output |
|
|
|
self._update_state(rl_output) |
|
|
|