~ubuntu-branches/ubuntu/precise/gnome-games/precise-proposed

« back to all changes in this revision

Viewing changes to gnome-sudoku/src/lib/sudoku.py

  • Committer: Package Import Robot
  • Author(s): Rodrigo Moya
  • Date: 2011-05-30 13:32:04 UTC
  • mfrom: (1.3.4)
  • mto: (163.1.3 precise)
  • mto: This revision was merged to the branch mainline in revision 143.
  • Revision ID: package-import@ubuntu.com-20110530133204-celaq1v1dsxc48q1
Tags: upstream-3.0.2
ImportĀ upstreamĀ versionĀ 3.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
467
467
        guess_obj = Guess(least[0][0], least[0][1], guess)
468
468
        if self.breadcrumbs:
469
469
            self.breadcrumbs[-1].children.append(guess_obj)
470
 
        self.current_guess = None #reset (we're tracked via guess.child)
 
470
        self.current_guess = None #reset (we're tracked via guess.get_child())
471
471
        self.add(least[0][0], least[0][1], guess)
472
472
        self.current_guess = guess_obj # (All deterministic additions
473
473
                                       # get added to our
683
683
 
684
684
 
685
685
class DifficultyRating:
686
 
 
687
 
    very_hard = _('Very hard')
688
 
    hard = _('Hard')
689
 
    medium = _('Medium')
690
 
    easy = _('Easy')
691
 
 
692
686
    very_hard_range = (0.75, 10)
693
687
    hard_range = (0.6, 0.75)
694
688
    medium_range = (0.45, 0.6)
700
694
                  'easy':easy_range}
701
695
 
702
696
    ordered_categories = ['easy', 'medium', 'hard', 'very hard']
703
 
    label_by_cat = {'easy':easy,
704
 
                    'medium':medium,
705
 
                    'hard':hard,
706
 
                    'very hard':very_hard}
707
697
 
708
698
    def __init__ (self,
709
699
                  fill_must_fillables,
768
758
                          ]:
769
759
            print name, ': ', stat
770
760
 
771
 
    def value_string (self):
772
 
        if self.value > self.very_hard_range[0]:
773
 
            return _(self.very_hard)
774
 
        elif self.value > self.hard_range[0]:
775
 
            return _(self.hard)
776
 
        elif self.value > self.medium_range[0]:
777
 
            return _(self.medium)
778
 
        else:
779
 
            return _(self.easy)
780
 
 
781
761
    def value_category (self):
782
762
        """Get category string, without i18n or capitalization
783
763
 
792
772
        else:
793
773
            return 'easy'
794
774
 
795
 
def get_difficulty_category_name (diff_float):
796
 
    return DifficultyRating.label_by_cat.get(
797
 
        get_difficulty_category(diff_float),
798
 
        '?'
799
 
        )
800
 
 
801
775
def get_difficulty_category (diff_float):
802
776
    for category, range in DifficultyRating.categories.items():
803
777
        if range[0] <= diff_float < range[1]: