#2248 - synced wth dev
This commit is contained in:
@@ -343,55 +343,12 @@ class PrimaiteGame:
|
||||
obs_space = ObservationManager.from_config(observation_space_cfg, game)
|
||||
|
||||
# CREATE ACTION SPACE
|
||||
action_space_cfg["options"]["node_uuids"] = []
|
||||
action_space_cfg["options"]["application_uuids"] = []
|
||||
action_space_cfg["options"]["service_uuids"] = []
|
||||
|
||||
# if a list of nodes is defined, convert them from node references to node UUIDs
|
||||
for action_node_option in action_space_cfg.get("options", {}).pop("nodes", {}):
|
||||
if "node_ref" in action_node_option:
|
||||
node_uuid = game.ref_map_nodes[action_node_option["node_ref"]]
|
||||
action_space_cfg["options"]["node_uuids"].append(node_uuid)
|
||||
|
||||
if "applications" in action_node_option:
|
||||
node_application_uuids = []
|
||||
for application_option in action_node_option["applications"]:
|
||||
# TODO: fix inconsistency with node uuids and application uuids. The node object get added to
|
||||
# node_uuid, whereas here the application gets added by uuid.
|
||||
application_uuid = game.ref_map_applications[application_option["application_ref"]]
|
||||
node_application_uuids.append(application_uuid)
|
||||
action_space_cfg["options"]["application_uuids"].append(node_application_uuids)
|
||||
|
||||
else:
|
||||
action_space_cfg["options"]["application_uuids"].append([])
|
||||
|
||||
if "services" in action_node_option:
|
||||
node_service_uuids = []
|
||||
for service_option in action_node_option["services"]:
|
||||
service_uuid = game.ref_map_services[service_option["service_ref"]]
|
||||
node_service_uuids.append(service_uuid)
|
||||
action_space_cfg["options"]["service_uuids"].append(node_service_uuids)
|
||||
|
||||
else:
|
||||
action_space_cfg["options"]["service_uuids"].append([])
|
||||
|
||||
# Each action space can potentially have a different list of nodes that it can apply to. Therefore,
|
||||
# we will pass node_uuids as a part of the action space config.
|
||||
# However, it's not possible to specify the node uuids directly in the config, as they are generated
|
||||
# dynamically, so we have to translate node references to uuids before passing this config on.
|
||||
|
||||
if "action_list" in action_space_cfg:
|
||||
for action_config in action_space_cfg["action_list"]:
|
||||
if "options" in action_config:
|
||||
if "target_router_ref" in action_config["options"]:
|
||||
_target = action_config["options"]["target_router_ref"]
|
||||
action_config["options"]["target_router_uuid"] = game.ref_map_nodes[_target]
|
||||
|
||||
action_space = ActionManager.from_config(game, action_space_cfg)
|
||||
|
||||
# CREATE REWARD FUNCTION
|
||||
rew_function = RewardFunction.from_config(reward_function_cfg, game=game)
|
||||
|
||||
# OTHER AGENT SETTINGS
|
||||
agent_settings = AgentSettings.from_config(agent_cfg.get("agent_settings"))
|
||||
|
||||
# CREATE AGENT
|
||||
|
||||
Reference in New Issue
Block a user