Make db admin reward persistent

This commit is contained in:
Marek Wolan
2024-03-01 16:02:27 +00:00
parent 10a4053887
commit ed01293b86
4 changed files with 11 additions and 10 deletions

View File

@@ -263,11 +263,13 @@ class GreenAdminDatabaseUnreachablePenalty(AbstractReward):
:type state: Dict
"""
db_state = access_from_nested_dict(state, self.location_in_state)
if db_state is NOT_PRESENT_IN_STATE or "connections_status" not in db_state:
if db_state is NOT_PRESENT_IN_STATE or "last_connection_successful" not in db_state:
_LOGGER.debug(f"Can't calculate reward for {self.__class__.__name__}")
connections_status = db_state["connections_status"]
if False in connections_status:
last_connection_successful = db_state["last_connection_successful"]
if last_connection_successful is False:
return -1.0
elif last_connection_successful is True:
return 1.0
return 0
@classmethod

View File

@@ -296,7 +296,7 @@ class PrimaiteGame:
if service_type == "DatabaseService":
if "options" in service_cfg:
opt = service_cfg["options"]
new_service.password = opt.get("backup_server_ip", None)
new_service.password = opt.get("db_password", None)
new_service.configure_backup(backup_server=IPv4Address(opt.get("backup_server_ip")))
if service_type == "FTPServer":
if "options" in service_cfg: