public override double ShouldAccept() { bool accept = true; // check if the base meets ALL the user's requirements if (!PassesBasicAcceptRequirements()) { if (!Opponent.IsForcedAttack) { return(0); } } //Check to see if the settings are favoring Gold or Elixir... IgnoreGold = (CurrentSetting("Ignore Gold") == 1); IgnoreElixir = (CurrentSetting("Ignore Elixir") == 1); var minTargets = CurrentSetting("Minimum Exposed Targets"); //If ignoring Gold, Reduce the min required targets by half. if (IgnoreGold) { Log.Info($"{Tag}Ignoring Gold Storages/Collectors"); } //If ignoring Gold, Reduce the min required targets by half. if (IgnoreElixir) { Log.Info($"{Tag}Ignoring Elixir Storages/Collectors"); } var acceptableTargetRange = CurrentSetting("Acceptable Target Range"); acceptableTargetRange = acceptableTargetRange * acceptableTargetRange; int ripeCollectors = 0; double avgfillState = 0; double avgCollectorLvel = 0; var activeBase = !Opponent.IsDead(); //Check how many Collectors are Ripe for the taking (outside walls) ripeCollectors = HumanLikeAlgorithms.CountRipeCollectors(algorithmName, acceptableTargetRange, IgnoreGold, IgnoreElixir, AttackId, out avgfillState, out avgCollectorLvel, CacheBehavior.Default, activeBase); if (activeBase) { var minFillLevel = (double)(CurrentSetting("Min Collector Fill Level")); if (Opponent.IsForcedAttack) { Log.Info($"{Tag}Forced Attack! Actual Fillstate: {(avgfillState * 10).ToString("F1")} Normal FillState Req: {minFillLevel}."); } else if ((avgfillState * 10) < minFillLevel) { //FillState is too Low. Skip Log.Warning($"{Tag}Skipping - Avg fillstate is too low: {(avgfillState * 10).ToString("F1")}. Must be > {minFillLevel}."); accept = false; } else { Log.Info($"{Tag}Avg Collector Fillstate Accepted: {(avgfillState * 10).ToString("F1")} > {minFillLevel}."); } var minAvgCollectorLevel = CurrentSetting("Min Average Collector Level"); if (Opponent.IsForcedAttack) { Log.Info($"{Tag}Forced Attack! Avg Collector Level: {avgCollectorLvel.ToString("F1")} Normal Collector Lvl Req: {minAvgCollectorLevel}."); } else if (avgCollectorLvel < minAvgCollectorLevel && accept) { //Level of Collectors is too low. Log.Warning($"{Tag}Skipping - Avg Collector Level is too low: {avgCollectorLvel.ToString("F1")}. Must be > {minAvgCollectorLevel}."); accept = false; } else if (accept) { Log.Info($"{Tag}Avg Collector Level Accepted: {avgCollectorLvel.ToString("F1")} > {minAvgCollectorLevel}."); } } else { //Log some info about the AvgCollectorLevel and Fill State Log.Info($"{Tag}Avg Collector Fillstate: {(avgfillState * 10).ToString("F1")}"); Log.Info($"{Tag}Avg Collector Level: {avgCollectorLvel.ToString("F1")}"); } if (Opponent.IsForcedAttack) { Log.Info($"{Tag}Forced Attack! {ripeCollectors} targets found outside walls. Normal Min={minTargets}"); } else if (ripeCollectors < minTargets && accept) { Log.Warning($"{Tag}Skipping - {ripeCollectors} targets were found outside the wall. Min={minTargets}"); accept = false; } else if (accept) { Log.Debug($"{Tag}{ripeCollectors} targets found outside walls. Min={minTargets}"); } double returnVal = 0; if (accept || Opponent.IsForcedAttack) { returnVal = .99; } return(returnVal); }
public override double ShouldAccept() { int returnVal = 0; // check if the base meets ALL the user's requirements if (!Opponent.MeetsRequirements(BaseRequirements.All)) { return(0); } //Check if the base is dead. if (Opponent.IsDead(true)) { //Check to see if the settings are favoring Gold or Elixir.. (if a resource is set to ZERO, Ignore that resource when searching for targets) if (!UserSettings.DeadSearch.NeedsOnlyOneRequirementForAttack) { IgnoreGold = (UserSettings.DeadSearch.MinGold == 0); IgnoreElixir = (UserSettings.DeadSearch.MinElixir == 0); } var minTargets = _minimumExposedTargets; //If ignoring Gold, Reduce the min required targets by half. if (IgnoreGold) { Log.Info($"[Human Barch] Minimum Gold = 0 - Ignoring Gold Storages/Collectors"); minTargets = (int)Math.Floor(Convert.ToDouble(minTargets) / 2d); } //If ignoring Gold, Reduce the min required targets by half. if (IgnoreElixir) { Log.Info($"[Human Barch] Minimum Elixir = 0 - Ignoring Elixir Storages/Collectors"); minTargets = (int)Math.Floor(Convert.ToDouble(minTargets) / 2d);; } if (minTargets == 0) { minTargets = 1; //if Gold AND Elixir are Ignored, there should be at least 1 target (DE) in order to attack. } //Check how many Collectors are Ripe for the taking (outside walls) int ripeCollectors = HumanLikeAlgorithms.CountRipeCollectors(_minimumDistanceToCollectors, IgnoreGold, IgnoreElixir); Log.Info($"[Human Barch] {ripeCollectors} targets found outside walls. Min={minTargets}"); if (ripeCollectors < minTargets) { Log.Info($"[Human Barch] Skipping - {ripeCollectors} targets were found outside the wall. Min={minTargets}"); returnVal = 0; } else { return(1); } } else { //Check to see if the settings are favoring Gold or Elixir.. (if a resource is set to ZERO, Ignore that resource when searching for targets) if (!UserSettings.ActiveSearch.NeedsOnlyOneRequirementForAttack) { IgnoreGold = (UserSettings.ActiveSearch.MinGold == 0); IgnoreElixir = (UserSettings.ActiveSearch.MinElixir == 0); } TownHall townHall = TownHall.Find(CacheBehavior.Default); if (townHall.CanSnipe()) { //The TH is positioned so we might be able to snipe it. Log.Info($"[Human Barch] Sniping Active Town Hall!"); return(1); } else { Log.Info($"[Human Barch] Skipping Active Base, TH is not Snipable."); //This is a live base, and we can't snipe the TH. Ignore the Loot Requirements, and always Skip. returnVal = 0; } } return(returnVal); }