PaletteOptimiser

Change of optimiser.py

42:25b72160e5c9
optimiser.py
     1.1 --- a/optimiser.py	Sun Oct 04 15:17:31 2015 +0200
     1.2 +++ b/optimiser.py	Sun Oct 04 19:23:16 2015 +0200
     1.3 @@ -174,7 +174,7 @@
     1.4                  else:
     1.5                      c[value] += f
     1.6  
     1.7 -        c = [(n, value) for value, n in c.items()]
     1.8 +        c = [(n/width, value) for value, n in c.items()]
     1.9          c.sort(reverse=True)
    1.10          colours.append(c)
    1.11  
    1.12 @@ -192,8 +192,14 @@
    1.13          least = [value for n, value in c[4:]]
    1.14  
    1.15          if least:
    1.16 -            i = randrange(4, len(c))
    1.17 -            c = c[:3] + c[i:i+1] + c[4:i] + c[i+1:]
    1.18 +            switched = []
    1.19 +            for j in 1, 2:
    1.20 +                i = randrange(0, 4)
    1.21 +                n, value = c[i]
    1.22 +                if n < 0.1:
    1.23 +                    switched.append(c[i])
    1.24 +                del c[i]
    1.25 +            c += switched
    1.26              most = [value for n, value in c[:4]]
    1.27              least = [value for n, value in c[4:]]
    1.28