internal static List <Challenge> SinglePointCrossover(Challenge c1, Challenge c2) { int crossPoint = (RandGenerator.Next(1, Math.Min(c1.ActionsList.Count, c2.ActionsList.Count))); Challenge offspring1 = new Challenge(c1.Name); Challenge offspring2 = new Challenge(c2.Name); for (int i = 0; i < crossPoint; i++) { offspring1.ActionsList.Add(new PinchAction(c1.ActionsList[i].Type, c1.ActionsList[i].DifficultyPerPlayer, c1.ActionsList[i].DifficultyLevel)); offspring2.ActionsList.Add(new PinchAction(c2.ActionsList[i].Type, c2.ActionsList[i].DifficultyPerPlayer, c2.ActionsList[i].DifficultyLevel)); } for (int i = crossPoint; i < c1.ActionsList.Count; i++) { offspring2.ActionsList.Add(new PinchAction(c1.ActionsList[i].Type, c1.ActionsList[i].DifficultyPerPlayer, c1.ActionsList[i].DifficultyLevel)); } for (int i = crossPoint; i < c2.ActionsList.Count; i++) { offspring1.ActionsList.Add(new PinchAction(c2.ActionsList[i].Type, c2.ActionsList[i].DifficultyPerPlayer, c2.ActionsList[i].DifficultyLevel)); } return(new List <Challenge>() { offspring1, offspring2 }); }
public void MakeMutation() { int actionIndex = (RandGenerator.Next(0, ActionsList.Count)); int newActionIndex = (RandGenerator.Next(0, 4 + 1)); while (actionIndex == newActionIndex) { newActionIndex = (RandGenerator.Next(0, 4 + 1)); } ActionsList.RemoveAt(actionIndex); PinchType newActType = (PinchType)newActionIndex; int Difficulty = RandGenerator.Next(_DifficultyMin, _DifficultyMax + 1); switch (newActType) { case PinchType.Tip2: ActionsList.Add(new PinchAction(newActType, dpT2, Difficulty)); break; case PinchType.Pad2: ActionsList.Add(new PinchAction(newActType, dpP2, Difficulty)); break; case PinchType.Tip3: ActionsList.Add(new PinchAction(newActType, dpT3, Difficulty)); break; case PinchType.Pad3: ActionsList.Add(new PinchAction(newActType, dpP3, Difficulty)); break; } }
public void AddRandomAction(int Difficulty = -1) { PinchType newActType = (PinchType)(RandGenerator.Next(0, 4 + 1)); if (Difficulty == -1) { Difficulty = RandGenerator.Next(_DifficultyMin, _DifficultyMax + 1); } switch (newActType) { case PinchType.Tip2: ActionsList.Add(new PinchAction(newActType, dpT2, Difficulty)); break; case PinchType.Pad2: ActionsList.Add(new PinchAction(newActType, dpP2, Difficulty)); break; case PinchType.Tip3: ActionsList.Add(new PinchAction(newActType, dpT3, Difficulty)); break; case PinchType.Pad3: ActionsList.Add(new PinchAction(newActType, dpP3, Difficulty)); break; //case PinchType.Lateral: // ActionsList.Add(new PinchAction(newActType, dpL2, Difficulty)); // break; } }
public void AddRandomAction(int Difficulty = -1) { PinchType newActType = (PinchType)(RandGenerator.Next(1, 4)); if (Difficulty == -1) { Difficulty = RandGenerator.Next(_DifficultyMin, _DifficultyMax + 1); } switch (newActType) { case PinchType.Tip2: ActionsList.Add(new PinchAction(newActType, dpT2, Difficulty)); break; case PinchType.Pad2: ActionsList.Add(new PinchAction(newActType, dpP2, Difficulty)); break; case PinchType.Tip3: ActionsList.Add(new PinchAction(newActType, dpT3, Difficulty)); break; case PinchType.Pad3: ActionsList.Add(new PinchAction(newActType, dpP3, Difficulty)); break; default: MainController.PrintToLog("At \"AddRandomAction\" Random number was not good - " + newActType + ". TherapyData.cs.", MainController.LogType.Error); break; } }
public int DifficultyPerPlayer; // dp public PinchAction(PinchType t, int dp, int diffScore = -1) { Type = t; DifficultyPerPlayer = dp; if (diffScore == -1) { DifficultyLevel = RandGenerator.Next(_DifficultyMin, _DifficultyMax + 1); } else { DifficultyLevel = diffScore; } }