public SimulationScreen( RenderWindow window, FloatRect configuration) : base(window, configuration) { this.townVisuals = new List <RectangleShape>(); this.pathLines = new List <ConvexShape>(); // Populate the towns, either hard coded or randomly. This is congifurable in the Configuration.cs. TownHelper.PopulateTowns(); // Grab the images that are used to represent our towns and insert them into quads so they can be shown. // For now our town positions are hard coded, but theres no reason we cant expand this in future to randomly place them. foreach (var town in TownFactory.GetTowns()) { this.townVisuals.Add(town.Shape); } // Create a camera instance to handle the changing of window sizes Camera = new Camera(Configuration.SinglePlayer); // Create a 'FontText' which is a simple wrapper to easily draw text to the screen. totalDistanceString = new FontText(new Font("font.ttf"), string.Empty, Color.Black, 3); GenerationString = new FontText(new Font("font.ttf"), $"Generation: {0}", Color.Black, 3); quitString = new FontText(new Font("font.ttf"), "Press 'Q' to quit.", Color.Black, 3); }
// public static List<RiftStats> DisposedRifts = new List<RiftStats>(); // public static RiftType RiftType; public void StartRift(Enigma.D3.Quest Quest) { RiftType = (RiftType)Quest.x000_QuestSnoId; RiftIsActive = true; CurrentRift = new Rift.RiftStats { StartTick = Quest.x004_CreationTick, Started = DateTime.Now.AddSeconds(-((GameManager.Instance.GameTicks - Quest.x004_CreationTick) / 60)), RiftType = this.RiftType, RiftLevel = -1, Legendary = new List <int>(), Levels = 1, Boss = -1, Difficulty = (Difficulty)GameManagerAccountHelper.Current.DiabloIII.ObjectManager.Storage.x004, }; if (GameManagerAccountHelper.Current.DiabloIII.ObjectManager.Storage._x05C != -1) // GR { CurrentRift.RiftLevel = (GameManagerAccountHelper.Current.DiabloIII.ObjectManager.Storage._x05C + 1); CurrentRift.Difficulty = Difficulty.GreaterRift; TownHelper.UpdateStash(); //RiftType = RiftType.GreaterRift; } Account = GameManagerAccountHelper.Current; SetTimer(); }
public void UpdateSequence(Individual individual) { // Convert our sequence of ints to the 2D line representations to be drawn on the screen. pathLines.Clear(); pathLines.AddRange(TownHelper.GetTownSequencePath(individual.Sequence)); // Convert the fitness into a format that is easily digestable and update the value on screen // Format: 1234.56 totalDistanceString.StringText = individual.GetFitness().ToString("#.##"); }
public void GenerateIndividualTest() { TownHelper.Initialize(); var individual = WorldHelper.GenerateIndividual(Configuration.TownCount); // Ensure that individual contains no repeated values var uniqueValueGroups = individual.Sequence.GroupBy(s => s); Assert.IsTrue(uniqueValueGroups.All(g => g.Count() == 1)); }
public void EnsureSwapMutationResultTest() { TownHelper.Initialize(); var individual = new Individual(new List <int> { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); var result = WorldHelper.DoSwapMutate(individual); // Ensure that all values are still in the list var distinctResultCount = result.Sequence.Distinct().Count(); Assert.AreEqual(distinctResultCount, 10); // Ensure that there are no duplicate entries var sequences = result.Sequence.GroupBy(s => s); Assert.IsTrue(sequences.All(s => s.Count() == 1)); // Perform manual swap to ensure result is correct var firstIndex = -1; var lastIndex = -1; for (int i = 0; i < individual.Sequence.Count; i++) { if (firstIndex == -1 && result.Sequence[i] != individual.Sequence[i]) { firstIndex = i; continue; } if (firstIndex != -1 && result.Sequence[i] != individual.Sequence[i]) { lastIndex = i; break; } } var originalSequence = individual.Sequence.ToList(); originalSequence.SwapInPlace(firstIndex, lastIndex); Assert.IsTrue(originalSequence.SequenceEqual(result.Sequence)); }
public void EnsureRotationMutationResultTest() { TownHelper.Initialize(); var individual = new Individual(new List <int> { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); var result = WorldHelper.DoRotateMutate(individual); // Ensure that all values are still in the list var distinctResultCount = result.Sequence.Distinct().Count(); Assert.AreEqual(distinctResultCount, 10); // Ensure that there are no duplicate entries var sequences = result.Sequence.GroupBy(s => s); Assert.IsTrue(sequences.All(s => s.Count() == 1)); }
public void LoadDefaultFeatures() { if (Config.Get <FKConfig>().General.DamageNumber.Enabled&& Config.Get <FKConfig>().General.Experience.Enabled) { GameManager.Instance.GManager.GRef.Actors.Features.Add(() => GameManager.Instance.GManager.GRef.Actors.DamangeNumbers.Update()); } if (Config.Get <FKAffixes>().Settings.Enabled) { GameManager.Instance.GManager.GRef.Actors.Features.Add(() => Affix.NewLoop()); } if (Config.Get <FKConfig>().General.Skills.Skill) { GameManager.Instance.GManager.GRef.Actors.Features.Add(() => { if (UIObjects.SkillsBar.Cache & !UIObjects.SkillsBar.TryGetValue <Enigma.D3.UI.Controls.UXControl>()) // Skills updated { GameManagerAccountHelper.Current.LevelAreaHelper.ResetSkillbar(); } }); } if ((Config.Get <FKConfig>().General.MiniMapSettings.RevealMapLargemap.Reveal || Config.Get <FKConfig>().General.MiniMapSettings.RevealMapMinimap.Reveal)) { GameManager.Instance.GManager.GRef.Actors.Features.Add(() => { SceneHelper.LoadScenes(); MapItems.Scene(); }); } GameManager.Instance.GManager.GRef.Actors.Features.Add(() => { if (TownHelper.InTown) { TownHelper.GetStash(); TownHelper.Gambling(); } }); }
public void EnsureSpawningUniqueTest() { TownHelper.Initialize(); var population = WorldHelper.SpawnPopulation(); var populationSequences = population.Select(i => i.Sequence); // Manually check that each individual in the population is unique foreach (var sequenceA in populationSequences) { foreach (var sequenceB in populationSequences) { if (sequenceA == sequenceB) { continue; } Assert.IsTrue(!sequenceA.SequenceEqual(sequenceB)); } } }
public void EnsureCrossoverTest() { TownHelper.Initialize(); var individualA = new Individual(new List <int> { 0, 9, 1, 8, 2, 7, 3, 6, 4, 5 }); var individualB = new Individual(new List <int> { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); var crossoverPointA = 3; var crossoverPointB = 1; var crossoverPointC = 8; var childA = WorldHelper.DoCrossover(individualA, individualB, crossoverPointA); var childB = WorldHelper.DoCrossover(individualA, individualB, crossoverPointB); var childC = WorldHelper.DoCrossover(individualA, individualB, crossoverPointC); var expectedChildASequence = new List <int> { 0, 9, 1, 2, 3, 4, 5, 6, 7, 8 }; var expectedChildBSequence = new List <int> { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; var expectedChildCSequence = new List <int> { 0, 9, 1, 8, 2, 7, 3, 6, 4, 5 }; Assert.IsTrue(childA.Sequence.SequenceEqual(expectedChildASequence)); Assert.IsTrue(childB.Sequence.SequenceEqual(expectedChildBSequence)); Assert.IsTrue(childC.Sequence.SequenceEqual(expectedChildCSequence)); Assert.AreEqual(childA.Sequence.Count(), individualA.Sequence.Count()); Assert.AreEqual(childB.Sequence.Count(), individualA.Sequence.Count()); Assert.AreEqual(childC.Sequence.Count(), individualA.Sequence.Count()); }
public Inventory() { InitializeComponent(); TownHelper.UpdateStash(); Set(); }
public void UpdateSequence(Neighbour neighbour) { pathLines = TownHelper.GetTownSequencePath(neighbour.Sequence); totalDistanceString.StringText = neighbour.GetFitness().ToString("#.##"); }
public void UpdateSequence(List <int> sequence) { base.Update(1); pathLines = TownHelper.GetTownSequencePath(sequence); }