-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinder_reverse.py
More file actions
64 lines (51 loc) · 1.79 KB
/
finder_reverse.py
File metadata and controls
64 lines (51 loc) · 1.79 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
from shape_util import *
###############################################################################
class ShapeReverseFinder:
def __init__(self, generator):
xshapes = generator.xshapes
yshapes = generator.yshapes
zshapes = generator.zshapes
xshapes.reverse()
yshapes.reverse()
zshapes.reverse()
self.gauges = generator.stabilizers
gauge_count = 0
# Choose the X shape
for xshape in xshapes:
#print "Considering " + str(xshape)
xvalid = True
for gauge in self.gauges:
xvalid = xvalid and (xshape.commutes_with(gauge))
if (not xvalid):
continue
for yshape in yshapes:
#print "Considering " + str(yshape)
if (yshape.commutes_with(xshape)):
continue
yvalid = True
for gauge in self.gauges:
yvalid = yvalid and (yshape.commutes_with(gauge))
if (not yvalid):
continue
ycontinue = False
for zshape in zshapes:
#print "Considering " + str(zshape)
if (zshape.commutes_with(yshape) or zshape.commutes_with(xshape)):
continue
zvalid = True
for gauge in self.gauges:
zvalid = zvalid and (zshape.commutes_with(gauge))
if (not zvalid):
continue
xshapes.remove(xshape)
yshapes.remove(yshape)
zshapes.remove(zshape)
gauge_count = gauge_count + 1
print "Adding X"+str(gauge_count)+": " + str(xshape)
print "Adding Y"+str(gauge_count)+": " + str(yshape)
print "Adding Z"+str(gauge_count)+": " + str(zshape)
self.gauges.extend([xshape, yshape, zshape])
ycontinue = True
break
if (ycontinue):
break