feat: time

This commit is contained in:
snsd0805 2024-04-09 21:32:39 +08:00
parent 3fcd55923b
commit f3afe492cf
Signed by: snsd0805
GPG Key ID: 569349933C77A854

11
game.py
View File

@ -650,6 +650,9 @@ class Game:
agentIndex = self.startingIndex
numAgents = len(self.agents)
time_sum = 0
counter = 0
while not self.gameOver:
# Fetch the next agent
agent = self.agents[agentIndex]
@ -729,7 +732,13 @@ class Game:
self.unmute()
return
else:
start = time.time()
action = agent.getAction(observation)
stop = time.time()
time_sum += (stop-start)
counter += 1
self.unmute()
# Execute the action
@ -762,6 +771,8 @@ class Game:
if _BOINC_ENABLED:
boinc.set_fraction_done(self.getProgress())
print("TIME:", time_sum/counter)
# inform a learning agent of the game result
for agentIndex, agent in enumerate(self.agents):
if "final" in dir(agent):