-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3x3Map.py
More file actions
269 lines (212 loc) · 6.96 KB
/
Copy path3x3Map.py
File metadata and controls
269 lines (212 loc) · 6.96 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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
from math import *
from array import *
from time import sleep
import sys
dice1 = ["A", "B", "C"]
dice2 = ["D", "E", "F"]
dice3 = ["G", "H", "I"]
allDice = [dice1, dice2, dice3]
dice = {}
for i, face1 in enumerate(dice1):
for j, face2 in enumerate(dice2):
for k, face3 in enumerate(dice3):
dice[i * 9 + j * 3 + k] = {"M": [], "F": [face1, face2, face3]}
InteractionTypes = {
tuple[1, 1, 0]: 6, # 1B2B3
tuple[1, 0, 0]: 3, # 1B3B2
tuple[0, 1, 0]: 3, # 2B1B3
tuple[0, 1, 1]: 6, # 2B3B1
tuple[1, 0, 1]: 6, # 3B1B2
tuple[0, 0, 1]: 3, # 3B2B1
}
OneB2B3 = 6
OneB3B2 = 3
TwoB1B3 = 3
TwoB3B1 = 6
ThreeB1B2 = 6
ThreeB2B1 = 3
OneBeatsTwo = 15
OneBeatsThree = 12
TwoBeatsOne = 12
TwoBeatsThree = 15
ThreeBeatsOne = 15
ThreeBeatsTwo = 12
dice[0]["M"] = [0, 1, 2]
print(
f"{dice[0]['F'][dice[0]['M'][0]]} beats {dice[0]['F'][dice[0]['M'][1]]} which beats {dice[0]['F'][dice[0]['M'][2]]}"
)
# class node:
# def __init__(self, name):
# self.name = name
# self.leftInteractions = []
# self.rightInterations = []
# def addInteration(self, node, direction):
# if direction == "left":
# self.leftInteractions.append(node)
# elif direction == "right":
# self.rightInterations.append(node)
# def getInteraction(self, direction):
# if direction == "left":
# return self.leftInteractions
# elif direction == "right":
# return self.rightInterations
# def removeInteraction(self, node, direction):
# if direction == "left":
# self.leftInteractions.remove(node)
# elif direction == "right":
# self.rightInterations.remove(node)
# def __str__(self):
# return self.name
# Ad = node("A")
# Bd = node("B")
# Cd = node("C")
# Dd = node("D")
# Ed = node("E")
# Fd = node("F")
# Gd = node("G")
# Hd = node("H")
# Id = node("I")
def setsThatContain(first, second):
def getDiceRange(diceInput):
if diceInput[0] == 0:
returnRange = list(range(diceInput[1] * 9, diceInput[1] * 9 + 9))
elif diceInput[0] == 1:
returnRange = []
returnRange.extend(list(range(diceInput[1] * 3, diceInput[1] * 3 + 3)))
returnRange.extend(list(range(diceInput[1] * 3 + 9, diceInput[1] * 3 + 12)))
returnRange.extend(
list(range(diceInput[1] * 3 + 18, diceInput[1] * 9 + 21))
)
elif diceInput[0] == 2:
returnRange = list(range(diceInput[1], diceInput[1] + 25, 3))
return returnRange
for i, dice in enumerate(allDice):
if first in dice:
firstDice = [i, dice.index(first)]
if second in dice:
secondDice = [i, dice.index(second)]
set1 = set(getDiceRange(firstDice))
set2 = set(getDiceRange(secondDice))
returnList = list(set1.intersection(set2))
returnList.sort()
return returnList
testVar = setsThatContain("A", "F")
print(testVar)
DiceInteractions = [[None] * 27 for i in range(3)]
DiceInteractions[0][0] = 1
DiceInteractions[1][0] = 1
DiceInteractions[2][0] = 0
def updateInteractions(interactionRow, interactionColumn):
global DiceInteractions
# Get the indexes of the dice face combinations that contain the interacting faces
overlap = setsThatContain(
dice[interactionRow]["F"][interactionColumn],
dice[interactionRow]["F"][interactionColumn - 2],
)
# Iterate through the list of indexes and set the interaction to the same as the first
for i in overlap:
DiceInteractions[interactionColumn][i] = DiceInteractions[interactionColumn][
interactionRow
]
def checkInteractions():
for i in range(27):
for j in range(3):
if DiceInteractions[j][i] != None:
updateInteractions(i, j)
def checkBucket(interactionRow):
if interactionRow == [1, 1, 0]:
return "OneB2B3"
elif interactionRow == [1, 0, 0]:
return "OneB3B2"
elif interactionRow == [0, 1, 0]:
return "TwoB1B3"
elif interactionRow == [0, 1, 1]:
return "TwoB3B1"
elif interactionRow == [1, 0, 1]:
return "ThreeB1B2"
elif interactionRow == [0, 0, 1]:
return "ThreeB2B1"
def checkForSolutions(printSolutions=False):
updateCount = 0
while updateCount <= 1:
for i in range(27):
noneCount = 0
noneIndex = None
for j in range(3):
if DiceInteractions[j][i] == None:
noneIndex = j
noneCount += 1
if noneCount == 0:
# get the type of interaction and see if we can afford it from the interaction buckets
# if a bucket runs out of room, go back to the previous branch point and try something else
pass
elif noneCount == 1:
tempSet = {
DiceInteractions[j][i],
DiceInteractions[j - 1][i],
DiceInteractions[j - 2][i],
}
tempSet.remove(None)
if len(tempSet) == 1:
if tempSet.pop() == 1:
DiceInteractions[noneIndex][i] = 0
else:
DiceInteractions[noneIndex][i] = 1
checkInteractions()
updateCount = 0
break
updateCount += 1
checkInteractions()
checkForSolutions()
DiceInteractions[0][17] = 0
checkInteractions()
checkForSolutions()
DiceInteractions[1][17] = 0
checkInteractions()
checkForSolutions()
DiceInteractions[2][17] = 1
checkInteractions()
checkForSolutions()
DiceInteractions[0][8] = 0
checkInteractions()
checkForSolutions()
DiceInteractions[0][9] = 1
checkInteractions()
checkForSolutions()
DiceInteractions[2][26] = 1
checkInteractions()
checkForSolutions()
DiceInteractions[2][1] = 0
checkInteractions()
checkForSolutions()
def branch(value):
updateCount = 0
while updateCount <= 1:
for i in range(27):
noneCount = 0
noneIndex = None
for j in range(3):
if DiceInteractions[j][i] == None:
noneIndex = j
noneCount += 1
if noneCount == 1:
tempSet = {
DiceInteractions[j][i],
DiceInteractions[j - 1][i],
DiceInteractions[j - 2][i],
}
tempSet.remove(None)
if len(tempSet) == 2:
DiceInteractionsCopy = DiceInteractions.copy()
branch(1)
# DiceInteractions[noneIndex][i] = 0
branch(2)
# DiceInteractions[noneIndex][i] = 1
checkInteractions()
updateCount = 0
break
for column in DiceInteractions:
for row in column:
print(f"{str(row): <5}", end="")
print()
print(InteractionTypes[tuple[0, 1, 1]])