diff options
author | Joe Anderson <jandew+dev@gmail.com> | 2016-02-23 18:52:19 -0800 |
---|---|---|
committer | Joe Anderson <jandew+dev@gmail.com> | 2016-02-23 18:53:45 -0800 |
commit | 7403b36992547841851e2ed405a5500a82416919 (patch) | |
tree | 8186be37117f9dc0a6f8f5a380d158d65be68c07 /oo.py | |
parent | 2b8ae2b1e120f7ee2b65f901b29d458c792840b8 (diff) | |
download | oo-7403b36992547841851e2ed405a5500a82416919.tar.gz oo-7403b36992547841851e2ed405a5500a82416919.zip |
plans for a go module
Diffstat (limited to 'oo.py')
-rw-r--r-- | oo.py | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -876,6 +876,35 @@ class ooPlay: elif self.xpos < self.max_xpos: self.xpos += 1 +class ooStudy(): + """Studies oo puzzles of a particular size. + + This class is not intended to be used. It is far too slow. + Instead, it is intended to be ported to a faster language. + """ + + def __init__(self, X, Y, toroidal=False): + self.X = X + self.Y = Y + self.toroidal = toroidal + self.puzzles = [] + + def __call__(self): + """Study each possible game id.""" + X = self.X + Y = self.Y + if self.toroidal: upper_bound = 2**( 2*X*Y ) + else: upper_bound = 2**( (X-1)*Y + X*(Y-1) ) + for game_id in range(upper_bound): + new_puzzle = ooPuzzle(X, Y, + game_id=game_id, toroidal=self.toroidal) + for puzzle in self.puzzles: + if puzzle.pieces == new_puzzle.pieces: + puzzle.equivalent_ids.append(game_id) + return + new_puzzle.equivalent_ids = [] + self.puzzles.append(new_puzzle) + def main(): curses.wrapper(ooPlay) |