/// <summary> /// runs the main brain a few times after mutating it and returns its average score /// </summary> /// <param name="mutateMagnitude">The magnitude by which mutations can happen</param> /// <param name="iterations">The number of times the snake plays the game before returning the average score.</param> /// <param name="mutateNRR">Determines how much mutation magnitude distrubution conforms to a normal distribution.</param> /// <returns>the average score</returns> private double ModeTrainAI(double mutateMagnitude = .1, int mutateNRR = 4, int iterations = 100, int mutationChance = 5) { SnakeBrain.Mutate(mutateMagnitude, mutateNRR, mutationChance); double averageScore = 0; for (int i = 0; i < iterations; i++) { NewBoard(i); while (Board1.Progress1Tick()) { RunBrain(); } averageScore += CalculateScore(); } return(averageScore / iterations); }
/// <summary> /// runs the main brain a few times after mutating it and returns its average score /// </summary> /// <param name="mutateMagnitude">The magnitude by which mutations can happen</param> /// <param name="iterations">The number of times the snake plays the game before returning the average score.</param> /// <param name="mutateNRR">Determines how much mutation magnitude distrubution conforms to a normal distribution.</param> /// <param name="randomly">Whether or not to use deterministic brain changes</param> /// <param name="incrementor">if non-random then this must should increment by 1 each call</param> /// <returns>the average score</returns> private double ModeTrainAI(double mutateMagnitude = .1, int mutateNRR = 4, int iterations = 100, int nrOfMutations = 2, bool randomly = false, int incrementor = 0) { if (randomly) { SnakeBrain.Mutate(mutateMagnitude, mutateNRR, nrOfMutations); } double averageScore = 0; for (int i = 0; i < iterations; i++) { NewBoard(i); while (Board1.Progress1Tick()) { RunBrain(Board1, SnakeBrain); } averageScore += CalculateScore(Board1); } return(averageScore / iterations); }