From 7403b36992547841851e2ed405a5500a82416919 Mon Sep 17 00:00:00 2001 From: Joe Anderson Date: Tue, 23 Feb 2016 18:52:19 -0800 Subject: plans for a go module --- oo.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'oo.py') diff --git a/oo.py b/oo.py index c8a6444..d9a153e 100644 --- a/oo.py +++ b/oo.py @@ -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) -- cgit v1.2.3-70-g09d2