protected void Page_Load(object sender, EventArgs e) { GameField _field = new GameField(); if (!IsPostBack) // вызов метода POST, форма отправила свои данные на сервер { if (Session["field"] == null) { Initialisation newInit = new Initialisation(); _field = newInit.InitGame(); } else { _field = (GameField)Session["field"]; } } else { _field = (GameField)Session["field"]; } if (_field.IsWinTheGame()) { string url = string.Format("~/Winner.aspx?time={0}&move={1}", lblTime.Text, Request.Cookies["countMove"].Value); // lblMoves.Text не сработало Session.Clear(); DeleteCookies(); Request.Cookies["countMove"].Value = "0"; Response.Redirect(url); } PrintField(_field); }
protected override void OnCreate(Bundle savedInstanceState) { RequestWindowFeature(WindowFeatures.NoTitle); BDD = new Initialisation(); BDD.DBConnection(); base.OnCreate(savedInstanceState); CrossCurrentActivity.Current.Activity = this; BDD.Table[] ListOfWeather = BDD.GetTable(); List<Table> CleanList = new List<Table>(); foreach(Table weather in ListOfWeather) { if (weather != null) { CleanList.Add(weather); } } ListView.Adapter = new DisplayAdapter(this, CleanList); ListView.Clickable = true; ListView.DescendantFocusability = DescendantFocusability.BlockDescendants; ListView.Focusable = false; ListView.ItemClick += View_Click; ListView.ItemSelected += ListView_ItemSelected; ListView.ItemLongClick += ListView_ItemLongClick; }
private void ReinitializePopulation(List <Representation> oldGeneration, int membersToReplace) { // 1.) pick up unique elite members and remove them from current population List <Representation> newGeneration = new List <Representation>(); List <Representation> eliteMembers = UniqueEliteSelection(oldGeneration.Count / 5 < 6 ? 6 : oldGeneration.Count / 10, oldGeneration); foreach (Representation representation in eliteMembers) { Representation member = oldGeneration.Find(item => item.Values.SequenceEqual(representation.Values)); oldGeneration.Remove(member); } // 2.) randomly initialise new initialPopulationCount/2 members Initialisation initialisation = new Initialisation(membersToReplace < oldGeneration.Count - eliteMembers.Count ? membersToReplace : oldGeneration.Count - eliteMembers.Count); List <Path> newMembers = initialisation.GenerateInitialPopulation(); Decoder decoder = new Decoder(); List <Representation> switcherees = newMembers.Select(path => decoder.EncodePath(path)).ToList(); // 3.) shuffle remains of current population and replace the first half with new member oldGeneration.Shuffle(); oldGeneration.RemoveRange(0, switcherees.Count); oldGeneration.InsertRange(0, switcherees); // 4.) append elite members oldGeneration.InsertRange(0, eliteMembers); }
private void onImageReceived(NetworkMessage netMsg) { var objectMessage = netMsg.ReadMessage <MyImageMessage>(); Sprite dim = Resources.Load <Sprite>(Partie.Langue + "/Dimension/" + objectMessage.dim); Sprite loco = Resources.Load <Sprite>(Partie.Langue + "/Locomotion/" + objectMessage.loco); Sprite equi1 = Resources.Load <Sprite>(Partie.Langue + "/Equipements/" + objectMessage.equi1); Sprite equi2 = Resources.Load <Sprite>(Partie.Langue + "/Equipements/" + objectMessage.equi2); Sprite equi3 = Resources.Load <Sprite>(Partie.Langue + "/Equipements/" + objectMessage.equi3); int numero = objectMessage.num; int z = objectMessage.zone; Sprite[] images = new Sprite[5]; images[0] = loco; images[1] = dim; images[2] = equi1; images[3] = equi2; images[4] = equi3; foreach (Joueur j in Partie.Joueurs) { if (j.Numero == numero) { j.Dim = dim; j.Loco = loco; j.Equi1 = equi1; j.Equi2 = equi2; j.Equi3 = equi3; } } Initialisation.get(images, z); }
public void RealizeEvolution() { Initialisation initialisation = new Initialisation(initialPopulationCount); // Initialisation - validated List <Path> population = initialisation.GenerateInitialPopulation(); for (int i = 0; i < population.Count; i++) { if (StaticOperations.ValidatePath(population[i]) == false) { throw new NotSupportedException(); } } // Evaluation Evaluation evaluation = new Evaluation(); evaluation.EvaluatePopulation(population); // Encoding List <Representation> representations = new List <Representation>(); Decoder decoder = new Decoder(); foreach (Path path in population) { Representation representation = decoder.EncodePath(path); representations.Add(representation); } // Evolution cycle for (int i = 0; i < evolutionCycles; i++) { // Selection Selection selection = new Selection(parentsCount, representations); List <Representation> parents = selection.SelectParents(); // Genetic operator - validated GeneticOperator geneticOperator = new GeneticOperator(descendantsCount, parents); List <Representation> descendants = geneticOperator.GenerateDescendants(); // Decoding List <Path> descendantPaths = new List <Path>(); foreach (Representation representation in descendants) { Path path = decoder.DecodeRepresentation(representation); if (StaticOperations.ValidatePath(path) == false) { throw new NotSupportedException(); } descendantPaths.Add(path); } // Evaluation evaluation.EvaluatePopulation(descendantPaths); for (int j = 0; j < descendants.Count; j++) { descendants[j].Fitness = descendantPaths[j].Fitness; } // Replacement Replacement replacement = new Replacement(parents, descendants, initialPopulationCount); representations = replacement.NextGeneration(); // Save to export file SaveTwoBestMembers(representations); } }
public void Simple_Left_Rotation_Check() { Initialisation roverDemo = new Initialisation(); roverDemo.FacingDirection = "E"; roverDemo.ComputePosition("L"); Assert.Equal("N", roverDemo.FacingDirection); }
public void Constructor_and_Getter_Check() { Initialisation roverDemo = new Initialisation(); Assert.Equal(0, roverDemo.LimitX); Assert.Equal(0, roverDemo.LimitY); Assert.Equal(0, roverDemo.CurrX); Assert.Equal(0, roverDemo.CurrY); Assert.Equal("N", roverDemo.FacingDirection); }
private void Window_Loaded(object sender, RoutedEventArgs e) { Gui.webBrowser = webBrowserEditor; Gui.htmlEditor = HtmlEditor1; Initialisation.webeditor = this; Gui.newdocument(); Initialisation.RibbonComboboxFontsInitialisation(); Initialisation.RibbonComboboxFontSizeInitialisation(); Initialisation.RibbonComboboxFormatInitionalisation(); }
void IDirectionTests.Motion_Check() { Initialisation roverDemo = new Initialisation(); roverDemo.FacingDirection = "W"; roverDemo.CurrX = 2; roverDemo.CurrY = 3; roverDemo.LimitX = 100; roverDemo.LimitY = 100; roverDemo.ComputePosition("M"); Assert.Equal(1, roverDemo.CurrX); }
void IDirectionTests.Motion_Check() { Initialisation roverDemo = new Initialisation(); roverDemo.FacingDirection = "E"; roverDemo.CurrX = 2; roverDemo.CurrY = 3; roverDemo.LimitX = 100; roverDemo.LimitY = 100; roverDemo.ComputePosition("M"); Assert.Equal(3, roverDemo.CurrX); throw new NotImplementedException(); }
public void OnLocationChanged(Location p_location) { if (p_location != null) { Localisation location = new Localisation(); location.Latitude = (float )p_location.Latitude; location.Longitude = (float)p_location.Longitude; Initialisation BDD = new Initialisation(); BDD.DBConnection(); BDD.BDDConnection.InsertOrIgnore(location); BDD.BDDConnection.Close(); } }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { Gui.webBrowser = webBrowserEditor; Gui.htmlEditor = HtmlEditor1; Initialisation.webeditor = this; Gui.newdocument(); // Gui.webBrowser.newWb(CollItem.HTMLtext); Initialisation.RibbonComboboxFontsInitialisation(); Initialisation.RibbonComboboxFontSizeInitialisation(); // Initialisation.RibbonComboboxFormatInitionalisation(); }
public PrivateSchool() { Console.WriteLine("Welcome to private school PC Education\nLet's get the data for this semester"); syntheticData = CommandPromtUtilities.SyntheticData(); this._courses = Initialisation.SetUpCourses(); this._trainers = Initialisation.SetUpTrainers(); this._courseclasses = Initialisation.SetUpClasses(this._courses, this._trainers); Console.WriteLine("\nSemester was organised succesfully!\n"); CommandPromtOutput.OutputMenu(this._courses, this._trainers, this._courseclasses); }
public void Setter_Check() { Initialisation roverDemo = new Initialisation(); roverDemo.LimitX = 180; roverDemo.LimitY = 400; roverDemo.FacingDirection = "S"; roverDemo.CurrX = 0; roverDemo.CurrY = 0; Assert.Equal(180, roverDemo.LimitX); Assert.Equal(400, roverDemo.LimitY); Assert.Equal(0, roverDemo.CurrX); Assert.Equal(0, roverDemo.CurrY); Assert.Equal("S", roverDemo.FacingDirection); }
private void ShowProgressDialogAsync() { Thread progressAsync = new Thread(new Runnable(ActionHandler)); progressAsync.Start(); Initialisation init = new Initialisation(); GlobalData.ContactItems = init.RetrieveAllContacts(BaseContext); //progressAsync.Stop(); progressAsync.Dispose(); _updatingContacts.Dismiss(); _updatingContacts = null; Add(); }
/// <summary> /// Retourne l'action correspondant à cette instruction. /// </summary> public override Action <Context> GetAction() { Action <Context> action = delegate(Context context) { var updateAction = Update.GetAction(); for (Initialisation.GetAction()(context); (bool)Condition.GetValue(context); updateAction(context)) { object val = Block.Execute(context); // Si le block a effectué return : if (Block.HasReturned) { HasReturned = true; ReturnValue = val; } } }; return(action); }
/* Peut etre execute en synchrone car recupere uste la position*/ public void GetLocationAsync(String p_Provider) { LocationManager l_LocationManager = GetLocationManager(); Initialisation BDD = new Initialisation(); BDD.DBConnection(); var locationCriteria = new Criteria { Accuracy = Accuracy.Fine, PowerRequirement = Power.Medium }; var locationProvider = l_LocationManager.GetBestProvider(locationCriteria, true); l_LocationManager.RequestLocationUpdates(p_Provider, MIN_TIME_FOR_UPDATE, MIN_DISTANCE_FOR_UPDATE, locationListener); var GPSEnabled = l_LocationManager.IsProviderEnabled(p_Provider); if (GPSEnabled) { if (l_LocationManager != null) { Localisation location = new Localisation(); Location p_location = getLastKnownLocation(); if (p_location != null) { BDD.BDDConnection.DeleteAll <Localisation>(); location.Latitude = (float)p_location.Latitude; location.Longitude = (float)p_location.Longitude; BDD.BDDConnection.InsertOrIgnore(location); } } } else { Toast.MakeText(this, "GPS is disabled. It is required for the first start and to update position.", ToastLength.Long).Show(); } BDD.BDDConnection.Close(); return; }
public CourseClass(Course course, List <Trainer> trainers) { this.Title = course.Title; this.Stream = course.Stream; this.Type = course.Type; this.StartDate = course.StartDate; this.EndDate = course.EndDate; this._trainers = Initialisation.AssignTrainers(trainers, this.Stream, this.Type); this._assignments = Initialisation.SetUpAssignments(this.Type); this._students = Initialisation.SetUpStudents(this.Stream, this.Type); foreach (var item in this._students) { foreach (var item2 in this._assignments) { item.Assignments.Add(item2); } } }
public static Localisation GetLocation() { Initialisation BDD = new Initialisation(); BDD.DBConnection(); TableQuery <Localisation> LocationList = BDD.BDDConnection.Table <Localisation>(); Localisation Location = null; if (LocationList.Count() != 0) { Location = LocationList.First(); } BDD.BDDConnection.Close(); return(Location); }
void Start() { databaseAccess = FindObjectOfType <DatabaseScript>(); variableAccess = FindObjectOfType <Initialisation>(); interfaceScriptAccess = FindObjectOfType <InterfaceScript>(); }
public static void ThreadTaskInitialisation(Context baseContext) { Initialisation init = new Initialisation(); Log.Info(TAG, "ThreadTaskInitialisation: Initialising MoodList array..."); init.CreateMoodListArray(Context); Log.Info(TAG, "ThreadTaskInitialisation: Forcing first time use of Database"); Globals dbHelp = new Globals(); dbHelp.OpenDatabase(); dbHelp.CloseDatabase(); //early setup for settings GetAllApplicationSettings(); Log.Info(TAG, "ThreadTaskInitialisation: Initialising MoodList..."); if (MoodlistArray.Length > 0) { //does the length match what the constant says it should be if (MoodlistArray.Length != ConstantsAndTypes.MAX_NUMBER_OF_MOODLIST_ITEMS) { //if there is a difference in length then recreate the array init.CreateMoodListArray(Context); Log.Info(TAG, "ThreadTaskInitialisation: Recreating Mood List array because array length (" + MoodlistArray.Length.ToString() + ") is not the same as the defined constant (" + ConstantsAndTypes.MAX_NUMBER_OF_MOODLIST_ITEMS.ToString() + ")"); } else { Log.Info(TAG, "ThreadTaskInitialisation: MoodList array has a length that agrees with the defined constant (" + ConstantsAndTypes.MAX_NUMBER_OF_MOODLIST_ITEMS.ToString() + ")"); } } else { //we need to recreate it anyway init.CreateMoodListArray(Context); Log.Info(TAG, "ThreadTaskInitialisation: Creating Mood List array from scratch"); } Log.Info(TAG, "ThreadTaskInitialisation: Creating Mood List..."); init.CreateMoodList(); Log.Info(TAG, "ThreadTaskInitialisation: Initialising Achievement Chart Types..."); init.CreateAchievementChartTypes(Context); Log.Info(TAG, "ThreadTaskInitialisation: Initialising Colour List..."); init.CreateColourList(); Log.Info(TAG, "ThreadTaskInitialisation: Initialising Medication Types..."); init.CreateMedicationTypes(baseContext); Log.Info(TAG, "ThreadTaskInitialisation: Initialising Medication List..."); init.CreateMedicationList(baseContext); Log.Info(TAG, "ThreadTaskInitialisation: Building list of Contacts..."); //Cannot do this if the user has not given permission yet! if (PermissionsHelper.HasPermission(Context, ConstantsAndTypes.AppPermission.ReadContacts) && PermissionsHelper.PermissionGranted(Context, ConstantsAndTypes.AppPermission.ReadContacts)) { ContactItems = init.RetrieveAllContacts(baseContext); } Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Emergency Contacts..."); init.RetrieveEmergencyContacts(baseContext); Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Tell Myself items..."); init.RetrieveAllTellMyselfEntries(); Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Generic Text items..."); init.RetrieveAllGenericTextEntries(); Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Safety Plan Card items..."); init.RetrieveAllSafetyPlanCardEntries(); Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Medication list items..."); init.RetrieveMedicationList(); Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Activity list for current week..."); init.RetrieveActivitesForCurrentWeek(); Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Reactions List..."); init.RetrieveAllReactions(); Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Feelings List..."); init.RetrieveAllFeelings(); Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Attitudes List..."); init.RetrieveAllAttitudes(); Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Relationships List..."); init.RetrieveAllRelationships(); Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Health List..."); init.RetrieveAllHealth(); Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Fantasies List..."); init.RetrieveAllFantasies(); Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Problems List..."); init.RetrieveAllProblems(); Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Solution Plan List..."); init.RetrieveAllSolutionPlans(); Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Affirmation List..."); init.RetrieveAllAffirmations(); Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Images List..."); init.RetrieveAllImages(); Log.Info(TAG, "ThreadTaskInitialisation: Retrieving PlayLists List..."); init.RetrieveAllPlayLists(); Log.Info(TAG, "ThreadTaskInitialisation: Initialising Appointment Types"); init.CreateAppointmentTypes(Context); Log.Info(TAG, "ThreadTaskInitialisation: Initialising Resource Medication Types"); init.RetrieveAllResourceMedicationTypes(); Log.Info(TAG, "ThreadTaskInitialisation: Initialising Resource Conditions"); init.RetrieveAllResourceConditions(); Log.Info(TAG, "ThreadTaskInitialisation: Initialising Settings"); init.RetrieveAllSettings(); init.GetErrorAlertShowSetting(); AchievementChartItems = new List <AchievementChart>(); }
public void RealizeEvolution() { Random random = new Random(); Initialisation initialisation = new Initialisation(initialPopulationCount); // Initialisation - validated List <Path> population = initialisation.GenerateInitialPopulation(); for (int i = 0; i < population.Count; i++) { if (StaticOperations.ValidatePath(population[i]) == false) { throw new NotSupportedException(); } } // Evaluation Evaluation evaluation = new Evaluation(); evaluation.EvaluatePopulation(population); // Encoding List <Representation> representations = new List <Representation>(); Decoder decoder = new Decoder(); foreach (Path path in population) { Representation representation = decoder.EncodePath(path); representations.Add(representation); } // Evolution cycle for (int i = 0; i < evolutionCycles; i++) { Console.Write("Epoch #" + i + "."); // Reinitialisation happens every 1/10th iteration and randomly resets half of population // Elite 10% is untouched by this process if ((i % 500) == 0 && i != 0) { ReinitializePopulation(representations, (int)(3 * initialPopulationCount / 4)); } // Remap fitness using exponential remapping //RemapFitness(representations, remapParameter); // Selection Selection selection = new Selection(parentsCount, representations); List <Representation> parents = selection.SelectParents(); //List<Representation> parents = selection.SelectCombinedParents(); // Genetic operator - validated GeneticOperator geneticOperator = new GeneticOperator(descendantsCount, parents); List <Representation> descendants = geneticOperator.GenerateDescendants(); // Decoding List <Path> descendantPaths = new List <Path>(); foreach (Representation representation in descendants) { Path path = decoder.DecodeRepresentation(representation); if (StaticOperations.ValidatePath(path) == false) { throw new NotSupportedException(); } descendantPaths.Add(path); } // Evaluation evaluation.EvaluatePopulation(descendantPaths); for (int j = 0; j < descendants.Count; j++) { descendants[j].Fitness = descendantPaths[j].Fitness; } // Revaluate current population after fitness remapping //List<Path> currentPaths = new List<Path>(); //foreach (Representation representation in representations) //{ // Path path = decoder.DecodeRepresentation(representation); // currentPaths.Add(path); //} //evaluation.EvaluatePopulation(currentPaths); //for (int j = 0; j < representations.Count; j++) //{ // representations[j].Fitness = currentPaths[j].Fitness; //} // Replacement Replacement replacement = new Replacement(representations, descendants, initialPopulationCount); //representations = replacement.GenerationReplacement(); //representations = replacement.NextGeneration(); representations = replacement.DuplicationElimination(7, representations.Count / 20 < 3 ? representations.Count / 20 : 3, 20); Console.Write(" Maximum fitness: " + representations.Max(item => item.Fitness)); // Save to export file SaveSixBestMembers(representations); } }
public void RealiseEvolution() { // Initialise population Initialisation initialisation = new Initialisation(initialPopulationCount, goldFieldCount); List <Individual> population = initialisation.InitialisePopulation(); // Validate population for (int i = 0; i < population.Count; i++) { if (StaticOperations.ValidateIndividual(population[i]) == false) { throw new NotSupportedException(); } } // Evaluate population Evaluation evaluation = new Evaluation(); for (int i = 0; i < population.Count; i++) { evaluation.EvaluateIndividual(population[i]); } // Evolution cycle for (int i = 0; i < evolutionCycles; i++) { Console.Write("# Epoch " + (i + 1)); // Selection Selection selection = new Selection(population, population.Count); // Q tournament List <Individual> parents = selection.SelectParents(4); // Genetic operators List <Individual> descendants = new List <Individual>(); GeneticOperators geneticOperators = new GeneticOperators(); for (int j = 0; j < parents.Count; j = j + 2) { descendants.AddRange(geneticOperators.GenerateDescendants(parents[j], parents[j + 1])); } // Evaluation for (int j = 0; j < descendants.Count; j++) { evaluation.EvaluateIndividual(descendants[j]); } // Replacement Replacement replacement = new Replacement(population, descendants, population.Count); if (i - bestFitnessEpoch < 100) { population = replacement.NextGeneration(); } else { population = replacement.KillBestIndividuals(); bestFitness = double.MaxValue; } foreach (Individual individual in population) { if (StaticOperations.ValidateIndividual(individual) == false) { throw new NotSupportedException(); } } // Save best member List <Individual> orderedPopulation = population.OrderBy(ind => ind.Fitness).ToList(); bestIndividualsPerGeneration.Add(orderedPopulation[0]); Console.WriteLine(" Minimum fitness: " + orderedPopulation[0].Fitness + "."); if (orderedPopulation[0].Fitness < bestFitness) { bestFitness = orderedPopulation[0].Fitness; bestFitnessEpoch = i; } if (orderedPopulation[0].Fitness == 0) { break; } } SaveDataToFile(); }
public void RealiseEvolution() { // Initialise population - validated Initialisation initialisation = new Initialisation(initialPopulationCount); List <Individual> population = initialisation.GenerateInitialPopulation(); foreach (Individual individual in population) { if (StaticOperations.ValidateIndividual(individual) == false) { throw new NotSupportedException(); } } // Evaluate synthethic fitness of population Evaluation evaluation = new Evaluation(firstCriteria, secondCriteria, thirdCriteria); foreach (Individual individual in population) { // Only criteria with true value will be considered evaluation.EvaluateIndividual(individual); } //Evolution cycles for (int i = 0; i < evolutionCycles; i++) { Console.Write("Epoch #" + i); // Selection - q-tournament Selection selection = new Selection(population, initialPopulationCount); List <Individual> parents = selection.SelectParents(2); // Genetic operators List <Individual> descendants = new List <Individual>(); GeneticOperators geneticOperators = new GeneticOperators(); for (int j = 0; j < parents.Count; j = j + 2) { descendants.AddRange(geneticOperators.GenerateDescendants(parents[j], parents[j + 1])); } // Evaluation foreach (Individual individual in descendants) { // Only criteria with true value will be considered evaluation.EvaluateIndividual(individual); } // Replacement Replacement replacement = new Replacement(population, descendants, initialPopulationCount); population = replacement.NextGeneration(); // Save best individual if (firstCriteria) { List <Individual> paretSetSurvivors = population.Where(ind => ind.Fitness == 1 && ind.FitnessVector[0] == 1).ToList(); if (paretSetSurvivors.Count == 0) { bestIndividuals.Add(population[0]); } else { paretSetSurvivors.Shuffle(); bestIndividuals.Add(paretSetSurvivors[0]); } Console.WriteLine(" Paret set count: " + EvaluateParetSet(population)); } else { List <Individual> paretSetSurvivors = population.Where(ind => ind.Fitness == 1).ToList(); paretSetSurvivors.Shuffle(); bestIndividuals.Add(paretSetSurvivors[0]); Console.WriteLine(" Paret set count: " + EvaluateParetSet(population)); } } SaveBestIndividualsInFile(); }
private void onImageReceived(NetworkMessage netMsg) { var objectMessage = netMsg.ReadMessage <MyImageMessage>(); string dim = objectMessage.dim; string loco = objectMessage.loco; string equi1 = objectMessage.equi1; string equi2 = objectMessage.equi2; string equi3 = objectMessage.equi3; int numero = objectMessage.num; int z = objectMessage.zone; string s = ""; for (int i = 0; i < dim.Length - 21; i++) { s = s + dim[i]; } Debug.Log(s); dim = s; s = ""; for (int i = 0; i < loco.Length - 21; i++) { s = s + loco[i]; } Debug.Log(s); loco = s; s = ""; for (int i = 0; i < equi1.Length - 21; i++) { s = s + equi1[i]; } Debug.Log(s); equi1 = s; s = ""; for (int i = 0; i < equi2.Length - 21; i++) { s = s + equi2[i]; } Debug.Log(s); equi2 = s; s = ""; for (int i = 0; i < equi3.Length - 21; i++) { s = s + equi3[i]; } Debug.Log(s); equi3 = s; Sprite[] images = new Sprite[5]; images[0] = Resources.Load <Sprite>("image/Locomotion/" + loco); images[1] = Resources.Load <Sprite>("image/Dimension/" + dim); images[2] = Resources.Load <Sprite>("image/Equipements/" + equi1); images[3] = Resources.Load <Sprite>("image/Equipements/" + equi2); images[4] = Resources.Load <Sprite>("image/Equipements/" + equi3); Joueur j = new Joueur(); j.Dim = images[1]; j.Loco = images[0]; j.Equi1 = images[2]; j.Equi2 = images[3]; j.Equi3 = images[4]; j.Numero = numero; j.Position = z; Partie.AddPlayer(j); Initialisation.get(images, z); }
public void Correctness_VerifyConnectionString() { string connection = Initialisation.InitConfiguration().GetConnectionString("DefaultConnectionString"); Assert.AreEqual("SERVER=(local);DATABASE=SampleDB;Integrated Security=true;Connection Timeout=30;", connection); }
public void RealiseEvolution() { // Initialisation ReferenceList referenceList = new ReferenceList("tsp.riesenia"); Initialisation initialisation = new Initialisation(initialPopulationCount, referenceList); List <Individual> population = initialisation.InitialisePopulation(); // Evaluation Evaluation evaluation = new Evaluation(referenceList); foreach (Individual individual in population) { evaluation.EvaluateIndividual(individual); } // Validation foreach (Individual individual in population) { if (StaticOperations.ValidateIndividual(individual) == false) { throw new NotSupportedException(); } } // Evolution cycles for (int i = 0; i < evolutionCycles; i++) { Console.Write("Epoch #" + i); // Selection Selection selection = new Selection(population, population.Count); List <Individual> parents = selection.SelectParents(2); // Genetic operators GeneticOperators geneticOperators = new GeneticOperators(); List <Individual> descendants = new List <Individual>(); for (int j = 0; j < parents.Count; j = j + 2) { descendants.AddRange(geneticOperators.GenerateDescendants(parents[j], parents[j + 1])); } // Validation foreach (Individual individual in descendants) { if (StaticOperations.ValidateIndividual(individual) == false) { throw new NotSupportedException(); } } // Evaluation foreach (Individual individual in descendants) { evaluation.EvaluateIndividual(individual); } // Replacement Replacement replacement = new Replacement(population, descendants, population.Count); population = replacement.NextGeneration(); // Save best individual List <Individual> orderedPopulation = population.OrderBy(item => item.Fitness).ToList(); bestIndividualPerGeneration.Add(orderedPopulation[0]); Console.WriteLine(" Minimum fitness: " + orderedPopulation[0].Fitness); } SaveBestIndividualsToFile(referenceList); }
public void OnEnable() { Initialisation.Start(); actions = Controls.actions; //Debug.Log("ACTION0!"); //Debug.Log(actions[0]); //Debug.Log("ACTION0\\!"); foreach (Action a in actions) { //Debug.Log("ACTION!"); try { actionByCategory[a.category.name].Add(a); } catch (KeyNotFoundException e) { List <Action> l = new List <Action> { a }; actionByCategory.Add(a.category.name, l); categories.Add(new Category(a.category.name, a.category.description)); } } GameObject mainControlMenu = CreateMenu(); //mainControlMenu.transform.SetAsFirstSibling(); mainControlMenu.transform.SetParent(transform.parent); mainControlMenu.transform.localPosition = new Vector2(0, 0); mainControlMenu.name = "Menu Control"; ControlOption.menu = mainControlMenu;//new GameObject selected = mainControlMenu.GetComponent <Menu>().selected; for (int k = 0; k < categories.Count; k++) { Category c = categories[k]; GameObject catMenu = CreateMenuCategory(actionByCategory[c.name]); catMenu.name = "Menu " + actionByCategory[c.name][0].category; GameObject catOption = CreateOptionCategory(actionByCategory[c.name], catMenu); catOption.transform.SetParent(mainControlMenu.transform); catOption.name = "Option " + actionByCategory[c.name][0].category; //catMenu.transform.SetAsFirstSibling(); catMenu.transform.SetParent(transform.parent); catMenu.transform.localPosition = k * sep * Vector2.down; if (selected.transform.parent == null) { //selected.transform.SetParent(catMenu.transform, false); selected.transform.parent = catMenu.transform;//MODIFIED selected.transform.localPosition = Vector2.zero; } //Debug.Log("Aah"); } gameObject.AddComponent <Controls>(); }
public void RealiseEvolution() { // Initialisation Initialisation initialisation = new Initialisation(initialPopulationCount, scale); List <Individual> population = initialisation.GenerateInitialPopulation(); // Validation foreach (Individual representation in population) { if (StaticOperations.ValidateIndividual(representation) == false) { throw new NotSupportedException(); } } // Evaluation Evaluation evaluation = new Evaluation(scale); foreach (Individual representation in population) { evaluation.EvaluateIndividual(representation); } // Evolution cycles for (int i = 0; i < evolutionCycles; i++) { Console.Write("Epoch #" + i + " "); // Selection Selection selection = new Selection(initialPopulationCount, population); List <Individual> parents = selection.SelectParents(2); // Genetic operators List <Individual> descendants = new List <Individual>(); GeneticOperators geneticOperators = new GeneticOperators(scale); for (int j = 0; j < parents.Count; j = j + 2) { descendants.AddRange(geneticOperators.GenerateDescendants(parents[j], parents[j + 1])); } // Evaluation foreach (Individual representation in descendants) { evaluation.EvaluateIndividual(representation); } // Validation foreach (Individual representation in population) { if (StaticOperations.ValidateIndividual(representation) == false) { throw new NotSupportedException(); } } // Replacement Replacement replacement = new Replacement(population, descendants, initialPopulationCount); population = replacement.NextGeneration(); List <Individual> orderedPopulation = population.OrderBy(item => item.Fitness).ToList(); Console.WriteLine("Best individual has fitness: " + orderedPopulation[0].Fitness); } SaveBestIndividualIntoFile(population[0]); }