public static void HandleArgs(EvolutionState engine, EvolvingSpaceShooter game) { lock (syncLock) { if (!processed) { // get the list of arguments string[] args = Environment.GetCommandLineArgs(); bool show_help = false; OptionSet parser = new OptionSet() { "Usage: ", "", { "batchmode", "run in batchmode", v => batchmode = v != null }, { "level=", "the number of the {Level} to use.", (int v) => game.levelNumber = v }, { "generations=", "the number of generations to execute.", (int v) => engine.numGenerations = v }, { "probm=", "the mutation probability.", (float v) => engine.mutationProbability = v }, { "probc=", "the crossover probability.", (float v) => engine.crossoverProbability = v }, { "mutType=", "the mutation type", (int v) => engine.mutationType = (MutationType)v }, { "crossType=", "the crossover type", (int v) => engine.crossoverType = (CrossoverType)v }, { "tournSize=", "the tournament size", (int v) => engine.tournamentSize = v }, { "tournK", "probability of tournament selection optimising", (float v) => engine.tournamentK = v }, { "n_cuts=", "number of cuts in the n-crossover", (int v) => engine.N_cutsCrossover = v }, { "elitism=", "number of preserved individuals", (int v) => engine.preservedIndividualsElitism = v }, { "log=", "the logger output filename to use.", v => engine.statsFilename = v }, { "h|help", "show this message and exit", v => show_help = v != null }, }; try { parser.Parse(args); processed = true; } catch (OptionException e) { Console.Write("sokoban: "); Console.WriteLine(e.Message); Console.WriteLine("Try `sokoban --help' for more information."); Application.Quit(); return; } if (show_help) { parser.WriteOptionDescriptions(Console.Out); Application.Quit(); return; } } } }
//Awake is always called before any Start functions void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); scoreText.text = ""; if (restartText) { restartText.text = "1/1"; } if (gameOverText) { gameOverText.text = ""; } evolEngine = this.GetComponentInParent <EvolutionState> (); BatchmodeConfig.HandleArgs(evolEngine, this); lvl = new Level(); lvl.load(levelNumber); evolEngine.populationSize = 50; evolEngine.individualSize = lvl.calcNumberOfMoves(); evolEngine.InitPopulation(); init(); }
public static void HandleArgs(EvolutionState engine, EvolvingSpaceShooter game) { lock (syncLock) { if (!processed) { // get the list of arguments string[] args = Environment.GetCommandLineArgs(); bool show_help = false; OptionSet parser = new OptionSet() { "Usage: ", "", { "batchmode", "run in batchmode", v => batchmode = v != null }, { "random=", "random generator number", (int v) => engine.random = v }, { "level=", "the number of the {Level} to use.", (int v) => game.levelNumber = v }, { "generations=", "the number of generations to execute.", (int v) => engine.numGenerations = v }, { "probm=", "the mutation probability.", (float v) => engine.mutationProbability = v }, { "probc=", "the crossover probability.", (float v) => engine.crossoverProbability = v }, { "log=", "the logger output filename to use.", v => engine.statsFilename = v }, { "tsize=", "the tournament size to use.", (int v) => engine.tournamentSize = v }, { "elitism=", "the elitism number to use.", (int v) => engine.elitismAffected = v }, { "seed=", "the seed to use.", (int v) => engine.random = v }, { "cuts=", "Number of cuts for selection.", (int v) => engine.ncortes = v }, { "tournament=", "true=Tournament || false=Random", (bool v) => engine.flagSelection = v }, { "h|help", "show this message and exit", v => show_help = v != null }, }; try{ parser.Parse(args); processed = true; Console.WriteLine(engine.statsFilename); Debug.Log(engine.statsFilename); } catch (OptionException e) { Console.Write("sokoban: "); Console.WriteLine(e.Message); Console.WriteLine("Try `sokoban --help' for more information."); Application.Quit(); return; } if (show_help) { parser.WriteOptionDescriptions(Console.Out); Application.Quit(); return; } } } }