private static void Play() { var neatGenomeFactory = new NeatGenomeFactory(NeatConsts.ViewX * NeatConsts.ViewY * NeatConsts.typeIds.Count, 1); var activationScheme = NetworkActivationScheme.CreateCyclicFixedTimestepsScheme(1); var genomeDecoder = new NeatGenomeDecoder(activationScheme); XmlReader xr; while (true) { try { xr = XmlReader.Create($"{NeatConsts.experimentName}/best.xml"); break; } catch (Exception) { } } var genome = NeatGenomeXmlIO.ReadCompleteGenomeList(xr, false, neatGenomeFactory)[0]; var phenome = genomeDecoder.Decode(genome); using var game = new Game(true); var brain = new BlackBoxBrain(phenome, game); while (!game.hasEnded) { brain.Step(); Thread.Sleep(200); } }
public FitnessInfo Evaluate(IBlackBox phenome) { Game game = new Game(); var fitness = new BlackBoxBrain(phenome, game).Run(); if (game.hasWon) { shouldEnd = true; } return(new FitnessInfo(fitness, fitness)); }