|
|
|
|
|
|
import pytest |
|
|
|
|
|
|
|
from mlagents_envs.environment import UnityEnvironment |
|
|
|
from mlagents_envs.base_env import DecisionSteps, TerminalSteps |
|
|
|
from mlagents_envs.base_env import DecisionSteps, TerminalSteps, ActionTuple |
|
|
|
from mlagents_envs.exception import UnityEnvironmentException, UnityActionException |
|
|
|
from mlagents_envs.mock_communicator import MockCommunicator |
|
|
|
|
|
|
|
|
|
|
env.step() |
|
|
|
with pytest.raises(UnityActionException): |
|
|
|
env.set_actions("RealFakeBrain", spec.action_spec.empty_action(n_agents - 1)) |
|
|
|
decision_steps, terminal_steps = env.get_steps("RealFakeBrain") |
|
|
|
n_agents = len(decision_steps) |
|
|
|
_empty_act = spec.action_spec.empty_action(n_agents) |
|
|
|
next_action = ActionTuple(_empty_act.continuous - 1, _empty_act.discrete - 1) |
|
|
|
env.set_actions("RealFakeBrain", next_action) |
|
|
|
env.step() |
|
|
|
|
|
|
|
env.close() |
|
|
|
assert isinstance(decision_steps, DecisionSteps) |
|
|
|
assert isinstance(terminal_steps, TerminalSteps) |
|
|
|