Enumeration

Enumeration is a very simple search algorithm that just puts every solution in some (total) order, checks the first one, then the second, then the third, and so on until it finds a solution with a good enough fitness.

In this example, the fitness of a particular location is shown by how light the grey colour is. This is randomly generated when the page loads.

Each (x, y) point in the square is a solution, and our goal is to find the best (lightest). To enumerate 2D points we need to interleave the x and y values somehow. There are a few different ways we could do it, but in this case we use the following algorithm:

denominator := 2
x_numerator := 1
y_numerator := 1
loop forever:
    try_solution((x_numerator / denominator, y_numerator / denominator))
    y_numerator := y_numerator + 2
    if y_numerator > denominator:
        y_numerator := 1
        x_numerator := x_numerator + 2
    if x_numerator > denominator:
        x_numerator := 1
        denominator := denominator * 2
end loop

This basically takes all of the odd coordinates, like (1, 1), (1, 3), (3, 1), etc., divided by increasing powers of 2 (2, 4, 8, 16, etc.). This way we never hit the same point twice; we end up missing a lot of solutions with this method, but we will always hit a solution nearby (for any finite value of "nearby").

Fittest so far: -1