forked from HelmerNylen/mkbsc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemory.py
58 lines (51 loc) · 1.64 KB
/
memory.py
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
from mkbsc import MultiplayerGame, iterate_until_isomorphic, \
export, to_string, from_string, to_file, from_file
#states
L = ["start", 0, 1, "win", "lose"]
#initial state
L0 = "start"
#action alphabet
Sigma = (("0", "t", "-1"), ("0", "t", "-1"))
#action labeled transitions
Delta = [
("start", ("-1", "-1"), "lose"),
("start", ("-1", "0"), 0),
("start", ("-1", "t"), 1),
("start", ("0", "-1"), 0),
("start", ("0", "0"), 0),
("start", ("0", "t"), 0),
("start", ("t", "-1"), 1),
("start", ("t", "0"), 0),
("start", ("t", "t"), 1),
(0, ("-1", "-1"), "lose"),
(0, ("-1", "0"), 0),
(0, ("0", "-1"), 0),
(0, ("0", "0"), 0),
(0, ("-1", "t"), 1),
(0, ("0", "t"), 1),
(0, ("t", "-1"), 1),
(0, ("t", "0"), 1),
(0, ("t", "t"), 1),
(1, ("-1", "-1"), "win"),
(1, ("-1", "0"), 0),
(1, ("-1", "t"), 0),
(1, ("0", "-1"), 0),
(1, ("0", "0"), 0),
(1, ("0", "t"), 0),
(1, ("t", "-1"), 0),
(1, ("t", "0"), 0),
(1, ("t", "t"), 0),
]
#observation partitioning
Obs = [
[["start"], [0, 1], ["win"], ["lose"]],
[["start"], [0, 1], ["win"], ["lose"]]
]
#G is a MultiplayerGame-object, and so are GK and GK0
G = MultiplayerGame.create(L, L0, Sigma, Delta, Obs)
GK = G.KBSC()
export(GK, "memory_GK")
(log2, GK2, iso_type2) = iterate_until_isomorphic(G, limit=-1, print_size=False, verbose=True)
export(GK2, "memory_GK2")
print(log2, GK2, iso_type2)