Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormantaraya36 <mantaraya36@gmail.com>2009-05-12 14:13:57 (GMT)
committer mantaraya36 <mantaraya36@gmail.com>2009-05-12 14:13:57 (GMT)
commite70b6bb86d4abdb34532055e948a3b0560e303e3 (patch)
treebdfccfe1652739917d1cefbe8cac87dca8b03d77
parentd48b46f8b1eb97d6a8914d3a1e52a910e1b6c560 (diff)
Fixed recursion bug in word search algorithmHEADmaster
-rw-r--r--wordhunt.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/wordhunt.py b/wordhunt.py
index dfe0ea9..eb40646 100644
--- a/wordhunt.py
+++ b/wordhunt.py
@@ -159,15 +159,15 @@ class wordhunt():
for transform in matrix:
new_row = row + transform[0]
new_column = column + transform[1]
- if new_row < 0 or new_column < 0 or \
- new_row > 3 or new_column > 3 or \
- used[new_row][new_column] == 1:
- pass
- elif self.dice[self.facedie[new_row][new_column]][self.face[new_row][new_column]] == letter:
+ if new_row >= 0 and new_column >= 0 and \
+ new_row < 4 and new_column < 4 and \
+ used[new_row][new_column] != 1 and \
+ self.dice[self.facedie[new_row][new_column]][self.face[new_row][new_column]] == letter:
used_copy = used
used_copy[new_row][new_column] = 1
- return [[new_row, new_column]] + \
- self.find_word(new_word, new_row, new_column, used_copy)
+ new = self.find_word(new_word, new_row, new_column, used_copy)
+ if new != [False]:
+ return [[new_row, new_column]] + new
return [False]
def word_is_valid(self,word):
@@ -218,7 +218,8 @@ class wordhunt():
for position in word_chain:
self.grid.set_color(gtk.gdk.Color(100, 100, 60000),
position[0], position[1])
- gobject.source_remove(self.highlight_timer)
+ if self.highlight_timer > 0:
+ gobject.source_remove(self.highlight_timer)
self.highlight_timer = gobject.timeout_add(5000, self.unmark_word)
return