Update actions and agents to get all tests passing post-refactor

This commit is contained in:
Marek Wolan
2025-01-20 14:07:51 +00:00
parent c521528a0a
commit 18a665e562
5 changed files with 18 additions and 44 deletions

View File

@@ -84,6 +84,7 @@ class ConfigureDoSBotAction(AbstractAction, identifier="configure_dos_bot"):
dos_intensity=config.dos_intensity,
max_sessions=config.max_sessions,
)
data = {k: v for k, v in data.items() if v is not None}
return ["network", "node", config.node_name, "application", "DoSBot", "configure", data]

View File

@@ -16,7 +16,7 @@ __all__ = "ProbabilisticAgent"
class ProbabilisticAgent(AbstractScriptedAgent, identifier="ProbabilisticAgent"):
"""Scripted agent which randomly samples its action space with prescribed probabilities for each action."""
rng: Generator = np.random.default_rng(np.random.randint(0, 65535))
rng: Generator = Field(default_factory=lambda: np.random.default_rng(np.random.randint(0, 65535)))
class AgentSettingsSchema(AbstractScriptedAgent.AgentSettingsSchema):
"""Schema for the `agent_settings` part of the agent config."""

View File

@@ -476,33 +476,6 @@ class PrimaiteGame:
if isinstance(new_agent, ProxyAgent):
game.rl_agents[agent_cfg["ref"]] = new_agent
# agent_name = agent_cfg["ref"] # noqa: F841
# agent_type = agent_cfg["type"]
# action_space_cfg = agent_cfg["action_space"]
# observation_space_cfg = agent_cfg["observation_space"]
# reward_function_cfg = agent_cfg["reward_function"]
# agent_settings = agent_cfg["agent_settings"]
# agent_config = {
# "type": agent_type,
# "action_space": action_space_cfg,
# "observation_space": observation_space_cfg,
# "reward_function": reward_function_cfg,
# "agent_settings": agent_settings,
# "game": game,
# }
# # CREATE AGENT
# if agent_type in AbstractAgent._registry:
# new_agent = AbstractAgent._registry[agent_cfg["type"]].from_config(config=agent_config)
# # If blue agent is created, add to game.rl_agents
# if agent_type == "ProxyAgent":
# game.rl_agents[agent_cfg["ref"]] = new_agent
# else:
# msg = f"Configuration error: {agent_type} is not a valid agent type."
# _LOGGER.error(msg)
# raise ValueError(msg)
# Validate that if any agents are sharing rewards, they aren't forming an infinite loop.
game.setup_reward_sharing()