|
|
|
|
|
|
value = {} if value is None else value |
|
|
|
if self._loaded and not self._global_done and self._global_done is not None: |
|
|
|
if isinstance(action, (int, np.int_, float, np.float_, list, np.ndarray)): |
|
|
|
if self._num_external_brains > 1: |
|
|
|
if self._num_external_brains == 1: |
|
|
|
action = {self._external_brain_names[0]: action} |
|
|
|
elif self._num_external_brains > 1: |
|
|
|
action = {self._external_brain_names[0]: action} |
|
|
|
raise UnityActionException( |
|
|
|
"There are no external brains in the environment, " |
|
|
|
"step cannot take an action input") |
|
|
|
|
|
|
|
if self._num_external_brains > 1: |
|
|
|
if self._num_external_brains == 1: |
|
|
|
memory = {self._external_brain_names[0]: memory} |
|
|
|
elif self._num_external_brains > 1: |
|
|
|
memory = {self._external_brain_names[0]: memory} |
|
|
|
raise UnityActionException( |
|
|
|
"There are no external brains in the environment, " |
|
|
|
"step cannot take a memory input") |
|
|
|
if self._num_external_brains > 1: |
|
|
|
if self._num_external_brains == 1: |
|
|
|
value = {self._external_brain_names[0]: value} |
|
|
|
elif self._num_external_brains > 1: |
|
|
|
value = {self._external_brain_names[0]: value} |
|
|
|
raise UnityActionException( |
|
|
|
"There are no external brains in the environment, " |
|
|
|
"step cannot take a value input") |
|
|
|
|
|
|
|
for brain_name in action.keys() + memory.keys() + value.keys(): |
|
|
|
if brain_name not in self._external_brain_names: |
|
|
|
raise UnityActionException( |
|
|
|
"The name {0} does not correspond to an external brain " |
|
|
|
"in the environment". format(brain_name)) |
|
|
|
|
|
|
|
for b in self._external_brain_names: |
|
|
|
n_agent = len(self._data[b].agents) |
|
|
|