/// <summary> /// Create a System.Windows.Forms derived object for displaying output for a domain (e.g. show best genome's output/performance/behaviour in the domain). /// </summary> public AbstractDomainView CreateDomainView() { SnakePanel sp = new SnakePanel(); SimpleSnakeWorld sw = new SimpleSnakeWorld(_swparams); sw.Init(); sp.Init(new SnakeRunnerSmart(sw, null, _inputMapper, _outputMapper, _msBetweenTicks, _maxTicksWithoutEating), new NeatGenomeDecoder(_activationScheme)); return(sp); }
public FitnessInfo Evaluate(IBlackBox phenome) { SimpleSnakeWorld sw = new SimpleSnakeWorld(_swparams); sw.Init(); SnakeRunnerSmart sr = new SnakeRunnerSmart(sw, phenome, _inputMapper, _outputMapper, 0, _maxTicksWithoutEating); //SimpleSnakeWorld clone = _srf.GetWorldClone(); //clone.Init(); //SnakeRunner sr = new SnakeRunnerWxH(clone, phenome, 0, _maxTicksWithoutScoreChange); int totalSquaredScore = 0; int totalScore = 0; int totalTicks = 0; double inverseOfMediumFoodDistance = 0; _wins = 0; int cutoffs = 0; for (int runs = 0; runs < _trialsPerEvaluation; runs++) { sr.RunTrial(runs); totalSquaredScore += sr.Score * sr.Score; //was totalScore += sr.Score; changed to emphasize large scores over lower scores totalScore += sr.Score; totalTicks += sr.Ticks; //inverseOfMediumFoodDistance += sr.Score / (double) sr.TotalFoodDistance; if (sr.Win) { _wins++; } //if (sr.Cutoff) // cutoffs++; } EvaluationCount++; return(new FitnessInfo(totalScore, totalSquaredScore)); //probably a good one //return new FitnessInfo(totalSquaredScore, totalScore); //return new FitnessInfo(totalScore, Double.MaxValue/(totalSquaredScore+1)); //return new FitnessInfo(totalScore, Double.MaxValue / (totalSquaredScore - totalScore + 1)); //probably a good one //TODO: magari cambiare la fitness... //return new FitnessInfo((double)(totalSquaredScore + totalScore*totalScore)/1024, totalScore); //return new FitnessInfo(phenome.GetHashCode(), phenome.GetHashCode()); //prova }