#2085: Get enum value data

This commit is contained in:
Nick Todd
2023-12-01 09:52:31 +00:00
parent 10d4b61c73
commit a073038ec0
2 changed files with 8 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
# import os import json
from typing import Any, Dict, Final, Optional, SupportsFloat, Tuple from typing import Any, Dict, Final, Optional, SupportsFloat, Tuple
import gymnasium import gymnasium
@@ -34,14 +34,15 @@ class PrimaiteGymEnv(gymnasium.Env):
state = self.game.get_sim_state() state = self.game.get_sim_state()
# Create state suitable for dumping to file. # Create state suitable for dumping to file.
dump_state = {self.game.episode_counter: {self.game.step_counter: state}} # dump_state = {self.game.episode_counter: {self.game.step_counter: state}}
# Dump to file # Dump to file
# if os.path.isfile(PRIMAITE_PATHS.episode_steps_log_file_path): # if os.path.isfile(PRIMAITE_PATHS.episode_steps_log_file_path):
with open(PRIMAITE_PATHS.episode_log_file_path, "a", encoding="utf-8") as f: with open(PRIMAITE_PATHS.episode_log_file_path, "a", encoding="utf-8") as f:
f.write(str(dump_state)) # f.write(str(dump_state))
f.write("\n=================\n") # f.write("\n=================\n")
f.flush() # f.flush()
json.dump(state, f)
self.game.update_agents(state) self.game.update_agents(state)

View File

@@ -109,8 +109,8 @@ class Service(IOSoftware):
""" """
state = super().describe_state() state = super().describe_state()
state["operating_state"] = self.operating_state.value state["operating_state"] = self.operating_state.value
state["health_state_actual"] = self.health_state_actual state["health_state_actual"] = self.health_state_actual.value
state["health_state_visible"] = self.health_state_visible state["health_state_visible"] = self.health_state_visible.value
return state return state
def stop(self) -> None: def stop(self) -> None: