-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTM_clauses.py
103 lines (88 loc) · 2.45 KB
/
TM_clauses.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import csv
# shape_y = 6
# shape_x = 7
"""
def Rearrange(WrongList):
output = []
for column in range(shape_y):
temp = shape_y - column
for row in range(shape_x):
index = (shape_y * row) + temp
# print(index)
output.append(WrongList[index - 1])
return output
"""
def transform(input):
# print(input)
if (int(input[0]) and int(input[2])) or (int(input[1]) and int(input[3])):
return "Fa"
elif int(input[0]) and int(input[1]):
return "+#"
elif int(input[2]) and int(input[3]):
return "-#"
elif int(input[0]):
return "+X"
elif int(input[1]):
return "+O"
elif int(input[2]):
return "-x"
elif int(input[3]):
return "-o"
else:
return "*#"
def GetOutput(tm, tm_class, clause):
output = []
for i in range(84 * 2):
outputbit = tm.ta_action(tm_class, clause, i)
output.append(outputbit)
return output
def PrintClause(clause):
for i in clause:
print(i)
def Align(tm, tm_class, clause):
output = GetOutput(tm, tm_class, clause)
nonNegated = output[:int(len(output) / 2)]
negated = output[int(len(output) / 2):]
xbit = nonNegated[:int(len(nonNegated) / 2)]
obit = nonNegated[int(len(nonNegated) / 2):]
nxbit = negated[:int(len(negated) / 2)]
nobit = negated[int(len(negated) / 2):]
board = []
for i in range(42):
print(str(xbit[i]) + str(obit[i]) + str(nxbit[i]) + str(nobit[i]))
if i < 41:
print(",")
else:
print("\n")
def PrintClass(Ts, Class, clauses):
for i in range(clauses):
Align(Ts, Class, i)
# resultclauses.writelines(clausesres)
# print(clausesres)
# PrintClause(action)
# PrintClass(tm, 1, clauses)
"""
Data/2D1218-0437clauses0.csv
Data/2D1218-0437clauses1.csv
Data/2D1218-0437clauses2.csv
"""
with open("Data/2D1218-0437clauses2.csv") as f:
reader = csv.reader(f)
table = []
for row in reader:
table.append(row)
index = 1
for index in range(1000):
if index % 2:
print("---| Negated |---")
else:
print("---| Non-Negated |---")
print(table[index])
for i in range(6):
temp = ""
for j in range(7):
temp = temp + transform(table[index][i * 7 + j]) + " "
# print(i*7+j)
print(temp)
print("\n")
index = index + 1