3075: Fix bug in notebook helper function.

This commit is contained in:
Nick Todd
2025-02-05 11:50:38 +00:00
parent 3c84a15d61
commit 3a29593f60

View File

@@ -6,7 +6,7 @@
"source": [ "source": [
"# Customising UC2 Red Agents\n", "# Customising UC2 Red Agents\n",
"\n", "\n",
"© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK\n", "© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK\n",
"\n", "\n",
"This notebook will go over some examples of how red agent behaviour can be varied by changing its configuration parameters.\n", "This notebook will go over some examples of how red agent behaviour can be varied by changing its configuration parameters.\n",
"\n", "\n",
@@ -26,7 +26,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@@ -36,13 +36,12 @@
"from primaite.game.agent.interface import AgentHistoryItem\n", "from primaite.game.agent.interface import AgentHistoryItem\n",
"from primaite.session.environment import PrimaiteGymEnv\n", "from primaite.session.environment import PrimaiteGymEnv\n",
"import yaml\n", "import yaml\n",
"from pprint import pprint\n", "from pprint import pprint"
"from primaite.game.agent.scripted_agents import probabilistic_agent, data_manipulation_bot"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@@ -69,7 +68,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@@ -80,9 +79,7 @@
" if red_action == 'do_nothing':\n", " if red_action == 'do_nothing':\n",
" red_str = 'DO NOTHING'\n", " red_str = 'DO NOTHING'\n",
" elif red_action == 'node_application_execute':\n", " elif red_action == 'node_application_execute':\n",
" client = \"client 1\" if red_info.parameters['node_name'] == 0 else \"client 2\"\n", " red_str = f\"ATTACK from {red_info.parameters['node_name']}\"\n",
"\n",
" red_str = f\"ATTACK from {client}\"\n",
" return red_str" " return red_str"
] ]
}, },
@@ -245,7 +242,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"change = yaml.safe_load(\"\"\"\n", "change = yaml.safe_load(\"\"\"\n",
" possible_start_nodes: [client_1, client_2]\n", " possible_start_nodes: [client_1]\n",
" target_application: DataManipulationBot\n", " target_application: DataManipulationBot\n",
" start_step: 25\n", " start_step: 25\n",
" frequency: 20\n", " frequency: 20\n",
@@ -315,6 +312,10 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"change = yaml.safe_load(\"\"\"\n", "change = yaml.safe_load(\"\"\"\n",
" agent_settings:\n",
" possible_start_nodes: [client_1]\n",
" target_application: DataManipulationBot\n",
"\n",
" action_space:\n", " action_space:\n",
" action_map:\n", " action_map:\n",
" 0:\n", " 0:\n",