shenzhen-solitaire.py
def move_dragons(self):
        """Generate move for clearing dragons, if allowed."""
        cards_in_front = list(self.spaces + [p[-1] for p in self.piles if p])

        for color in COLORS:
            dragon = Card(DRAGON, color)
            if cards_in_front.count(dragon) == 4 and (
                    dragon in self.spaces or self.num_spaces_open):
                new_b = deepcopy(self)
                new_b.colors_cleared += 1

                while dragon in new_b.spaces:
                    new_b.spaces.remove(dragon)

                for pile in new_b.piles:
                    if pile and pile[-1] == dragon:
                        pile.pop()

                yield new_b, ("Clear %s" % color, CLEAR_D, (color))
Generate move for clearing dragons, if allowed.
Generate move for clearing dragons, if allowed.
Generate move for clearing dragons if allowed .
def move_dragons(self):
        cards_in_front = list(self.spaces + [p[-1] for p in self.piles if p])
        for color in COLORS:
            dragon = Card(DRAGON, color)
            if cards_in_front.count(dragon) == 4 and (
                    dragon in self.spaces or self.num_spaces_open):
                new_b = deepcopy(self)
                new_b.colors_cleared += 1
                while dragon in new_b.spaces:
                    new_b.spaces.remove(dragon)
                for pile in new_b.piles:
                    if pile and pile[-1] == dragon:
                        pile.pop()
                yield new_b, ("Clear %s" % color, CLEAR_D, (color))
def move_dragons ( self ) : cards_in_front = list ( self . spaces + [ p [ - 1 ] for p in self . piles if p ] ) for color in COLORS : dragon = Card ( DRAGON , color ) if cards_in_front . count ( dragon ) == 4 and ( dragon in self . spaces or self . num_spaces_open ) : new_b = deepcopy ( self ) new_b . colors_cleared += 1 while dragon in new_b . spaces : new_b . spaces . remove ( dragon ) for pile in new_b . piles : if pile and pile [ - 1 ] == dragon : pile . pop ( ) yield new_b , ( "Clear %s" % color , CLEAR_D , ( color ) )
Generate move for clearing dragons, if allowed.
Generate move for clearing dragons if allowed .
"""Generate move for clearing dragons, if allowed."""
self