RED = 1 YELLOW = -1 EMPTY = 0 def to_svg(board): """ Create an SVG representation of the board, with the latest piece dropping down via SVG I must confess that this function was written almost entirely by Claude; done in 15 mins, when it would have taken me a couple of hours. Amazing! """ svg = '''
''' # Add the holes to the mask svg += ''.join(f''' ''' for y in range(6) for x, cell in enumerate(board.cells[5-y]) ) svg += ''' ''' # Add pieces svg += ''.join(f''' ''' for y in range(6) for x, cell in enumerate(board.cells[5-y]) if cell != EMPTY ) svg += ''' ''' # Add hole borders on top svg += ''.join(f''' ''' for y in range(6) for x, cell in enumerate(board.cells[5-y]) ) svg += '''
''' return svg