-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathturmite.py
37 lines (31 loc) · 1.26 KB
/
turmite.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
import io
TURMITE = [[[1,2,1],[1,8,1]],[[1,2,1],[0,2,0]]]
# TURMITE = [[[1,8,1],[1,2,0]],[[1,4,1],[1,4,2]],[[0,1,0],[0,4,0]]]
SAVE_FILE = 'chaotic'
saveString = ''
for rot in range(4):
for s in range(len(TURMITE)):
for c in range(len(TURMITE[s])):
# New state must be specified state and cur rotation plus turn amount specified.
# No turn
if TURMITE[s][c][1] == 1:
turnAmount = 0
# Turn right
elif TURMITE[s][c][1] == 2:
turnAmount = 1
# U turn
elif TURMITE[s][c][1] == 4:
turnAmount = 2
# Turn left
elif TURMITE[s][c][1] == 8:
turnAmount = 3
newRot = rot + turnAmount
# Deal with overrotating
if newRot > 3:
newRot -= 4
# Get direction should move depending on new rotation
dirList = ['L','U','R','D']
direction = dirList[newRot]
saveString += (str(s*4+rot) + ',' + ('True' if c else 'False') + ',' + str(TURMITE[s][c][2]*4+newRot) + ',' + ('True' if TURMITE[s][c][0] else 'False') + ',' + direction + '\n')
with open(SAVE_FILE, 'w') as file:
file.write(saveString[:-1])