genetics: Re-optimise fitness function

The fitness function implementation has a number of shady hacks and poor
performance optimisations. Not least is the modulo 3 operation which
means that every 3rd component in the pixel data is ignored! While
browser performance is important, that is a serious flaw, since
essentially a third of the gene pool is free from natural selection.

This patch reworks the fitness kernel by removing this modulo operator,
and re-arranging the nesting of loops and branch points. The result is a
faster, more accurate fitness function. Results after 1 minute of
running with default settings, before this patch:

    Number of generations       397
    Average time per generation 15.11 ms
    Highest fitness             99.07%
    Lowest fitness              94.95%

And after:

    Number of generations       427
    Average time per generation 13.97 ms
    Highest fitness             99.00%
    Lowest fitness              93.29%

Similar results are achieved with the "differences squared" feature
disabled. Before:

    Number of generations       403
    Average time per generation 14.86 ms
    Highest fitness             94.38%
    Lowest fitness              84.08%

And after:

    Number of generations       403
    Average time per generation 14.81 ms
    Highest fitness             93.39%
    Lowest fitness              80.78%

My thanks to Denis Lebedev for bringing the dubious "mod 3" line to my
attention.