-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.py
More file actions
36 lines (32 loc) · 925 Bytes
/
util.py
File metadata and controls
36 lines (32 loc) · 925 Bytes
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
35
from actions import *
def print_values(V, g):
for i in range(g.rows):
print("------" * g.cols)
for j in range(g.cols):
v = V.get((i,j), 0)
if v >= 0:
print(" %.2f|" % v, end="")
else:
print("%.2f|" % v, end="") # - sign takes up an extra space
print("")
print("------" * g.cols + "\n")
def print_policy(P, g):
for i in range(g.rows):
print("------" * g.cols)
for j in range(g.cols):
a = ' '
try:
a = ACTION_SYMBOLS[P.get((i,j), ' ')]
except:
pass
print(" %s |" % a, end="")
print("")
print("------" * g.cols + "\n")
def max_dict(d):
max_key = None
max_val = float('-inf')
for k, v in d.items():
if v > max_val:
max_val = v
max_key = k
return max_key, max_val