Merged PR 61: Fix minor logic errors in main script

This PR fixes some minor issues that I found in the main.py script. Namely:

1. The first observation was always all zeroes when using a generic agent. This is because the `update_environment_obs()` method is not called automatically and is only called by `env.reset()`.
2. The config yaml is never closed as the close function of the file reader was only referenced but never called.

Related work items: #1441
This commit is contained in:
Marek Wolan
2023-06-06 15:02:40 +00:00

View File

@@ -25,6 +25,7 @@ from primaite.transactions.transactions_to_file import write_transaction_to_file
def run_generic():
"""Run against a generic agent."""
for episode in range(0, config_values.num_episodes):
env.reset()
for step in range(0, config_values.num_steps):
# Send the observation space to the agent to get an action
# TEMP - random action for now
@@ -42,7 +43,6 @@ def run_generic():
time.sleep(config_values.time_delay / 1000)
# Reset the environment at the end of the episode
env.reset()
env.close()
@@ -375,7 +375,7 @@ logging.info("Saving transaction logs...")
write_transaction_to_file(transaction_list)
config_file_main.close
config_file_main.close()
print("Finished")
logging.info("Finished")