/* Tank problem solver using ES(Evolution Strategy) */ import java.lang.*; import java.io.*; import java.util.*; public class ES { boolean[][] chromosome; //遺伝子配列[固体番号][遺伝子内の座標] int MAXLOOP = 1000; Random random; long seed; double fitness[]; //遺伝子の適応度を記録 int MAXRANGE=1000; //敵戦車の範囲 0-1000m //for test public static void main(String[] args){ int population=100; int chromLen=16; //遺伝子の長さ long seed=0; ES es = new ES(population, chromLen, seed); es.start(); } public ES(int population, int chromLen, long seed){ chromosome = new boolean[population][chromLen]; this.seed = seed; fitness = new double[population]; } public void start(){ this.init(); int loop=1; while(true){ System.out.print("loop:"+loop); this.eval(); printChromosome(0); if(loop>=MAXLOOP) { break; } select(); geneticOperation(); loop++; } printChromosome(0); //output best Chromosome } void init(){ random = new Random(seed); for(int i=0; ii; j--){ if(fitness[j]