Example #1
0
 def find_rule1(self, board, chain):
     '''Continuous Alternating Nice Loop - Weak link => off-chain candidates in same unit are OFF '''
     for value in chain.root.c:
         for leaf in chain.paths[value].get_leaves():
             if chain.paths[value].state == leaf.state and leaf.cell == chain.root:
                 solved_sets = []
                 for node in leaf.supernodes():
                     if node.parent != None and share_unit(node.cell,node.parent.cell):
                         removed = [cell for cell in visible_intersection(board,[node.cell,node.parent.cell]) if cell.check_remove(set([value]))]
                         if removed:
                             solved_sets += [SolvedSet(XCycleSolver(0, Solver.TYPE1), [node.cell, node.parent.cell], set([value]), removed)]
                 return solved_sets
     return []
Example #2
0
 def find_rule6(self, board, chain):
     ''' same color in a unit opposite color in cell '''
     for v in chain.root.c:
         possible = chain.paths[v].subnodes()
         for i,node1 in enumerate(possible):
             solved_sets = []
             for j,node2 in enumerate(possible):
                 if j > i and node1.cell != node2.cell and node1.value != node2.value and node1.state != node2.state and share_unit(node1.cell,node2.cell):
                     if node1.value in node2.cell.c:
                         solved_sets += [SolvedSet(Medusa3DSolver(0, Solver.TYPE6), [node1.cell, node2.cell], set([node1.value]), [node2.cell])]
                     if node2.value in node1.cell.c:
                         solved_sets += [SolvedSet(Medusa3DSolver(0, Solver.TYPE6), [node1.cell, node2.cell], set([node2.value]), [node1.cell])]
             return solved_sets
     return []
Example #3
0
 def find_rule2(self, board, chain):
     ''' twice in a unit '''
     for v in chain.root.c:
         possible = chain.paths[v].subnodes()
         for i,node1 in enumerate(possible):
             for j,node2 in enumerate(possible):
                 if j > i and node1.cell != node2.cell and node1.value == node2.value and node1.state == node2.state and share_unit(node1.cell,node2.cell):
                     solved_sets = []
                     for node in set(chain.paths[v].subnodes(state = node1.state)):
                         solved_sets += [SolvedSet(Medusa3DSolver(0, Solver.TYPE2), [node1.cell, node2.cell], set([node.value]), [node.cell])]
                     return solved_sets
     return []
Example #4
0
 def find_rule4(self, board, chain):
     ''' twice in a unit '''
     for v in chain.root.c:
         possible = chain.paths[v].subnodes()
         for i,node1 in enumerate(possible):
             for j,node2 in enumerate(possible):
                 if j > i and node1.cell != node2.cell and node1.value == node2.value and node1.state != node2.state and share_unit(node1.cell,node2.cell):
                     removed = [cell for cell in visible_intersection(board, [node1.cell,node2.cell]) if cell.check_remove(set([node1.value]))]
                     if removed:
                         return [SolvedSet(Medusa3DSolver(0, Solver.TYPE4), [node1.cell, node2.cell], set([node1.value]) ,removed)]
     return []
 def find_rule2(self, board, chain):
     ''' same color twice in a unit '''
     for v in chain.root.c:
         possible = chain.paths[v].subnodes()
         for i,node1 in enumerate(possible):
             for j,node2 in enumerate(possible):
                 if j > i and node1.state == node2.state and node1.cell != node2.cell and share_unit(node1.cell,node2.cell):
                     return [SolvedSet(SimpleColoringSolver(0, Solver.TYPE2), [node1.cell, node2.cell], set([v]), [cell for cell in set(chain.paths[v].subcells(v,node1.state))])]
     return []