-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog_episode.py
More file actions
34 lines (29 loc) 路 1.04 KB
/
Copy pathlog_episode.py
File metadata and controls
34 lines (29 loc) 路 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
import csv
from datetime import datetime
def log_episode(episode_number, total_reward, actions_taken, fields_filled, submitted):
if not os.path.exists("logs"):
os.makedirs("logs")
now = datetime.now()
filename = f"logs/agent_log_{now.strftime('%Y-%m-%d')}.csv"
file_exists = os.path.isfile(filename)
with open(filename, mode='a', newline='', encoding='utf-8') as f:
writer = csv.writer(f)
# Pokud soubor neexistuje, zap铆拧eme hlavi膷ku
if not file_exists:
writer.writerow([
"膶as",
"Epizoda",
"Celkov谩 odm臎na",
"Po膷et vypln臎n媒ch pol铆",
"Odesl谩no",
"Akce"
])
writer.writerow([
now.strftime('%Y-%m-%d %H:%M:%S'),
episode_number,
total_reward,
str(fields_filled),
"ANO" if submitted else "NE",
", ".join(actions_taken) if isinstance(actions_taken, (list, tuple)) else str(actions_taken)
])