[gnome-games/applygsoc2009: 40/76] Make show-hint work
- From: Pablo Castellano <pablog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/applygsoc2009: 40/76] Make show-hint work
- Date: Mon, 6 Sep 2010 02:50:35 +0000 (UTC)
commit a724404f89a6d7c0e5e5cdc93c220a0192b30a83
Author: Pablo Castellano <pablog src gnome org>
Date: Thu Aug 26 15:58:31 2010 +0200
Make show-hint work
gnome-sudoku/src/lib/gsudoku.py | 23 +++--------------------
gnome-sudoku/src/lib/main.py | 3 ++-
2 files changed, 5 insertions(+), 21 deletions(-)
---
diff --git a/gnome-sudoku/src/lib/gsudoku.py b/gnome-sudoku/src/lib/gsudoku.py
index 252397e..f168ed2 100644
--- a/gnome-sudoku/src/lib/gsudoku.py
+++ b/gnome-sudoku/src/lib/gsudoku.py
@@ -304,6 +304,9 @@ class NotesModel:
for y in range(self._group_size):
self._update_hint_for_entry(x, y)
+ def show_hint(self, x, y):
+ self._update_hint_for_entry(x, y)
+
def _update_hint_for_entry(self, x, y):
# no need to show anything if it's already filled, being correct or not
if self._model.get_value(x, y):
@@ -374,24 +377,6 @@ class SudokuModel:
for observer in self._observers:
observer.puzzle_finished_cb()
- def show_hint (self):
- min_options = 10;
- squares = []
- for x in xrange(9):
- for y in xrange(9):
- if self.grid._get_(x, y) != 0:
- continue
- n_options = len(self.grid.possible_values(x, y))
- if n_options < min_options:
- squares = [(x, y)]
- min_options = n_options
- elif n_options == min_options:
- squares.append((x, y))
-
- if len(squares) != 0:
- self.set_hint_square(random.choice(squares))
- self.hints += 1
-
def reset_grid (self):
'''Remove all untracked values from the grid
@@ -545,7 +530,6 @@ class SudokuModel:
result.extend(old_conflicts)
result.extend(new_conflicts)
- print self.grid
self._signal_observers(result)
self._check_for_completeness()
@@ -560,7 +544,6 @@ class SudokuModel:
def _find_new_conflicts(self, x, y, value):
result = []
new_conflicts = self.grid.find_conflicts(x, y, value)
- print new_conflicts
if new_conflicts:
self.__error_pairs__[(x, y)] = new_conflicts
for entry in new_conflicts:
diff --git a/gnome-sudoku/src/lib/main.py b/gnome-sudoku/src/lib/main.py
index 83d7d14..6d16f4e 100644
--- a/gnome-sudoku/src/lib/main.py
+++ b/gnome-sudoku/src/lib/main.py
@@ -480,7 +480,8 @@ class UI (gconf_wrapper.GConfWrapper):
self.start_dancer()
def show_hint_cb (self, *args):
- self.gsd.show_hint()
+ current = self._main_grid_vew.get_focus()
+ self._notes_model.show_hint(current.x, current.y)
def auto_hint_cb (self, action):
self._notes_model.toggle_auto_hint(action.get_active())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]