public void OnProgress(TChromosome best) { DataChart.Series[0].Points.AddY(best.Fitness); DataChart.Update(); ErrorLbl.Text = "Error: " + HighScore.ToString(); ErrorLbl.Refresh(); }
public double OnEvaluate(TChromosome specimen) { var cube = new RubikCube(RubikCube); var bestFitness = double.MaxValue; for (int len = 0; len < specimen.Genes.Length; len++) { var move = new TMove(); move.Decode((int)specimen.Genes[len]); cube.MakeMove(move); var fitness = cube.Evaluate(); if (fitness < bestFitness) { bestFitness = fitness; (specimen as RubikGenome).MovesCount = len + 1; } } specimen.Fitness = bestFitness; return(bestFitness); }