public void Test1() { var list = new WeightedList <BasicClass>(); list.Add(new BasicClass("a")); list.Add(new BasicClass("b")); list.Add(new BasicClass("c")); Assert.Equal(0, list.IndexOf(c => c.Name == "a")); Assert.Equal(1, list.IndexOf(c => c.Name == "b")); Assert.Equal(2, list.IndexOf(c => c.Name == "c")); var n = list.Get(c => c.Name == "a"); list.CheckConsistency(); Assert.Equal("a", n.Name); n = list.Get(c => c.Name == "c"); list.CheckConsistency(); Assert.Equal(1, list.IndexOf(n)); n = list.Get(c => c.Name == "c"); list.CheckConsistency(); Assert.Equal(0, list.IndexOf(n)); n = list.Get(c => c.Name == "c"); list.CheckConsistency(); n = list.Get(c => c.Name == "c"); list.CheckConsistency(); Assert.Equal(0, list.IndexOf(n)); }
public void RemoveEntries_PreserveAtZero_LeaveNone_GetExpectedOrderAndWeights() { var weightedList = new WeightedList<string>(); weightedList.Add("A"); weightedList.Add("B"); weightedList.Add("C"); weightedList.Add("A"); weightedList.Add("B"); weightedList.Add("C"); weightedList.Add("A"); weightedList.Add("B"); weightedList.Remove("A", false); weightedList.Remove("A", false); weightedList.Remove("A", false); List<string> list = weightedList.ToSortedList(); Assert.AreEqual(3, weightedList.Count); Assert.AreEqual(3, list.Count); Assert.AreEqual("A", list[0]); Assert.AreEqual("C", list[1]); Assert.AreEqual("B", list[2]); Assert.AreEqual("A", weightedList.GetMinWeight()); Assert.AreEqual("B", weightedList.GetMaxWeight()); }
private void ReadPhonotactics(string filePath) { XmlDocument xml = new XmlDocument(); xml.Load(filePath); foreach (XmlNode node in xml.SelectNodes("Phonotactics/Constraint")) { string definition = node.Attributes.GetNamedItem("Definition").Value; FieldInfo field = GetType().GetField(definition); if (field != null) { WeightedList <Phonotactics> constraint = (WeightedList <Phonotactics>)field.GetValue(this); double forbiddenWeight = double.Parse(node.Attributes.GetNamedItem("Forbidden").Value, CultureInfo.InvariantCulture); double optionalWeight = double.Parse(node.Attributes.GetNamedItem("Optional").Value, CultureInfo.InvariantCulture); double requiredWeight = double.Parse(node.Attributes.GetNamedItem("Required").Value, CultureInfo.InvariantCulture); constraint.Add(Phonotactics.Forbidden, forbiddenWeight); constraint.Add(Phonotactics.Optional, optionalWeight); constraint.Add(Phonotactics.Required, requiredWeight); } else { Console.WriteLine("Error: " + definition + " not implemented"); } } }
public void WeightedListWith0ElementWeightTest() { int testsNum = 100000; WeightedElement element4 = new WeightedElement(4f); WeightedElement element0 = new WeightedElement(0f); WeightedElement element6 = new WeightedElement(6f); Dictionary <WeightedElement, int> chosenElementNums = new Dictionary <WeightedElement, int>(); chosenElementNums.Add(element4, 0); chosenElementNums.Add(element0, 0); chosenElementNums.Add(element6, 0); WeightedList <WeightedElement> weightedList = new WeightedList <WeightedElement>(new List <WeightedElement> { element4, element0, element6, }); for (int i = 0; i < testsNum; i++) { WeightedElement chosenElement = weightedList.GetRandomWeightedElement(); chosenElementNums[chosenElement]++; } Assert.GreaterOrEqual(chosenElementNums[element4], 39000, "Element with a weight of 4f"); Assert.LessOrEqual(chosenElementNums[element4], 41000, "Element with a weight of 4f"); Assert.AreEqual(chosenElementNums[element0], 0, "Element with a weight of 0f"); Assert.GreaterOrEqual(chosenElementNums[element6], 59000, "Element with a weight of 6f"); Assert.LessOrEqual(chosenElementNums[element6], 61000, "Element with a weight of 6f"); }
public void WeightedListWithFloatElementWeights() { int testsNum = 100000; WeightedElement element37 = new WeightedElement(3.7f); WeightedElement element20 = new WeightedElement(2f); WeightedElement element43 = new WeightedElement(4.3f); Dictionary <WeightedElement, int> chosenElementNums = new Dictionary <WeightedElement, int>(); chosenElementNums.Add(element37, 0); chosenElementNums.Add(element20, 0); chosenElementNums.Add(element43, 0); WeightedList <WeightedElement> weightedList = new WeightedList <WeightedElement>(new List <WeightedElement> { element37, element20, element43, }); for (int i = 0; i < testsNum; i++) { WeightedElement chosenElement = weightedList.GetRandomWeightedElement(); chosenElementNums[chosenElement]++; } Assert.GreaterOrEqual(chosenElementNums[element37], 36000, "Element with a weight of 3.7f"); Assert.LessOrEqual(chosenElementNums[element37], 38000, "Element with a weight of 3.7f"); Assert.GreaterOrEqual(chosenElementNums[element20], 19000, "Element with a weight of 2f"); Assert.LessOrEqual(chosenElementNums[element20], 21000, "Element with a weight of 2f"); Assert.GreaterOrEqual(chosenElementNums[element43], 42000, "Element with a weight of 4.3f"); Assert.LessOrEqual(chosenElementNums[element43], 44000, "Element with a weight of 4.3f"); }
public MeatData ChooseMeatToBuy() { WeightedList <MeatPopularity> meatsToChooseFrom = new WeightedList <MeatPopularity>(NpcCharacterBehaviour.CurrentCityRegion.meatsPopularity.List); MeatData chosenMeat = null; while (!chosenMeat && meatsToChooseFrom.List.Count > 0) { MeatPopularity tempChosenMeatPopularity = meatsToChooseFrom.GetRandomWeightedElement(); chosenMeat = GameManager.Instance.Player.Inventory.HasMeatType(tempChosenMeatPopularity.meatData) ? tempChosenMeatPopularity.meatData : null; if (!chosenMeat) { if (tempChosenMeatPopularity.thisOrNothing) { break; } else { meatsToChooseFrom.List.Remove(tempChosenMeatPopularity); } } } if (!chosenMeat) { NoMeatBought(); } return(chosenMeat); }
public void WeightedList0WeightOnAllElements() { int testsNum = 100000; WeightedElement element0 = new WeightedElement(0f); WeightedElement element00 = new WeightedElement(0f); WeightedElement element000 = new WeightedElement(0f); Dictionary <WeightedElement, int> chosenElementNums = new Dictionary <WeightedElement, int>(); chosenElementNums.Add(element0, 0); chosenElementNums.Add(element00, 0); chosenElementNums.Add(element000, 0); WeightedList <WeightedElement> weightedList = new WeightedList <WeightedElement>(new List <WeightedElement> { element0, element00, element000, }); for (int i = 0; i < testsNum; i++) { WeightedElement chosenElement = weightedList.GetRandomWeightedElement(); chosenElementNums[chosenElement]++; } Assert.GreaterOrEqual(chosenElementNums[element0], 32333, "First element with a weight of 0f"); Assert.LessOrEqual(chosenElementNums[element0], 34333, "First element with a weight of 0f"); Assert.GreaterOrEqual(chosenElementNums[element00], 32333, "Second element with a weight of 0f"); Assert.LessOrEqual(chosenElementNums[element00], 34333, "Second element with a weight of 0f"); Assert.GreaterOrEqual(chosenElementNums[element000], 32333, "Third element with a weight of 0f"); Assert.LessOrEqual(chosenElementNums[element000], 34333, "Third element with a weight of 0f"); }
private static void FixActiveMapWeights(WeightedList <MapAndEncounters> activeMaps) { foreach (MapAndEncounters level in activeMaps) { int indexOfLevelInActiveList = -1; int weight = level.Map.Weight; // Get index1 of element in the rootList List <MapAndEncounters> rootList = (List <MapAndEncounters>)Traverse.Create(activeMaps).Field("rootList").GetValue(); int indexOfLevelInRootList = rootList.IndexOf(level); // Get index2 of element in activeList (if it contains it) List <MapAndEncounters> activeList = (List <MapAndEncounters>)Traverse.Create(activeMaps).Field("activeList").GetValue(); if (activeList.Contains(level)) { indexOfLevelInActiveList = activeList.IndexOf(level); } // Set the weight in the rootWeights in index1 position List <int> rootWeights = (List <int>)Traverse.Create(activeMaps).Property("rootWeights").GetValue(); rootWeights[indexOfLevelInRootList] = weight; // if index2 is >= 0, remove from index2 of activeWeights if (indexOfLevelInActiveList >= 0) { List <int> activeWeights = (List <int>)Traverse.Create(activeMaps).Property("activeWeights").GetValue(); activeWeights[indexOfLevelInActiveList] = weight; } } }
private static void HandleLackOfContractsSituation(SimGameState simGameState, WeightedList <MapAndEncounters> activeMaps, List <Contract> currentContracts, bool filterOutRepeats = true) { // If there are no more active maps, reset the biomes/maps list // Main.Logger.LogWarning($"[HandleLackOfContractsSituation] No valid map/encounter combinations. Handling lack of map/encounter situation."); // if (!filterOutRepeats) Main.Logger.LogWarning($"[HandleLackOfContractsSituation] Since previous runs that filter out used maps didn't produce results. Filtering will not happen on this run."); StarSystem system = MissionControl.Instance.System; List <string> mapDiscardPile = (List <string>)AccessTools.Field(typeof(SimGameState), "mapDiscardPile").GetValue(simGameState); mapDiscardPile.Clear(); WeightedList <MapAndEncounters> playableMaps = (WeightedList <MapAndEncounters>)AccessTools.Method(typeof(SimGameState), "GetSinglePlayerProceduralPlayableMaps").Invoke(null, new object[] { system }); IEnumerable <int> source = from map in playableMaps select map.Map.Weight; WeightedList <MapAndEncounters> weightedList = new WeightedList <MapAndEncounters>(WeightedListType.WeightedRandom, playableMaps.ToList(), source.ToList <int>(), 0); activeMaps.AddRange(weightedList); // Main.Logger.LogWarning($"[HandleLackOfContractsSituation] Running fresh map list over post processing to ensure no contracts screen freezes"); if (filterOutRepeats) { HandleContractRepeats(simGameState, activeMaps); } FixActiveMapWeights(activeMaps); FilterOnMapsWithEncountersWithValidContractRequirements(simGameState, activeMaps, currentContracts); }
//TODO: actually finish this up. public override void loadLevel(BaseLevelData data, GameController game) { if (data.getLevelDataType() != WeightedListLevelData.LEVEL_DATA_TYPE) { Debug.Log("Error: Invalid level data for this loader."); return; } WeightedListLevelData levelData = data as WeightedListLevelData; WeightedList <BaseTargetFactory> _factoryList = levelData.getFactoryList(); //Load the level into the game. for (int i = 0; i < levelData.getDifficulty(); i++) { float targetX = UnityEngine.Random.Range(X_MIN, X_MAX); float targetY = UnityEngine.Random.Range(Y_MIN, Y_MAX); float targetSize = UnityEngine.Random.Range(TARGET_MIN, TARGET_MAX); BaseTargetFactory factory = _factoryList.getItem(); BaseTarget target = factory.makeTarget(); game.addTarget(target, targetX, targetY, targetSize); } game.setTime(levelData.getTime(), true); }
public void WeightedListBasicWithIntegerElementsWeightsTest() { int testsNum = 100000; WeightedElement element1 = new WeightedElement(1f); WeightedElement element3 = new WeightedElement(3f); WeightedElement element6 = new WeightedElement(6f); Dictionary <WeightedElement, int> chosenElementNums = new Dictionary <WeightedElement, int>(); chosenElementNums.Add(element1, 0); chosenElementNums.Add(element3, 0); chosenElementNums.Add(element6, 0); WeightedList <WeightedElement> weightedList = new WeightedList <WeightedElement>(new List <WeightedElement> { element1, element3, element6, }); for (int i = 0; i < testsNum; i++) { WeightedElement chosenElement = weightedList.GetRandomWeightedElement(); chosenElementNums[chosenElement]++; } Assert.GreaterOrEqual(chosenElementNums[element1], 9000, "Element with a weight of 1"); Assert.LessOrEqual(chosenElementNums[element1], 11000, "Element with a weight of 1"); Assert.GreaterOrEqual(chosenElementNums[element3], 29000, "Element with a weight of 3"); Assert.LessOrEqual(chosenElementNums[element3], 31000, "Element with a weight of 3"); Assert.GreaterOrEqual(chosenElementNums[element6], 59000, "Element with a weight of 6"); Assert.LessOrEqual(chosenElementNums[element6], 61000, "Element with a weight of 6"); }
private static WeightedList<T> CreateIfNull<T>(WeightedList<T> list) { if (list == null) { list = new WeightedList<T>(); } return list; }
public GridTerrainGenerator() { Biomes = new WeightedList <BiomeGenerator>() { { 10, BiomeLibrary.LightWoods }, { 10, BiomeLibrary.LakeBiome }, { 20, BiomeLibrary.DessertBiome }, { 10, BiomeLibrary.DenseWoodsBiome }, }; }
static void Postfix(SimGameState __instance, ref WeightedList <MapAndEncounters> activeMaps, List <Contract> currentContracts) { // Main.LogDebug($"[SimGameStateFilterActiveMapsPatch.Postfix] Running SimGameStateFilterActiveMapsPatch"); FixActiveMapWeights(activeMaps); FilterOnMapsWithEncountersWithValidContractRequirements(__instance, activeMaps, currentContracts); if (activeMaps.Count <= 0) { HandleLackOfContractsSituation(__instance, activeMaps, currentContracts); } }
public void Process(WeightedList <QualificationDefinition> input) { if (Definitions == null) { Definitions = new Dictionary <string, QualificationDefinition>(); foreach (KeyValuePair <QualificationDefinition, int> item in input.List) { Definitions.Add(item.Key.NameLocalised.Term, item.Key); } } }
public static void Postfix(FactionDef employer, ref WeightedList <SimGameState.ContractParticipants> __result, string[] __state) { if (Globals.WarStatusTracker == null || Globals.Sim.IsCampaign && !Globals.Sim.CompanyTags.Contains("story_complete")) { return; } employer.Enemies = __state; var type = __result.Type; __result = __result.Distinct().ToWeightedList(type); }
public static void EditWeightedList(string label, bool show, WeightedList list) { DrawList(list.ToList()) .Header(label) .Fold(show) .Item((item) => { item.Object = EditorGUILayout.ObjectField(item.Object, typeof(UnityEngine.Object), true); item.Weight = EditorGUILayout.FloatField(item.Weight); return(item); }) .Render(); }
new public void Awake() { logList = new WeightedList(logs); base.Awake(); main.transform.localScale += new Vector3(0f, -0.2f, 0f); lEnd.transform.localScale += new Vector3(0f, -0.2f, 0f); rEnd.transform.localScale += new Vector3(0f, -0.2f, 0f); main.transform.position += new Vector3(0f, -0.1f, 0f); lEnd.transform.position += new Vector3(0f, -0.1f, 0f); rEnd.transform.position += new Vector3(0f, -0.1f, 0f); }
private static WeightedList<T> ProcessButtons<T>(WeightedList<T> list, int indexToRemove) { if (indexToRemove != -1) { list.RemoveAt(indexToRemove); } if (GUILayout.Button("Add")) { Debug.Log("Add " + default(T)); list.Add(default(T), 0f); } return list; }
private static WeightedList <SimGameState.ContractParticipants> GenerateContractParticipants(FactionDef employer, StarSystemDef system, List <string> opFor) { var weightedList1 = new WeightedList <SimGameState.ContractParticipants>(WeightedListType.PureRandom); var enemies = opFor?.Count > 0 ? opFor : system.contractTargetIDs.Except(employer.Allies).Except(Globals.Sim.GetAllCareerAllies()); var neutrals = FactionEnumeration.PossibleNeutralToAllList.Where(f => !employer.FactionValue.Equals(f) && !Globals.Sim.IgnoredContractTargets.Contains(f.Name)).ToList(); var hostiles = FactionEnumeration.PossibleHostileToAllList.Where(f => !employer.FactionValue.Equals(f) && !Globals.Sim.IgnoredContractTargets.Contains(f.Name)).ToList(); var allies = FactionEnumeration.PossibleAllyFallbackList.Where(f => !employer.FactionValue.Equals(f) && !Globals.Sim.IgnoredContractTargets.Contains(f.Name)).ToList(); foreach (var str in enemies) { var target = str; var targetFactionDef = Globals.Sim.factions[target]; var mercenariesFactionValue = FactionEnumeration.GetHostileMercenariesFactionValue(); var defaultHostileFaction = Globals.Sim.GetDefaultHostileFaction(employer.FactionValue, targetFactionDef.FactionValue); var defaultTargetAlly = allies.Where(f => !targetFactionDef.Enemies.Contains(f.Name) && !employer.Allies.Contains(f.Name) && target != f.Name).DefaultIfEmpty(targetFactionDef.FactionValue).GetRandomElement(Globals.Sim.NetworkRandom); var randomElement = allies.Where(f => !employer.Enemies.Contains(f.Name) && !targetFactionDef.Allies.Contains(f.Name) && defaultTargetAlly != f && target != f.Name).DefaultIfEmpty(employer.FactionValue).GetRandomElement(Globals.Sim.NetworkRandom); var weightedList2 = targetFactionDef.Allies.Select(FactionEnumeration.GetFactionByName).Where(f => !employer.Allies.Contains(f.Name) && !Globals.Sim.IgnoredContractTargets.Contains(f.Name)).DefaultIfEmpty(defaultTargetAlly).ToWeightedList(WeightedListType.PureRandom); var weightedList3 = employer.Allies.Select(FactionEnumeration.GetFactionByName).Where(f => !targetFactionDef.Allies.Contains(f.Name) && !Globals.Sim.IgnoredContractTargets.Contains(f.Name)).DefaultIfEmpty(randomElement).ToWeightedList(WeightedListType.PureRandom); var list2 = neutrals.Where(f => target != f.Name && !targetFactionDef.Enemies.Contains(f.Name) && !employer.Enemies.Contains(f.Name)).DefaultIfEmpty(mercenariesFactionValue).ToList(); var list3 = hostiles.Where(f => target != f.Name && !targetFactionDef.Allies.Contains(f.Name) && !employer.Allies.Contains(f.Name)).DefaultIfEmpty(defaultHostileFaction).ToList(); weightedList1.Add(new SimGameState.ContractParticipants(targetFactionDef.FactionValue, weightedList2, weightedList3, list2, list3)); } return(weightedList1); }
private void CheckInitialize(SerializedProperty property, GUIContent label) { if (_WList == null) { var target = property.serializedObject.targetObject; _WList = fieldInfo.GetValue(target) as WeightedList <T>; if (_WList == null) { _WList = new WeightedList <T>(); fieldInfo.SetValue(target, _WList); } _Foldout = EditorPrefs.GetBool(label.text); } }
void Awake() { weightedSpawnables = new WeightedList <Spawnable>(); foreach (Spawnable s in Spawnables) { weightedSpawnables.Add(s, s.weight); } WorldContainer = new GameObject("WorldContainer"); WorldContainer.transform.parent = transform; Terrain = GetComponentInChildren <Terrain>(); bounds = TerrainUtils.GetTerrainBounds(Terrain); positions = new List <ObjectLocation>(); }
public IWeightedList <ConcreteSpecimen> Build(int sizeOfStarterPopulation) { var random = new Random(); var result = new WeightedList <ConcreteSpecimen>(sizeOfStarterPopulation); // We generate the population around a random epicenter... var epicenter = -1.5d + random.NextDouble() * 3; for (var i = 0; i < sizeOfStarterPopulation; i++) { var cell = new ConcreteSpecimen(epicenter + (-2 + random.NextDouble() * 4)); result.Add(new WeightedItem <ConcreteSpecimen>(cell, 0)); } return(result); }
private static void HandleContractRepeats(SimGameState simGameState, WeightedList <MapAndEncounters> activeMaps) { List <string> mapDiscardPile = (List <string>)AccessTools.Field(typeof(SimGameState), "mapDiscardPile").GetValue(simGameState); MethodInfo DoesActiveFlashpointUseSameMapMethod = AccessTools.Method(typeof(SimGameState), "DoesActiveFlashpointUseSameMap"); for (int num = activeMaps.Count - 1; num >= 0; num--) { Map_MDD map = activeMaps[num].Map; bool doesActiveFlashpointUseSameMap = (bool)DoesActiveFlashpointUseSameMapMethod.Invoke(simGameState, new object[] { map.MapName }); if (mapDiscardPile.Contains(map.MapID) || doesActiveFlashpointUseSameMap) { activeMaps.RemoveAt(num); } } }
static void Postfix(JobApplicant __instance, WeightedList <QualificationDefinition> qualifications) { if (!Main.enabled || Main.InInitialisePools || Main.settings.RespecFutureApplicants == 0) { return; } Main.qualifications.Process(qualifications); WeightedList <string> buildlist = new WeightedList <string>(); foreach (KeyValuePair <string, int> item in statistics[__instance.Definition._type]) { buildlist.Add(item.Key, item.Value); } Main.ProcessJobApplicant(ref __instance, buildlist.Choose(null, RandomUtils.GlobalRandomInstance)); }
private List <Vector2> CreatePointOnBounds(int amount) { WeightedList <WeightedElement <Directions>, Directions> borderWeights = new WeightedList <WeightedElement <Directions>, Directions>(); // Add 8 valid directions to the weighted list. For now 8 streets max are possible borderWeights.Add(new WeightedElement <Directions>(Directions.North, 1)); borderWeights.Add(new WeightedElement <Directions>(Directions.East, 1)); borderWeights.Add(new WeightedElement <Directions>(Directions.South, 1)); borderWeights.Add(new WeightedElement <Directions>(Directions.West, 1)); borderWeights.Add(new WeightedElement <Directions>(Directions.North, 1)); borderWeights.Add(new WeightedElement <Directions>(Directions.East, 1)); borderWeights.Add(new WeightedElement <Directions>(Directions.South, 1)); borderWeights.Add(new WeightedElement <Directions>(Directions.West, 1)); List <Vector2> pointOnBounds = new List <Vector2>(); for (int i = 0; i < amount; i++) { var rnd = FloatGenerator.Generate(); var direction = borderWeights.GetElement(rnd); var rnd1 = FloatGenerator.Generate(); switch (direction) { case Directions.North: pointOnBounds.Add(new Vector2(rnd1, 1f)); break; case Directions.East: pointOnBounds.Add(new Vector2(1f, rnd1)); break; case Directions.South: pointOnBounds.Add(new Vector2(rnd1, 0f)); break; case Directions.West: pointOnBounds.Add(new Vector2(0f, rnd1)); break; } } return(pointOnBounds); }
/* * public static void EditAssetObject<TAssetsLib,TAsset>(TAssetsLib assetsLib,TAssetsLib) * { * * }*/ public static void EditWeightedList(string label, bool show, WeightedList list) { DrawFoldList(label, show, list.Count, (i) => { EditorGUILayout.BeginHorizontal(); list[i].Object = EditorGUILayout.ObjectField(list[i].Object, typeof(UnityEngine.Object), true); list[i].Weight = EditorGUILayout.FloatField(list[i].Weight); if (GUILayout.Button("-")) { list.RemoveAt(i); } EditorGUILayout.EndHorizontal(); }, () => { list.Add(new WeightedItem(null, 1)); }); }
public void Add() { WeightedList <string> wl = new WeightedList <string> { { "one", 1 }, { "two", 1 }, { "three", 2 } }; Assert.AreEqual(wl.getWeight(0), 0.25f); Assert.AreEqual(wl.getWeight(1), 0.25f); Assert.AreEqual(wl.getWeight(2), 0.5f); float t = 0.0f; for (int i = 0; i < wl.Count; i++) { t += wl.getWeight(i); } Assert.AreEqual(1.0f, t); }
public void Test2() { var list = new WeightedList <BasicClass>().AddComparator((a, b) => a.Value.Value - b.Value.Value); list.Add(new BasicClass("a") { Value = 0 }); list.Add(new BasicClass("b") { Value = 0 }); list.Add(new BasicClass("c") { Value = 1 }); Assert.Equal(1, list.IndexOf(c => c.Name == "a")); Assert.Equal(2, list.IndexOf(c => c.Name == "b")); Assert.Equal(0, list.IndexOf(c => c.Name == "c")); }
private void SelectAttack(SnakeHydra head) { var weightedList = new WeightedList <Snake.Action>(); weightedList.Add(new Snake.ActionIdle(head), 30); Vector2 dist = Target.Position - Position; if (Heads.Count(x => x.CurrentAction is Snake.ActionBite) < 2 && dist.LengthSquared() < 90 * 90) { weightedList.Add(new Snake.ActionBite(head, 60 + Random.Next(60), 20, 60 + Random.Next(60)), 50); } if (Heads.Count(x => x.CurrentAction is Snake.ActionSpit) < 1) { weightedList.Add(new Snake.ActionSpit(head, Target, new Vector2(0, -70), 60, 20, 20, 20), 30); } if (Heads.Count(x => x.CurrentAction is Snake.ActionBreath) < 1 && Math.Abs(dist.X) < 100) { weightedList.Add(new Snake.ActionBreath(head, Target, 80, 120, 60), 30); } head.CurrentAction = weightedList.GetWeighted(Random); }