diff --git a/src/primaite/game/agent/interface.py b/src/primaite/game/agent/interface.py index 56404e13..5bef1076 100644 --- a/src/primaite/game/agent/interface.py +++ b/src/primaite/game/agent/interface.py @@ -98,6 +98,8 @@ class AbstractAgent(BaseModel, ABC, identifier="Abstract_Agent"): _registry: ClassVar[Dict[str, Type[AbstractAgent]]] = {} config: "AbstractAgent.ConfigSchema" + agent_name: str = "Abstact_Agent" + logger: AgentLog = AgentLog(agent_name) class ConfigSchema(BaseModel): """ @@ -115,9 +117,6 @@ class AbstractAgent(BaseModel, ABC, identifier="Abstract_Agent"): :type agent_settings: Optional[AgentSettings] """ - type: str - agent_name: str = "Abstact_Agent" - logger: AgentLog = AgentLog(agent_name) history: List[AgentHistoryItem] = [] action_manager: Optional[ActionManager] = None observation_manager: Optional[ObservationManager] = None diff --git a/src/primaite/game/agent/scripted_agents/abstract_tap.py b/src/primaite/game/agent/scripted_agents/abstract_tap.py index a1d1eebc..bda54c58 100644 --- a/src/primaite/game/agent/scripted_agents/abstract_tap.py +++ b/src/primaite/game/agent/scripted_agents/abstract_tap.py @@ -11,11 +11,11 @@ class AbstractTAPAgent(AbstractScriptedAgent, identifier="Abstract_TAP"): """Base class for TAP agents to inherit from.""" config: "AbstractTAPAgent.ConfigSchema" + agent_name: str = "Abstract_TAP" class ConfigSchema(AbstractScriptedAgent.ConfigSchema): """Configuration schema for Abstract TAP agents.""" - agent_name: str = "Abstract_TAP" starting_node_name: str next_execution_timestep: int @@ -40,4 +40,4 @@ class AbstractTAPAgent(AbstractScriptedAgent, identifier="Abstract_TAP"): num_nodes = len(self.config.action_manager.node_names) starting_node_idx = random.randint(0, num_nodes - 1) self.starting_node_name = self.config.action_manager.node_names[starting_node_idx] - self.config.logger.debug(f"Selected Starting node ID: {self.starting_node_name}") \ No newline at end of file + self.logger.debug(f"Selected Starting node ID: {self.starting_node_name}") diff --git a/src/primaite/game/agent/scripted_agents/data_manipulation_bot.py b/src/primaite/game/agent/scripted_agents/data_manipulation_bot.py index dbb51b74..247e815a 100644 --- a/src/primaite/game/agent/scripted_agents/data_manipulation_bot.py +++ b/src/primaite/game/agent/scripted_agents/data_manipulation_bot.py @@ -10,15 +10,15 @@ class DataManipulationAgent(AbstractTAPAgent, identifier="Data_Manipulation_Agen """Agent that uses a DataManipulationBot to perform an SQL injection attack.""" config: "DataManipulationAgent.ConfigSchema" + agent_name: str = "Data_Manipulation_Agent" class ConfigSchema(AbstractTAPAgent.ConfigSchema): """Configuration Schema for DataManipulationAgent.""" starting_application_name: str - agent_name: str = "Data_Manipulation_Agent" def __init__(self) -> None: - """Meh.""" + """Initialise DataManipulationAgent.""" self.setup_agent() @property diff --git a/src/primaite/game/agent/scripted_agents/probabilistic_agent.py b/src/primaite/game/agent/scripted_agents/probabilistic_agent.py index 1522096e..6300b1d9 100644 --- a/src/primaite/game/agent/scripted_agents/probabilistic_agent.py +++ b/src/primaite/game/agent/scripted_agents/probabilistic_agent.py @@ -14,11 +14,11 @@ class ProbabilisticAgent(AbstractScriptedAgent, identifier="Probabilistic_Agent" """Scripted agent which randomly samples its action space with prescribed probabilities for each action.""" config: "ProbabilisticAgent.ConfigSchema" + agent_name: str = "Probabilistic_Agent" class ConfigSchema(AbstractScriptedAgent.ConfigSchema): """Configuration schema for Probabilistic Agent.""" - agent_name: str = "Probabilistic_Agent" action_space: ActionManager action_probabilities: Dict[int, float] """Probability to perform each action in the action map. The sum of probabilities should sum to 1.""" diff --git a/src/primaite/game/agent/scripted_agents/random_agent.py b/src/primaite/game/agent/scripted_agents/random_agent.py index e11e3352..8b0a3591 100644 --- a/src/primaite/game/agent/scripted_agents/random_agent.py +++ b/src/primaite/game/agent/scripted_agents/random_agent.py @@ -31,27 +31,27 @@ class RandomAgent(AbstractScriptedAgent, identifier="Random_Agent"): class PeriodicAgent(AbstractScriptedAgent, identifier="Periodic_Agent"): """Agent that does nothing most of the time, but executes application at regular intervals (with variance).""" - config: "PeriodicAgent.ConfigSchema" + config: "PeriodicAgent.ConfigSchema" = {} class ConfigSchema(AbstractScriptedAgent.ConfigSchema): """Configuration Schema for Periodic Agent.""" - agent_name = "Periodic_Agent" - """Name of the agent.""" - start_step: int = 20 - "The timestep at which an agent begins performing it's actions." - start_variance: int = 5 - "Deviation around the start step." - frequency: int = 5 - "The number of timesteps to wait between performing actions." - variance: int = 0 - "The amount the frequency can randomly change to." - max_executions: int = 999999 - "Maximum number of times the agent can execute its action." - num_executions: int = 0 - """Number of times the agent has executed an action.""" - next_execution_timestep: int = 0 - """Timestep of the next action execution by the agent.""" + agent_name = "Periodic_Agent" + """Name of the agent.""" + start_step: int = 20 + "The timestep at which an agent begins performing it's actions." + start_variance: int = 5 + "Deviation around the start step." + frequency: int = 5 + "The number of timesteps to wait between performing actions." + variance: int = 0 + "The amount the frequency can randomly change to." + max_executions: int = 999999 + "Maximum number of times the agent can execute its action." + num_executions: int = 0 + """Number of times the agent has executed an action.""" + next_execution_timestep: int = 0 + """Timestep of the next action execution by the agent.""" @property def num_executions(self) -> int: