Pass agent settings from config to agent

This commit is contained in:
Jake Walker
2023-11-20 10:38:01 +00:00
parent 227e73602f
commit 7e0e8a4768
3 changed files with 40 additions and 7 deletions

View File

@@ -25,6 +25,24 @@ class AgentExecutionDefinition(BaseModel):
"The probability of data manipulation succeeding."
class AgentStartSettings(BaseModel):
"""Configuration values for when an agent starts performing actions."""
start_step: int = 5
"The timestep at which an agent begins performing it's actions"
frequency: int = 5
"The number of timesteps to wait between performing actions"
variance: int = 0
"The amount the frequency can randomly change to"
class AgentSettings(BaseModel):
"""Settings for configuring the operation of an agent."""
start_settings: Optional[AgentStartSettings] = None
"Configuration for when an agent begins performing it's actions"
class AbstractAgent(ABC):
"""Base class for scripted and RL agents."""
@@ -35,6 +53,7 @@ class AbstractAgent(ABC):
observation_space: Optional[ObservationSpace],
reward_function: Optional[RewardFunction],
execution_definition: Optional[AgentExecutionDefinition],
agent_settings: Optional[AgentSettings],
) -> None:
"""
Initialize an agent.
@@ -57,6 +76,8 @@ class AbstractAgent(ABC):
# by for example specifying target ip addresses, or converting a node ID into a uuid
self.execution_definition = execution_definition or AgentExecutionDefinition()
self.agent_settings = agent_settings or AgentSettings()
def convert_state_to_obs(self, state: Dict) -> ObsType:
"""
Convert a state from the simulator into an observation for the agent using the observation space.