summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Anderson <jandew+dev@gmail.com>2016-02-10 19:41:30 -0800
committerJoe Anderson <jandew+dev@gmail.com>2016-02-10 19:41:30 -0800
commitfb9013c61dce135d258a2c7f93ffa67334aae45f (patch)
treec9a46d31cbe88cfe374bfc6ca3fb2402273a0925
parentb54325a48b1afb8d5f7a25e32afc062aa82aaf17 (diff)
downloadoo-fb9013c61dce135d258a2c7f93ffa67334aae45f.tar.gz
oo-fb9013c61dce135d258a2c7f93ffa67334aae45f.zip
finish ooPuzzle.is_solved
-rw-r--r--oo.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/oo.py b/oo.py
index 67bf51b..4f5bbc6 100644
--- a/oo.py
+++ b/oo.py
@@ -204,7 +204,29 @@ class ooPuzzle:
# check boundary edge pairs
- #TODO: check boundary edges dependent on toroidal
+ for y in range(self.Y):
+ l_piece = self.pieces [self.X-1, y]
+ l_orient = self.orients[self.X-1, y]
+ r_piece = self.pieces [0, y]
+ r_orient = self.orients[0, y]
+ l_edge = self.PIECE_ORIENT_TO_EDGES[l_piece, l_orient][2]
+ r_edge = self.PIECE_ORIENT_TO_EDGES[r_piece, r_orient][0]
+ if self.toroidal:
+ if l_edge != r_edge: return False
+ else:
+ if l_edge or r_edge: return False
+
+ for x in range(self.X):
+ u_piece = self.pieces [x, self.Y-1]
+ u_orient = self.orients[x, self.Y-1]
+ d_piece = self.pieces [x, 0]
+ d_orient = self.orients[x, 0]
+ u_edge = self.PIECE_ORIENT_TO_EDGES[u_piece, u_orient][3]
+ d_edge = self.PIECE_ORIENT_TO_EDGES[d_piece, d_orient][1]
+ if self.toroidal:
+ if u_edge != d_edge: return False
+ else:
+ if u_edge or d_edge: return False
return True