您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
39 行
995 B
39 行
995 B
from abc import ABC, abstractmethod
|
|
from typing import List, Dict, NamedTuple, Optional
|
|
from mlagents.envs import AllBrainInfo, BrainParameters, Policy, ActionInfo
|
|
|
|
|
|
class StepInfo(NamedTuple):
|
|
previous_all_brain_info: Optional[AllBrainInfo]
|
|
current_all_brain_info: AllBrainInfo
|
|
brain_name_to_action_info: Optional[Dict[str, ActionInfo]]
|
|
|
|
|
|
class EnvManager(ABC):
|
|
def __init__(self):
|
|
self.policies: Dict[str, Policy] = {}
|
|
|
|
def set_policy(self, brain_name: str, policy: Policy) -> None:
|
|
self.policies[brain_name] = policy
|
|
|
|
@abstractmethod
|
|
def step(self) -> List[StepInfo]:
|
|
pass
|
|
|
|
@abstractmethod
|
|
def reset(self, config=None, train_mode=True) -> List[StepInfo]:
|
|
pass
|
|
|
|
@property
|
|
@abstractmethod
|
|
def external_brains(self) -> Dict[str, BrainParameters]:
|
|
pass
|
|
|
|
@property
|
|
@abstractmethod
|
|
def reset_parameters(self) -> Dict[str, float]:
|
|
pass
|
|
|
|
@abstractmethod
|
|
def close(self):
|
|
pass
|