Closed kasanari closed 7 months ago
This can also lead to invalid actions not being reported as failed:
from pprint import pprint
from CybORG import CybORG
from CybORG.Simulator.Scenarios import EnterpriseScenarioGenerator
from CybORG.Agents import SleepAgent, FiniteStateRedAgent, EnterpriseGreenAgent
from CybORG.Simulator.Actions import Analyse
from CybORG.Simulator.Actions.ConcreteActions.ControlTraffic import BlockTrafficZone
steps = 200
sg = EnterpriseScenarioGenerator(blue_agent_class=SleepAgent,
green_agent_class=EnterpriseGreenAgent,
red_agent_class=FiniteStateRedAgent,
steps=steps)
cyborg = CybORG(scenario_generator=sg, seed=1000)
cyborg.reset()
blue_agent_name = 'blue_agent_0'
blue_action_space = cyborg.get_action_space(blue_agent_name)
action = Analyse(session=0, agent=blue_agent_name, hostname='restricted_zone_a_subnet_server_host_0')
results = cyborg.step(agent=blue_agent_name, action=action)
print("Step 1: ", results.observation)
action = BlockTrafficZone(session=0, agent=blue_agent_name, from_subnet='restricted_zone_a_subnet', to_subnet='hoolabaloo') <- Invalid Action
results = cyborg.step(agent=blue_agent_name, action=action)
print("Step 2: ", results.observation)
results = cyborg.step(agent=blue_agent_name)
print("Step 3: ", results.observation)
Step 1: {'success': <TernaryEnum.IN_PROGRESS: 4>}
Step 2: {'success': <TernaryEnum.TRUE: 1>, 'action': Analyse restricted_zone_a_subnet_server_host_0}
Step 3: {'success': <TernaryEnum.UNKNOWN: 2>, 'action': Sleep}
I believe that due to this line, if an agent has an action that is currently IN_PROGRESS
, any additional actions are silently ignored since only actions set in actions_in_progress
dict are executed. Therefore, I think you would be correct to say that blue agents should not take new actions if others are running.
Hi @kasanari, as @dvanbrug pointed out, additional actions are ignored if a blue agent is currently executing an action. This prevents them from stacking actions on top of one another as CybORG was designed to process only one action at a time. In the future, this would be a really cool feature to add, but for this CAGE Challenge 4 it won't be included.
The 'success' parameter seems to get overwritten when an action finished at the same time one starts.
This can be demonstrated with a slight modification to the example in the documentation:
In step 1, IN_PROGRESS refers to the action just taken (the first Analyze). When the second action is taken, the 'success' of the second action is seemingly overwritten by the result of the first action as it finishes. Ideally, I would like to know the status of the second action alongside the result of the finished first action. I could assume that the status of all actions just taken is IN_PROGRESS, but would that be true for actions where the duration is 1? Should a blue agent not take actions while another one is running?