From fb9013c61dce135d258a2c7f93ffa67334aae45f Mon Sep 17 00:00:00 2001 From: Joe Anderson Date: Wed, 10 Feb 2016 19:41:30 -0800 Subject: finish ooPuzzle.is_solved --- oo.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'oo.py') 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 -- cgit v1.2.3-70-g09d2