Genetic Algorithm in Java
1 1 1 1 0 0 0 0
1 1 1 1 1 0 0 0
1 1 1 1 1 1 0 0
1 1 1 1 1 1 1 0
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
where the 0's are spaces where nothing can be placed.
Now suppose you have four tetris shapes (each a 4x4 2D array)
Using a genetic algorithm, I need to come up with the best fitness (# spaces filled/total # of spaces)
Pseudo code for the genetic algorithm:
------------
initialize population randomly;
Evaluate;
while (best fitness < 1)
{
Evaluate;
Discard bottom 2 solutions;
Add a new solution as crossover of top 2 solutions;
Add a new solutation as a mutation of the top solution;
}
------------
Here is the code I have so far, I'm having trouble staying in bounds with my arrays:
http://www.codetoad.com/forum/17_25391.asp

