cmd += 'l' elif output[0] >= 0.5: cmd += 'r' if abs(output[1]) < 0.5: pass elif output[1] <= -0.5: cmd += 'a' elif output[1] >= 0.5: cmd += 's' if output[2] >= 0.9: cmd += 'd' game.update(cmd) if game.cleared: print 'Cleared', game.cleared, 'rows' return game.score return sub() ga = GA(3 * 2 + 3, 36, 5, 4, 2, 2, 3, .1, evaluate) while True: print 'Generation', ga.generation ga.next() best, avg = ga.fitnessHistory[-1] print 'Best score %i, average %i' % (best, avg)