code: def getPixelAttrRandom(self, x, y):
          'weighted-random choice of attr at this pixel.'
          c = list(attr for attr, rows in self.pixels[y][x].items()
                           for r in rows if attr and attr not in self.hiddenAttrs)
          return random.choice(c) if c else f getPixelAttrRandom(self, x, y):
          'weighted-random choice of attr at this pixel.'
          c = list(attr for attr, rows in self.pixels[y][x].items()
                           for r in rows if attr and attr not in self.hiddenAttrs)
          return random.choice(c) if c else 0
docs: weighted-random choice of attr at this pixel.