|
|
|
|
|
|
from mlagents.trainers.agent_processor import AgentManager, AgentManagerQueue |
|
|
|
from mlagents.trainers.action_info import ActionInfo |
|
|
|
from mlagents_envs.logging_util import get_logger |
|
|
|
from mlagents_envs.exception import UnityActionException |
|
|
|
|
|
|
|
AllStepResult = Dict[BehaviorName, Tuple[DecisionSteps, TerminalSteps]] |
|
|
|
AllGroupSpec = Dict[BehaviorName, BehaviorSpec] |
|
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
def action_tuple_from_numpy_dict(action_dict: Dict[str, np.ndarray]) -> ActionTuple: |
|
|
|
continuous: np.ndarray = None |
|
|
|
discrete: np.ndarray = None |
|
|
|
if "discrete_action" in action_dict: |
|
|
|
if "discrete_action" in action_dict: |
|
|
|
discrete = action_dict["discrete_action"] |
|
|
|
action_tuple = ActionTuple(continuous, discrete) |
|
|
|
else: |
|
|
|
action_tuple = ActionTuple.create_continuous(continuous) |
|
|
|
elif "discrete_action" in action_dict: |
|
|
|
return ActionTuple(continuous, discrete) |
|
|
|
action_tuple = ActionTuple.create_discrete(discrete) |
|
|
|
else: |
|
|
|
raise UnityActionException( |
|
|
|
"The action dict must contain entries for either continuous_action or discrete_action." |
|
|
|
) |
|
|
|
return action_tuple |