From 015571217bad50e5a0318d4a88a37d3a1545871d Mon Sep 17 00:00:00 2001 From: Czar Echavez Date: Tue, 8 Nov 2022 11:35:44 +0000 Subject: [PATCH] AIDT-67: remove partial configs and use base test config + code clean up --- tests/__init__.py | 4 + .../config => }/config_test_utils.py | 0 .../complete_blue_agent_config.yaml | 90 ------------------- .../complete_game_rules_config.yaml | 31 ------- .../complete_observation_space_config.yaml | 18 ---- .../complete_red_agent_config.yaml | 64 ------------- .../complete_reset_config.yaml | 3 - .../complete_rewards_config.yaml | 13 --- tests/unit_tests/config/agents/__init__.py | 13 --- .../config/agents/test_blue_agent_config.py | 29 +++--- .../config/agents/test_red_agent_config.py | 18 ++-- .../unit_tests/config/environment/__init__.py | 22 ----- .../environment/test_game_rules_config.py | 14 +-- .../test_observation_space_config.py | 8 +- .../config/environment/test_reset_config.py | 10 +-- .../config/environment/test_rewards_config.py | 8 +- .../game_config/test_game_mode_config.py | 8 +- .../network_config/test_network_config.py | 2 +- .../config/game_config/game_mode_config.py | 1 - 19 files changed, 52 insertions(+), 304 deletions(-) rename tests/{unit_tests/config => }/config_test_utils.py (100%) delete mode 100644 tests/test_configs/config_sections/complete_blue_agent_config.yaml delete mode 100644 tests/test_configs/config_sections/complete_game_rules_config.yaml delete mode 100644 tests/test_configs/config_sections/complete_observation_space_config.yaml delete mode 100644 tests/test_configs/config_sections/complete_red_agent_config.yaml delete mode 100644 tests/test_configs/config_sections/complete_reset_config.yaml delete mode 100644 tests/test_configs/config_sections/complete_rewards_config.yaml diff --git a/tests/__init__.py b/tests/__init__.py index 9864a818..8fd7c2be 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -5,3 +5,7 @@ TEST_CONFIG_PATH: Final[Path] = Path( os.path.join(Path(__file__).parent.resolve(), "test_configs") ) + +TEST_BASE_CONFIG_PATH = Path( + os.path.join(Path(__file__).parent.resolve(), "test_configs", "base_config.yaml") +) diff --git a/tests/unit_tests/config/config_test_utils.py b/tests/config_test_utils.py similarity index 100% rename from tests/unit_tests/config/config_test_utils.py rename to tests/config_test_utils.py diff --git a/tests/test_configs/config_sections/complete_blue_agent_config.yaml b/tests/test_configs/config_sections/complete_blue_agent_config.yaml deleted file mode 100644 index 81925944..00000000 --- a/tests/test_configs/config_sections/complete_blue_agent_config.yaml +++ /dev/null @@ -1,90 +0,0 @@ -# The max number of deceptive nodes that blue can place -max_number_deceptive_nodes: 2 -# Can discover the location an attack came from if the attack failed -can_discover_failed_attacks: True - - -# The blue agent does not have to have perfect detection. In these settings you can change how much information blue -# can gain from the red agents actions. There are two different pieces of information blue can get: intrusions and -# attacks. - -# --Intrusions-- -# An intrusion is when the red agent takes over a node and compromises it. You can change the chance that blue has to -# be able to detect this using the "chance_to_immediately_discover_intrusion". If blue does not detect an intrusion -# then it can use the scan action to try and discover these intrusions with "chance_to_discover_intrusion_on_scan". - -# There are also deceptive nodes that blue can place down. These nodes are used as detectors to inform blue when they -# are compromised. They should have a chance to detect of 1 so that they can detect everything (at the very least -# they should have a chance to detect higher than the normal chance to detect) but you can modify it if you so wish -# with "chance_to_immediately_discover_intrusion_deceptive_node" and "chance_to_discover_intrusion_on_scan_deceptive_node" - -# --Attacks-- -# Attacks are the actual attacks that the red agent does to compromise the nodes. For example you may be able to see -# that node 14 is compromised but using the attack detection, the blue agent may be able to see that it was node 12 -# that attacked node 14. You can modify the chance for blue to see attacks that failed, succeeded (and blue was able -# to detect that the node was compromised) and attacks that succeeded and the blue agent did not detect the intrusion. - -# Again there are settings to change the likelihood that a deceptive node can detect an attack. While this should -# remain at 1, it is open for you to change. - -# --INTRUSIONS-- -# -Standard Nodes- -# Chance for blue to discover a node that red has compromised the instant red compromises the node -chance_to_immediately_discover_intrusion: 0.5 -# When blue performs the scan action this is the chance that a red intrusion is discovered -chance_to_discover_intrusion_on_scan: 1 - -# -Deceptive Nodes- -# Chance for blue to discover a deceptive node that red has compromised the instant red compromises the node -chance_to_immediately_discover_intrusion_deceptive_node: 1 -# When blue uses the scan action what is the chance that blue will detect an intrusion in a deceptive node -chance_to_discover_intrusion_on_scan_deceptive_node: 1 - -# --ATTACKS-- -# -Standard Nodes- -# Chance for blue to discover information about a failed attack -chance_to_discover_failed_attack: 1 -# Can blue learn information about an attack that succeeds if the compromise is known -can_discover_succeeded_attacks_if_compromise_is_discovered: True -# Can blue learn information about an attack that succeeds if the compromise is NOT known -can_discover_succeeded_attacks_if_compromise_is_not_discovered: True -# Chance for blue to discover information about an attack that succeeded and the compromise was known -chance_to_discover_succeeded_attack_compromise_known: 1 -# Chance for blue to discover information about an attack that succeeded and the compromise was NOT known -chance_to_discover_succeeded_attack_compromise_not_known: 1 - -# -Deceptive Nodes- -# Chance to discover the location of a failed attack on a deceptive node -chance_to_discover_failed_attack_deceptive_node: 1 -# Chance to discover the location of a succeeded attack against a deceptive node -chance_to_discover_succeeded_attack_deceptive_node: 1 - - -# If blue fixes a node then the vulnerability score of that node increases -making_node_safe_modifies_vulnerability: False -# The amount that the vulnerability of a node changes when it is made safe -vulnerability_change_during_node_patch: 0.4 -# When fixing a node the vulnerability score is randomised -making_node_safe_gives_random_vulnerability: False - -# CHOOSE AT LEAST ONE OF THE FOLLOWING 8 ITEMS -# Blue picks a node and reduces the vulnerability score -blue_uses_reduce_vulnerability: False -# Blue picks a node and restores everything about the node to its state at the beginning of the game -blue_uses_restore_node: True -# Blue fixes a node but does not restore it to its initial state -blue_uses_make_node_safe: True -# Blue scans all of the nodes to try and detect any red intrusions -blue_uses_scan: True -# Blue disables all of the connections to and from a node -blue_uses_isolate_node: False -# Blue re-connects all of the connections to and from a node -blue_uses_reconnect_node: False -# Blue agent does nothing -blue_uses_do_nothing: False -# Blue agent can place down deceptive nodes. These nodes act as just another node in the network but have a different -# chance of spotting attacks and always show when they are compromised -blue_uses_deceptive_nodes: False -# When the blue agent places a deceptive node and it has none left in stock it will "pick up" the first deceptive node that it used and "relocate it" -# When relocating a node will the stats for the node (such as the vulnerability and compromised status) be re-generated as if adding a new node or will they carry over from the "old" node -relocating_deceptive_nodes_generates_a_new_node: True diff --git a/tests/test_configs/config_sections/complete_game_rules_config.yaml b/tests/test_configs/config_sections/complete_game_rules_config.yaml deleted file mode 100644 index e9d5947f..00000000 --- a/tests/test_configs/config_sections/complete_game_rules_config.yaml +++ /dev/null @@ -1,31 +0,0 @@ -# Minimum number of nodes the network this game mode is allowed to run on -min_number_of_network_nodes: 18 -# A lower vulnerability means that a node is less likely to be compromised -node_vulnerability_lower_bound: 0.2 -# A higher vulnerability means that a node is more vulnerable -node_vulnerability_upper_bound: 0.8 -# The max steps that a game can go on for. If the blue agent reaches this they win -max_steps: 1000 -# The blue agent loses if all the nodes become compromised -lose_when_all_nodes_lost: False -# The blue agent loses if n% of the nodes become compromised -lose_when_n_percent_of_nodes_lost: False -# The percentage of nodes that need to be lost for blue to lose -percentage_of_nodes_compromised_equals_loss: 0.8 -# Blue loses if a special 'high value' target is lost (a node picked in the environment) -lose_when_high_value_target_lost: True -# If no high value targets are supplied, how many should be chosen -number_of_high_value_targets: 1 -# The high value target is picked at random -choose_high_value_targets_placement_at_random: False -# The node furthest away from the entry points to the network is picked as the target -choose_high_value_targets_furthest_away_from_entry: True -# If no entry nodes are supplied choose some at random -choose_entry_nodes_randomly: True -# If no entry nodes are supplied then how many should be chosen -number_of_entry_nodes: 3 -# If no entry nodes are supplied then what bias is applied to the nodes when choosing random entry nodes -prefer_central_nodes_for_entry_nodes: True -prefer_edge_nodes_for_entry_nodes: False -# The length of a grace period at the start of the game. During this time the red agent cannot act. This gives the blue agent a chance to "prepare" (A length of 0 means that there is no grace period) -grace_period_length: 0 \ No newline at end of file diff --git a/tests/test_configs/config_sections/complete_observation_space_config.yaml b/tests/test_configs/config_sections/complete_observation_space_config.yaml deleted file mode 100644 index db80d48f..00000000 --- a/tests/test_configs/config_sections/complete_observation_space_config.yaml +++ /dev/null @@ -1,18 +0,0 @@ -# The blue agent can see the compromised status of all the nodes -compromised_status: True -# The blue agent can see the vulnerability scores of all the nodes -vulnerabilities: True -# The blue agent can see what nodes are connected to what other nodes -node_connections: True -# The blue agent can see the average vulnerability of all the nodes -average_vulnerability: False -# The blue agent can see a graph connectivity score -graph_connectivity: True -# The blue agent can see all of the nodes that have recently attacked a safe node -attacking_nodes: True -# The blue agent can see all the nodes that have recently been attacked -attacked_nodes: True -# The blue agent can see all of the special nodes (entry nodes, high value targets) -special_nodes: True -# The blue agent can see the skill level of the red agent -red_agent_skill: True \ No newline at end of file diff --git a/tests/test_configs/config_sections/complete_red_agent_config.yaml b/tests/test_configs/config_sections/complete_red_agent_config.yaml deleted file mode 100644 index cbee5fdc..00000000 --- a/tests/test_configs/config_sections/complete_red_agent_config.yaml +++ /dev/null @@ -1,64 +0,0 @@ -# The red agents skill level. Higher means that red is more likely to succeed in attacks -red_skill: 0.5 - -# CHOOSE AT LEAST ONE OF THE FOLLOWING 3 ITEMS (red_ignore_defences: False counts as choosing an item) -# Red uses its skill modifier when attacking nodes -red_uses_skill: True -# The red agent ignores the defences of nodes -red_ignores_defences: False -# Reds attacks always succeed -red_always_succeeds: False - -# The red agent will only ever be in one node however it can control any amount of nodes. Can the red agent only -# attack from its one main node or can it attack from any node that it controls -red_can_only_attack_from_red_agent_node: False -red_can_attack_from_any_red_node: True - -# The red agent naturally spreads its influence every time-step -red_can_naturally_spread: True -# If a node is connected to a compromised node what chance does it have to become compromised every turn through natural spreading -chance_to_spread_to_connected_node: 0.05 -# If a node is not connected to a compromised node what chance does it have to become randomly infected through natural spreading -chance_to_spread_to_unconnected_node: 0 - -# CHOOSE AT LEAST ONE OF THE FOLLOWING 6 ITEMS (EACH ITEM HAS ASSOCIATED WEIGHTING) -# SPREAD: Tries to spread to every node connected to an infected node -red_uses_spread_action: False -# weighting for action -spread_action_likelihood: 1 -# chance for each 'spread' to succeed -chance_for_red_to_spread: 0.1 -# RANDOM INFECT: Tries to infect every safe node in the environment -red_uses_random_infect_action: False -# weighting for action -random_infect_action_likelihood: 1 -# chance for each 'infect' to succeed -chance_for_red_to_random_compromise: 0.1 -# BASIC ATTACK: The red agent picks a single node connected to an infected node and tries to attack and take over that node -red_uses_basic_attack_action: True -# weighting for action -basic_attack_action_likelihood: 2 -# DO NOTHING: The red agent does nothing -red_uses_do_nothing_action: True -do_nothing_action_likelihood: 1 -# The red agent moves to a different node -red_uses_move_action: False -move_action_likelihood: 1 -# ZERO DAY: The red agent will pick a safe node connected to an infect node and take it over with a 100% chance to succeed (can only happen every n timesteps) -red_uses_zero_day_action: True -# The number of zero day attacks that the red agent starts with -zero_day_start_amount: 1 -# The amount of 'progress' that need to have passed before the red agent gains a zero day attack -days_required_for_zero_day: 4 - -# CHOOSE ONE OF THE FOLLOWING 5 ITEMS -# Red picks nodes to attack at random -red_chooses_target_at_random: True -# Red sorts the nodes it can attack and chooses the one that has the most connections -red_prioritises_connected_nodes: False -# Red sorts the nodes it can attack and chooses the one that has the least connections -red_prioritises_un_connected_nodes: False -# Red sorts the nodes is can attack and chooses the one that is the most vulnerable -red_prioritises_vulnerable_nodes: False -# Red sorts the nodes is can attack and chooses the one that is the least vulnerable -red_prioritises_resilient_nodes: False diff --git a/tests/test_configs/config_sections/complete_reset_config.yaml b/tests/test_configs/config_sections/complete_reset_config.yaml deleted file mode 100644 index f70a4281..00000000 --- a/tests/test_configs/config_sections/complete_reset_config.yaml +++ /dev/null @@ -1,3 +0,0 @@ -randomise_vulnerabilities_on_reset: False -choose_new_high_value_targets_on_reset: True -choose_new_entry_nodes_on_reset: True \ No newline at end of file diff --git a/tests/test_configs/config_sections/complete_rewards_config.yaml b/tests/test_configs/config_sections/complete_rewards_config.yaml deleted file mode 100644 index f78ec740..00000000 --- a/tests/test_configs/config_sections/complete_rewards_config.yaml +++ /dev/null @@ -1,13 +0,0 @@ -# Rewards for the blue agent losing -rewards_for_loss: -100 -# Rewards for the blue agent winning by reaching the maximum number of steps -rewards_for_reaching_max_steps: 100 -# How good the end state is (what % blue controls) is multiplied by the rewards that blue receives for winning -end_rewards_are_multiplied_by_end_state: True -# The negative rewards from the red agent winning are reduced the closer to the end the blue agent gets -reduce_negative_rewards_for_closer_fails: True -# choose the reward method -# There are several built in example reward methods that you can choose from (shown below) -# You can also create your own reward method by copying one of the built in methods and calling it here -# built in reward methods: standard_rewards, one_per_timestep, safe_nodes_give_rewards, punish_bad_actions -reward_function: "standard_rewards" \ No newline at end of file diff --git a/tests/unit_tests/config/agents/__init__.py b/tests/unit_tests/config/agents/__init__.py index 8c2298c2..e69de29b 100644 --- a/tests/unit_tests/config/agents/__init__.py +++ b/tests/unit_tests/config/agents/__init__.py @@ -1,13 +0,0 @@ -import os -from pathlib import Path -from typing import Final - -from tests import TEST_CONFIG_PATH - -TEST_BLUE_AGENT_CONFIG_PATH: Final[Path] = Path( - os.path.join(TEST_CONFIG_PATH, "config_sections", "complete_blue_agent_config.yaml") -) - -TEST_RED_AGENT_CONFIG_PATH: Final[Path] = Path( - os.path.join(TEST_CONFIG_PATH, "config_sections", "complete_red_agent_config.yaml") -) diff --git a/tests/unit_tests/config/agents/test_blue_agent_config.py b/tests/unit_tests/config/agents/test_blue_agent_config.py index 2d4cbc35..34c92cd8 100644 --- a/tests/unit_tests/config/agents/test_blue_agent_config.py +++ b/tests/unit_tests/config/agents/test_blue_agent_config.py @@ -1,15 +1,14 @@ -import os from typing import Dict, Any import pytest -from tests.unit_tests.config.agents import TEST_BLUE_AGENT_CONFIG_PATH -from tests.unit_tests.config.config_test_utils import read_yaml_file +from tests import TEST_BASE_CONFIG_PATH +from tests.config_test_utils import read_yaml_file from yawning_titan.config.agents.blue_agent_config import BlueAgentConfig def get_config_dict() -> Dict: - return read_yaml_file(TEST_BLUE_AGENT_CONFIG_PATH) + return read_yaml_file(TEST_BASE_CONFIG_PATH)["BLUE"] def test_read_valid_config(): @@ -19,10 +18,10 @@ def test_read_valid_config(): assert blue_agent.blue_max_deceptive_nodes == 2 # chance_to_immediately_discover_intrusion - assert blue_agent.blue_immediate_detection_chance + assert blue_agent.blue_immediate_detection_chance == 0.5 # chance_to_discover_intrusion_on_scan - assert blue_agent.blue_scan_detection_chance == 1 + assert blue_agent.blue_scan_detection_chance == 0.7 # chance_to_immediately_discover_intrusion_deceptive_node assert blue_agent.blue_deception_immediate_detection_chance == 1 @@ -40,13 +39,13 @@ def test_read_valid_config(): assert blue_agent.blue_discover_attack_source_if_not_detected is True # chance_to_discover_failed_attack - assert blue_agent.blue_chance_to_discover_source_failed == 1 + assert blue_agent.blue_chance_to_discover_source_failed == 0.5 # chance_to_discover_succeeded_attack_compromise_known - assert blue_agent.blue_chance_to_discover_source_succeed_known == 1 + assert blue_agent.blue_chance_to_discover_source_succeed_known == 0.3 # chance_to_discover_succeeded_attack_compromise_not_known - assert blue_agent.blue_chance_to_discover_source_succeed_unknown == 1 + assert blue_agent.blue_chance_to_discover_source_succeed_unknown == 0.1 # chance_to_discover_failed_attack_deceptive_node assert blue_agent.blue_chance_to_discover_source_deceptive_failed == 1 @@ -61,10 +60,10 @@ def test_read_valid_config(): assert blue_agent.blue_vuln_change_amount_make_safe == 0.4 # making_node_safe_gives_random_vulnerability - assert blue_agent.blue_make_safe_random_vuln is False + assert blue_agent.blue_make_safe_random_vuln is True # blue_uses_reduce_vulnerability - assert blue_agent.blue_reduce_vuln_action is False + assert blue_agent.blue_reduce_vuln_action is True # blue_uses_restore_node assert blue_agent.blue_restore_node_action is True @@ -76,16 +75,16 @@ def test_read_valid_config(): assert blue_agent.blue_scan_action is True # blue_uses_isolate_node - assert blue_agent.blue_isolate_action is False + assert blue_agent.blue_isolate_action is True # blue_uses_reconnect_node - assert blue_agent.blue_reconnect_action is False + assert blue_agent.blue_reconnect_action is True # blue_uses_do_nothing is False - assert blue_agent.blue_do_nothing_action is False + assert blue_agent.blue_do_nothing_action is True # blue_uses_deceptive_nodes - assert blue_agent.blue_deceptive_action is False + assert blue_agent.blue_deceptive_action is True # relocating_deceptive_nodes_generates_a_new_node assert blue_agent.blue_deceptive_node_make_new is True diff --git a/tests/unit_tests/config/agents/test_red_agent_config.py b/tests/unit_tests/config/agents/test_red_agent_config.py index 062416f3..56b94396 100644 --- a/tests/unit_tests/config/agents/test_red_agent_config.py +++ b/tests/unit_tests/config/agents/test_red_agent_config.py @@ -2,13 +2,13 @@ import pytest -from tests.unit_tests.config.agents import TEST_RED_AGENT_CONFIG_PATH -from tests.unit_tests.config.config_test_utils import read_yaml_file +from tests import TEST_BASE_CONFIG_PATH +from tests.config_test_utils import read_yaml_file from yawning_titan.config.agents.red_agent_config import RedAgentConfig def get_config_dict() -> Dict: - return read_yaml_file(TEST_RED_AGENT_CONFIG_PATH) + return read_yaml_file(TEST_BASE_CONFIG_PATH)["RED"] def test_read_valid_config(): @@ -36,10 +36,10 @@ def test_read_valid_config(): assert red_agent.red_naturally_spread is True # chance_to_spread_to_connected_node - assert red_agent.red_chance_to_spread_to_connected_node == 0.05 + assert red_agent.red_chance_to_spread_to_connected_node == 0.01 # chance_to_spread_to_unconnected_node - assert red_agent.red_chance_to_spread_to_unconnected_node == 0 + assert red_agent.red_chance_to_spread_to_unconnected_node == 0.005 # red_uses_spread_action assert red_agent.red_spread_action is False @@ -63,7 +63,7 @@ def test_read_valid_config(): assert red_agent.red_basic_attack_action is True # basic_attack_action_likelihood - assert red_agent.red_basic_attack_likelihood == 2 + assert red_agent.red_basic_attack_likelihood == 1 # red_uses_do_nothing_action assert red_agent.red_do_nothing_action is True @@ -84,13 +84,13 @@ def test_read_valid_config(): assert red_agent.red_zero_day_start_amount == 1 # days_required_for_zero_day - assert red_agent.red_zero_day_days_required_to_create == 4 + assert red_agent.red_zero_day_days_required_to_create == 10 # red_chooses_target_at_random - assert red_agent.red_targeting_random is True + assert red_agent.red_targeting_random is False # red_prioritises_connected_nodes - assert red_agent.red_targeting_prioritise_connected_nodes is False + assert red_agent.red_targeting_prioritise_connected_nodes is True # red_prioritises_un_connected_nodes assert red_agent.red_targeting_prioritise_unconnected_nodes is False diff --git a/tests/unit_tests/config/environment/__init__.py b/tests/unit_tests/config/environment/__init__.py index 71585c3b..e69de29b 100644 --- a/tests/unit_tests/config/environment/__init__.py +++ b/tests/unit_tests/config/environment/__init__.py @@ -1,22 +0,0 @@ -from typing import Final -import os -from pathlib import Path -from typing import Final - -from tests import TEST_CONFIG_PATH - -TEST_GAME_RULES_CONFIG_PATH: Final[Path] = Path( - os.path.join(TEST_CONFIG_PATH, "config_sections", "complete_game_rules_config.yaml") -) - -TEST_OBSERVATION_SPACE_CONFIG_PATH: Final[Path] = Path( - os.path.join(TEST_CONFIG_PATH, "config_sections", "complete_observation_space_config.yaml") -) - -TEST_RESET_CONFIG_PATH: Final[Path] = Path( - os.path.join(TEST_CONFIG_PATH, "config_sections", "complete_reset_config.yaml") -) - -TEST_REWARDS_CONFIG_PATH: Final[Path] = Path( - os.path.join(TEST_CONFIG_PATH, "config_sections", "complete_rewards_config.yaml") -) diff --git a/tests/unit_tests/config/environment/test_game_rules_config.py b/tests/unit_tests/config/environment/test_game_rules_config.py index 775f3572..bd6482ca 100644 --- a/tests/unit_tests/config/environment/test_game_rules_config.py +++ b/tests/unit_tests/config/environment/test_game_rules_config.py @@ -2,13 +2,13 @@ import pytest -from tests.unit_tests.config.config_test_utils import read_yaml_file -from tests.unit_tests.config.environment import TEST_GAME_RULES_CONFIG_PATH +from tests import TEST_BASE_CONFIG_PATH +from tests.config_test_utils import read_yaml_file from yawning_titan.config.environment.game_rules_config import GameRulesConfig def get_config_dict() -> Dict: - return read_yaml_file(TEST_GAME_RULES_CONFIG_PATH) + return read_yaml_file(TEST_BASE_CONFIG_PATH)["GAME_RULES"] def test_read_valid_config(): @@ -24,13 +24,13 @@ def test_read_valid_config(): assert game_rules.gr_loss_total_compromise is False - assert game_rules.gr_loss_pc_nodes_compromised is False + assert game_rules.gr_loss_pc_nodes_compromised is True assert game_rules.gr_loss_pc_node_compromised_pc == 0.8 assert game_rules.gr_number_of_high_value_targets == 1 - assert game_rules.gr_loss_hvt is True + assert game_rules.gr_loss_hvt is False assert game_rules.gr_loss_hvt_random_placement is False @@ -40,11 +40,11 @@ def test_read_valid_config(): assert game_rules.gr_num_entry_nodes == 3 - assert game_rules.gr_prefer_central_entry is True + assert game_rules.gr_prefer_central_entry is False assert game_rules.gr_prefer_edge_nodes is False - assert game_rules.gr_grace_period == 0 + assert game_rules.gr_grace_period == 3 @pytest.mark.parametrize( diff --git a/tests/unit_tests/config/environment/test_observation_space_config.py b/tests/unit_tests/config/environment/test_observation_space_config.py index bc8c2643..d5dfe4c7 100644 --- a/tests/unit_tests/config/environment/test_observation_space_config.py +++ b/tests/unit_tests/config/environment/test_observation_space_config.py @@ -2,13 +2,13 @@ import pytest -from tests.unit_tests.config.config_test_utils import read_yaml_file -from tests.unit_tests.config.environment import TEST_OBSERVATION_SPACE_CONFIG_PATH +from tests import TEST_BASE_CONFIG_PATH +from tests.config_test_utils import read_yaml_file from yawning_titan.config.environment.observation_space_config import ObservationSpaceConfig def get_config_dict() -> Dict: - return read_yaml_file(TEST_OBSERVATION_SPACE_CONFIG_PATH) + return read_yaml_file(TEST_BASE_CONFIG_PATH)["OBSERVATION_SPACE"] def test_read_valid_config(): @@ -28,7 +28,7 @@ def test_read_valid_config(): assert obs_space.obs_attack_targets is True - assert obs_space.obs_special_nodes is True + assert obs_space.obs_special_nodes is False assert obs_space.obs_red_agent_skill is True diff --git a/tests/unit_tests/config/environment/test_reset_config.py b/tests/unit_tests/config/environment/test_reset_config.py index b2c757de..a495da70 100644 --- a/tests/unit_tests/config/environment/test_reset_config.py +++ b/tests/unit_tests/config/environment/test_reset_config.py @@ -2,13 +2,13 @@ import pytest -from tests.unit_tests.config.config_test_utils import read_yaml_file -from tests.unit_tests.config.environment import TEST_RESET_CONFIG_PATH +from tests import TEST_BASE_CONFIG_PATH +from tests.config_test_utils import read_yaml_file from yawning_titan.config.environment.reset_config import ResetConfig def get_config_dict() -> Dict: - return read_yaml_file(TEST_RESET_CONFIG_PATH) + return read_yaml_file(TEST_BASE_CONFIG_PATH)["RESET"] def test_read_valid_config(): @@ -16,9 +16,9 @@ def test_read_valid_config(): assert reset_config.reset_random_vulns is False - assert reset_config.reset_move_hvt is True + assert reset_config.reset_move_hvt is False - assert reset_config.reset_move_entry_nodes is True + assert reset_config.reset_move_entry_nodes is False @pytest.mark.parametrize( diff --git a/tests/unit_tests/config/environment/test_rewards_config.py b/tests/unit_tests/config/environment/test_rewards_config.py index f91f33c6..06dc2789 100644 --- a/tests/unit_tests/config/environment/test_rewards_config.py +++ b/tests/unit_tests/config/environment/test_rewards_config.py @@ -2,13 +2,13 @@ import pytest -from tests.unit_tests.config.config_test_utils import read_yaml_file -from tests.unit_tests.config.environment import TEST_REWARDS_CONFIG_PATH +from tests import TEST_BASE_CONFIG_PATH +from tests.config_test_utils import read_yaml_file from yawning_titan.config.environment.rewards_config import RewardsConfig def get_config_dict() -> Dict: - return read_yaml_file(TEST_REWARDS_CONFIG_PATH) + return read_yaml_file(TEST_BASE_CONFIG_PATH)["REWARDS"] def test_read_valid_config(): @@ -20,7 +20,7 @@ def test_read_valid_config(): assert rewards_config.reward_end_multiplier is True - assert rewards_config.reward_reduce_negative_rewards is True + assert rewards_config.reward_reduce_negative_rewards is False assert rewards_config.reward_function == "standard_rewards" diff --git a/tests/unit_tests/config/game_config/test_game_mode_config.py b/tests/unit_tests/config/game_config/test_game_mode_config.py index ff037dda..cbb24fb2 100644 --- a/tests/unit_tests/config/game_config/test_game_mode_config.py +++ b/tests/unit_tests/config/game_config/test_game_mode_config.py @@ -4,8 +4,8 @@ import pytest -from tests import TEST_CONFIG_PATH -from tests.unit_tests.config.config_test_utils import read_yaml_file +from tests import TEST_BASE_CONFIG_PATH +from tests.config_test_utils import read_yaml_file from yawning_titan.config.agents.blue_agent_config import BlueAgentConfig from yawning_titan.config.agents.red_agent_config import RedAgentConfig from yawning_titan.config.environment.game_rules_config import GameRulesConfig @@ -17,7 +17,7 @@ def get_config_dict() -> Dict: - return read_yaml_file(Path(os.path.join(TEST_CONFIG_PATH, "base_config.yaml"))) + return read_yaml_file(TEST_BASE_CONFIG_PATH) def get_default_config_dict() -> Dict: @@ -25,7 +25,7 @@ def get_default_config_dict() -> Dict: def test_read_valid_path_and_valid_config(): - game_mode = GameModeConfig.create(os.path.join(TEST_CONFIG_PATH, "base_config.yaml")) + game_mode = GameModeConfig.create(TEST_BASE_CONFIG_PATH) assert game_mode.red_agent_config == RedAgentConfig.create(get_config_dict()["RED"]) assert game_mode.blue_agent_config == BlueAgentConfig.create(get_config_dict()["BLUE"]) diff --git a/tests/unit_tests/config/network_config/test_network_config.py b/tests/unit_tests/config/network_config/test_network_config.py index 90310c71..0c42555f 100644 --- a/tests/unit_tests/config/network_config/test_network_config.py +++ b/tests/unit_tests/config/network_config/test_network_config.py @@ -24,7 +24,7 @@ def test_config_properties(): def test_hvn_entry_node_matching(): with warnings.catch_warnings(record=True) as w: - network_config = NetworkConfig.create( + NetworkConfig.create( matrix=matrix, positions=node_positions, entry_nodes=["0"], diff --git a/yawning_titan/config/game_config/game_mode_config.py b/yawning_titan/config/game_config/game_mode_config.py index e5aac90c..8f169688 100644 --- a/yawning_titan/config/game_config/game_mode_config.py +++ b/yawning_titan/config/game_config/game_mode_config.py @@ -78,7 +78,6 @@ def create( settings = yaml.load(f, Loader=SafeLoader) except FileNotFoundError as e: msg = f"Configuration file does not exist: {settings_path}" - print(msg) # TODO: Remove once proper logging is setup _LOGGER.critical(msg, exc_info=True) raise e