In my learning about genetic algorithms, my original scenario was a 'playground' grid, and the goal was to get from the entrance on one side to the exit on the other. Each gene moved the current position (the agent) by one in one of 8 directions (compass directions N, NE, E, SE, S, SW, W, NW). The fitness was calculated by the distance from the agent's final position to the exit when the chromosome had been completely processed. On display, a dot indicated a place the agent had been; a digit indicated that it had been there that many times.
⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕ ⎕ ·2··2· ⎕ ⎕ 3 222 ⎕ ⎕ ··· 42 ⎕ ⎕ ·· ··· ⎕ =· · ·· · · = ⎕·· 2· · · · · ⎕ ⎕ · · · · · ·· ⎕ ⎕ ·223·· ⎕ ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕ Mid-process display
In general, with 200 chromosomes in each generation and a 24×80 playground, it took about 95 generations to find a solution.
I played with it a bit, adding fitness penalties if a gene moved to a place the agent had already been, or would have moved off the playground. I also tried adding obstacles to the playground.
Drawbacks to this experiment included:
- I didn't really know what I was doing;
- I had to ensure that the chromosome length was sufficient to get across the playground; and
- Once the exit was reached, there was no further 'refining' of the chromosome that had gotten there.
I'm now reading Genetic Algorithms in Search, Optimization, and Machine Learning and trying to correct point #1 above. The math is a little hairy in places, and some of the text is really daunting:
… During reproduction, a string is copied according to its fitness, or more precisely a string Ai gets selected with probability pi = fi÷Σfj. After picking a nonoverlapping population of size n with replacement from the population A(t), we expect to have m(H, t+1) representatives of the schema H in the population at time t+1 as given by the equation m(H,t+1) = m(H,t)×n×f(H)÷Σfj, where f(H) is the average fitness of the strings representing schema H at time t. If we recognize that the average fitness of the entire population may be written as f̄=Σfj÷n then we may rewrite the reproductive schema growth equation as follows …
Wow. And that's only in Chapter 2. (Minor liberties were taken to represent the mathematical symbols.)
But I'm slogging through it, when time permits. It's a hell of a thing to try to read in coach on a transAtlantic flight, though.
In addition to wanting to rework my original experiment in terms of what I learn from the book, I've also thought of trying GAs on:
- MENACE, the original 'teach matchboxes tic-tac-toe' endeavour I first read about in The Adolescence of P1 around 1979. I'm not sure if I'd want to reduce the 'boxes' according to mirroring and rotation; different patterns might yield different results. Maybe treat those conditions as having equivalent schemata, though..
- The game of Sprouts, although from that article it appears as though it might be pointless.
And I'm doing all this in Ruby, of course.