# - - - P u z z l e . _ _ r e d u c e C y c l e
def __reduceCycle ( self ):
'''One cycle of cyclic reduction.
[ self.__wordBank := self.__wordBank - (choices
eliminated at slot intersections, if any) ]
'''
This method performs the three types of static reduction in word choices described in Section 4.5, “Cyclic reduction”.
First, we visit every cell in the puzzle (using Section 33, “Puzzle.genCells(): Generate all the
cells”), but we are interested only
in those cells that are related to two slots. For each
such cell, we try to eliminate any choices from the
intersecting slots. For the process carried out for each
pair, see Section 40, “Puzzle.__reduceCell(): Eliminate choices where
two slots intersect”.
#-- 1 --
if VERBOSE: print "=== Reduction cycle"
for cell in self.genCells():
#-- 1 body --
# [ if cell is related to two slots ->
# self.__wordBank := self.__wordBank -
# (choices for those slots that have letters at
# cell's position not found in the intersecting
# slot)
# else -> I ]
self.__reduceCell ( cell )
Next, we perform the unique word test for all slots.
#-- 2 --
for slot in self.__slotMap.values():
#-- 2 body --
# [ if slot has only one choice ->
# remove that choice from all other slots
# else -> I ]
self.__uniqueWordTest ( slot )
Finally, we perform the unique slot test for all words.
#-- 3 --
for word in self.__wordBank.genAllWords():
#-- 3 body --
# [ if word occurs in only one slot's choices ->
# self.__wordBank := self.__wordBank - (choices
# for slot other than word) - (choices for
# that word in all slots)
# else -> I ]
self.__uniqueSlotTest ( word )