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 override void Randomize() { // randomize weights base.Randomize(); // randomize threshold Threshold = RandGenerator.NextDouble() * (RandRange.Length) + RandRange.Min; }
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 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(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; } }
private void Initialize() { biasWeight = RandGenerator.NextDouble(); for (int i = 0; i < weights.Length; i++) { Weights[i] = RandGenerator.NextDouble(); } }
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; } }
public ActionResult <UserModel> Login(string username, string password) { var user = (from u in _context.Users where u.UserName.Equals(username) && u.password.Equals(password) select u).FirstOrDefault(); if (user != null) { var rnd = new RandGenerator(); string randomString = rnd.RandomString(32, true); return(Ok(randomString)); } return(StatusCode(401)); }
public Dungeon(RandGenerator g, short width, short height) { // Création du héros, NPC _npc = new List<NPC>(); _heros = new Heros(17, 33, '*'); // Au _heros = new Heros((short)(Width/2 +1), (short)(Height/2+1), '*'); // Init du dungeon R = g; Width = width; Height = height; _map = new Elements[width, height]; _view = new Visibility[width, height]; for (int w = 0; w < _map.GetLength(0); w++) { for (int h = 0; h < _map.GetLength(1); h++) { _map[w, h] = Elements.Empty; _view[w, h] = Visibility.Visible; } } }
public Roulette(RandGenerator randGenerator) { this.randGenerator = randGenerator; }
public Relative(RandGenerator randGenerator) : base(randGenerator) { }
public RelativeBase(RandGenerator randGenerator) { this.randGenerator = randGenerator; pockets = new List <Pocket <T> >(); totalSize = 0; }