diff options
author | Walter Bender <walter@walter-laptop.(none)> | 2009-10-09 06:10:52 (GMT) |
---|---|---|
committer | Walter Bender <walter@walter-laptop.(none)> | 2009-10-09 06:10:52 (GMT) |
commit | f4e9be649585977bda66bcdafda9f25fb894c38d (patch) | |
tree | 8d8aabf8c340e3ddd1a25b2fc8b65122e8f4cd8a /orientation.py | |
parent | d692af30c7dfa822bd9b049a01d27ac706254f0a (diff) |
speed up of solver code
Diffstat (limited to 'orientation.py')
-rw-r--r-- | orientation.py | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/orientation.py b/orientation.py index d31579c..1e994e1 100644 --- a/orientation.py +++ b/orientation.py @@ -4,11 +4,11 @@ # initial position # # Since the gender of a neighboring edge has to be opposite, the following -# constraints apply: +# constraints apply (top,left): # -ORIENTATION_CONSTRAINTS = [(-1,-1),(0,-1),(1,-1), \ - (-1,0), (3,1), (4,2), \ - (-1,3), (6,4), (7,5)] +# ORIENTATION_CONSTRAINTS = [(-1,-1),(-1,0),(-1,1), \ +# (0,-1), (1,3), (2,4), \ +# (3,-1), (4,6), (5,7)] # where the pairs are (left dependency, top dependency) # and -1 indicates an edge, i.e., no dpendency # @@ -19,11 +19,11 @@ ROTS = (0,90,180,270) # constraint tables LEFT = {0:(0,270),90:(90,180),180:(90,180),270:(0,270)} -TOP = {0:(0,90),90:(0,90),180:(180,270),270:(180,270)} +TOP = {0:(0,90),90:(0,90),180:(180,270),270:(180,270)} TOP_LEFT = [{0:0,90:90,180:90,270:0}, \ - {0:0,90:90,180:90,270:0}, \ - {0:270,90:180,180:180,270:270}, \ - {0:270,90:180,180:180,270:270}] + {0:0,90:90,180:90,270:0}, \ + {0:270,90:180,180:180,270:270}, \ + {0:270,90:180,180:180,270:270}] def get_rotation_sets(): @@ -52,8 +52,8 @@ def get_rotation_sets(): # fourth tile is constrained to the top only (16 groups of 2x2 for i in range(16): for j in range(2): - rot_sets[i*4+j].append(TOP[rot_sets[i*4+j][1]][0]) - rot_sets[i*4+j+2].append(TOP[rot_sets[i*4+j+2][1]][1]) + rot_sets[i*4+j].append(TOP[rot_sets[i*4+j][0]][0]) + rot_sets[i*4+j+2].append(TOP[rot_sets[i*4+j+2][0]][1]) # fifth tile is constrained by top and left # sixth tile is constrained by top and left @@ -63,8 +63,8 @@ def get_rotation_sets(): # seventh tile is constrained to the top only (32 groups of 1x2) for i in range(32): - rot_sets[i*2].append(TOP[rot_sets[i*2][4]][0]) - rot_sets[i*2+1].append(TOP[rot_sets[i*2+1][4]][1]) + rot_sets[i*2].append(TOP[rot_sets[i*2][3]][0]) + rot_sets[i*2+1].append(TOP[rot_sets[i*2+1][3]][1]) # eigth tile is constrained by top and left # ninth tile is constrained by top and left @@ -72,4 +72,7 @@ def get_rotation_sets(): rot_sets[i].append(TOP_LEFT[ROTS.index(rot_sets[i][4])][rot_sets[i][6]]) rot_sets[i].append(TOP_LEFT[ROTS.index(rot_sets[i][5])][rot_sets[i][7]]) + # for i in range(64): + # print str(i) + ": " + str(rot_sets[i]) + return rot_sets |