# - - - P u z z l e . _ _ a d d S l o t
def __addSlot ( self, isV, start, length ):
'''Add a new slot to self.
[ (isV is 0 for horizontal, 1 for vertical) and
(start is the starting coordinate of a slot as a
Coord instance) and
(length is the length of the slot) ->
self := self with a slot added starting at start
and extending in direction isV for length cells ]
'''
First we create a Slot instance, then add it
to self.__slotMap; see Section 52, “class Slot: One place where a word
goes”. We must also link each of its
cells to the slot, so that a cell can quickly determine of
which slot or slots it is part; see Section 32, “Puzzle.whatCell(): Is there a cell at a
given coordinate?” and Section 50, “Cell.addSlot(): Add an intersecting
slot”.
#-- 1 --
# [ slot := a new Slot instance with origin (start),
# length (length), and orientation (isV) ]
slot = Slot ( start, length, isV )
if VERBOSE:
print ( "=== Creating %s" % slot )
#-- 2 --
self.__slotMap[(start[0], start[1], isV)] = slot
#-- 3 --
# [ self := self with all cells that are part of slot
# linked to slot ]
for coord in slot.genCoords():
cell = self.whatCell ( coord )
cell.addSlot ( slot )