public override void OnFrame(Tyr tyr) { tyr.DrawText("Replenishing scvs: " + Units.Count); List <Agent> unassignedSCVs = new List <Agent>(); Dictionary <ulong, int> alreadyRepairing = new Dictionary <ulong, int>(); foreach (Agent agent in Units) { tyr.DrawSphere(agent.Unit.Pos); if (RepairMap.ContainsKey(agent.Unit.Tag) && !NeedsRepairing.Contains(RepairMap[agent.Unit.Tag])) { RepairMap.Remove(agent.Unit.Tag); } if (!RepairMap.ContainsKey(agent.Unit.Tag)) { unassignedSCVs.Add(agent); } else { if (!alreadyRepairing.ContainsKey(RepairMap[agent.Unit.Tag])) { alreadyRepairing.Add(RepairMap[agent.Unit.Tag], 1); } else { alreadyRepairing[RepairMap[agent.Unit.Tag]]++; } } } foreach (ulong tag in NeedsRepairing) { if (!alreadyRepairing.ContainsKey(tag)) { alreadyRepairing[tag] = 0; } while (alreadyRepairing[tag] == 0 && unassignedSCVs.Count > 0) { alreadyRepairing[tag]++; RepairMap.Add(unassignedSCVs[unassignedSCVs.Count - 1].Unit.Tag, tag); unassignedSCVs.RemoveAt(unassignedSCVs.Count - 1); } } for (int i = unassignedSCVs.Count - 1; i >= 0; i--) { IdleTask.Task.Add(unassignedSCVs[i]); Units.Remove(unassignedSCVs[i]); } foreach (Agent agent in Units) { tyr.DrawLine(agent, tyr.UnitManager.Agents[RepairMap[agent.Unit.Tag]].Unit.Pos); agent.Order(Abilities.MOVE, RepairMap[agent.Unit.Tag]); } }
public override void OnFrame(Tyr tyr) { Point2D targetLocation = GetTarget(); bool starportsRemain = false; /* * foreach (Unit unit in tyr.Enemies()) * if (unit.UnitType == UnitTypes.STARPORT) * { * starportsRemain = true; * Search = true; * break; * } */ tyr.DrawText("Search: " + Search); tyr.DrawSphere(targetLocation); foreach (Agent agent in units) { Unit target = Targetting.GetTarget(agent); if (Search) { if (target != null && (target.UnitType == UnitTypes.STARPORT || (UnitTypes.AirAttackTypes.Contains(target.UnitType) && agent.DistanceSq(target) <= 15 * 15))) { agent.Order(Abilities.ATTACK, target.Tag); tyr.DrawLine(agent.Unit.Pos, target.Pos); } else { agent.Order(Abilities.MOVE, targetLocation); } if (agent.DistanceSq(targetLocation) <= 4 * 4 && !starportsRemain) { Search = false; } } else { if (target != null) { agent.Order(Abilities.ATTACK, target.Tag); tyr.DrawLine(agent.Unit.Pos, target.Pos); } else { agent.Order(Abilities.ATTACK, targetLocation); } } } }
public override void OnFrame(Tyr tyr) { if (Units.Count > 0) { tyr.DrawText("Defending workers: " + Units.Count); } if (target == null) { Clear(); return; } while (Units.Count > desiredDefenders) { IdleTask.Task.Add(PopAt(Units.Count - 1)); } // Remove probes whose shields have depleted. if (tyr.MyRace == Race.Protoss) { for (int i = units.Count - 1; i >= 0; i--) { if (units[i].Unit.Shield <= 1) { IdleTask.Task.Add(units[i]); units[i] = units[units.Count - 1]; units.RemoveAt(units.Count - 1); } } } // Remove low health workers. for (int i = units.Count - 1; i >= 0; i--) { if (units[i].Unit.Shield + units[i].Unit.Health <= 5) { IdleTask.Task.Add(units[i]); units[i] = units[units.Count - 1]; units.RemoveAt(units.Count - 1); } } foreach (Agent agent in units) { agent.Order(Abilities.ATTACK, SC2Util.To2D(target.Pos)); } }
public override void OnFrame(Tyr tyr) { if (units.Count <= RetreatSize) { CurrentState = State.Advance; Clear(); return; } bool canAttackGround = false; foreach (Agent agent in Units) { if (agent.CanAttackGround()) { canAttackGround = true; } } if (!canAttackGround) { CurrentState = State.Advance; Clear(); return; } tyr.DrawText("SiegeTask state: " + CurrentState); if (CurrentState == State.Advance) { Advance(tyr); } else if (CurrentState == State.SiegeUp) { SiegeUp(tyr); } else if (CurrentState == State.LeapFrog) { LeapFrog(tyr); } else if (CurrentState == State.Kill) { Kill(tyr); } }
public void OnFrame(Tyr tyr) { List <Unit> simulatedUnits = new List <Unit>(); foreach (Task task in tyr.TaskManager.Tasks) { task.AddCombatSimulationUnits(simulatedUnits); } foreach (Unit unit in tyr.EnemyManager.LastSeen.Values) { if (unit.UnitType == UnitTypes.SIEGE_TANK_SIEGED || unit.UnitType == UnitTypes.WIDOW_MINE_BURROWED) { continue; } if (tyr.EnemyManager.LastSeen.ContainsKey(unit.Tag) && tyr.Frame - tyr.EnemyManager.LastSeenFrame[unit.Tag] > 112) { continue; } if (UnitTypes.CombatUnitTypes.Contains(unit.UnitType)) { simulatedUnits.Add(unit); } } foreach (UnitLocation unit in tyr.EnemyMineManager.Mines) { if (tyr.EnemyManager.LastSeen.ContainsKey(unit.Tag)) { simulatedUnits.Add(tyr.EnemyManager.LastSeen[unit.Tag]); } } foreach (UnitLocation unit in tyr.EnemyTankManager.Tanks) { if (tyr.EnemyManager.LastSeen.ContainsKey(unit.Tag)) { simulatedUnits.Add(tyr.EnemyManager.LastSeen[unit.Tag]); } } List <List <Unit> > simulationGroups = GroupUnits(simulatedUnits); HashSet <uint> myUpgrades = new HashSet <uint>(); if (tyr.Observation.Observation.RawData.Player.UpgradeIds != null) { foreach (uint upgrade in tyr.Observation.Observation.RawData.Player.UpgradeIds) { myUpgrades.Add(upgrade); } } HashSet <uint> enemyUpgrades = new HashSet <uint>(); bool logSimulation = tyr.Frame % 22 == 0 && simulationGroups.Count > 0 && Debug; tyr.DrawText("Simulations: " + simulationGroups.Count); if (logSimulation) { FileUtil.Debug("Simulations: " + simulationGroups.Count); } bool printState = false; if (Tyr.Debug && tyr.Observation.Chat != null && tyr.Observation.Chat.Count > 0) { foreach (ChatReceived message in tyr.Observation.Chat) { if (message.Message == "s") { printState = true; break; } } } int i = 0; foreach (List <Unit> simulationGroup in simulationGroups) { SimulationState state = GetState(tyr, simulationGroup, myUpgrades, enemyUpgrades, false); if (printState) { state.SafeToFile("SimulationState-" + tyr.Frame + "-" + i + ".txt"); } float myResources = GetResources(state, true); float enemyResources = GetResources(state, false); if (printState) { TestCombatSim.TestCombat(state, SimulationLength); } else { state.Simulate(SimulationLength); } float myNewResources = GetResources(state, true); float enemyNewResources = GetResources(state, false); tyr.DrawText("SimulationResult me: " + myResources + " -> " + myNewResources + " his: " + enemyResources + " -> " + enemyNewResources); if (logSimulation) { FileUtil.Debug("SimulationResult me: " + myResources + " -> " + myNewResources + " his: " + enemyResources + " -> " + enemyNewResources); } MakeDecision(simulationGroup, state, myResources, myNewResources, enemyResources, enemyNewResources, myUpgrades, enemyUpgrades); i++; } if (logSimulation) { FileUtil.Debug(""); } }
public override void OnFrame(Tyr tyr) { if (!ChatMessageSent) { if (Completed(UnitTypes.TEMPEST) > 0) { tyr.Chat("This build is dedicated to Andyman!"); ChatMessageSent = true; } } if (HideLocation == null) { HideLocation = ProxyTask.Task.GetHideLocation(); } if (HideLocation != null) { if (ProxyTask.Task.UnitCounts.ContainsKey(UnitTypes.PYLON) && ProxyTask.Task.UnitCounts[UnitTypes.PYLON] > 0 && ProxyTask.Task.UnitCounts.ContainsKey(UnitTypes.STARGATE) && ProxyTask.Task.UnitCounts[UnitTypes.STARGATE] > 0) { float dist = 10 * 10; Unit fleeEnemy = null; foreach (Unit enemy in tyr.Enemies()) { if (!UnitTypes.CanAttackAir(enemy.UnitType)) { continue; } float newDist = SC2Util.DistanceSq(enemy.Pos, HideLocation); if (newDist > dist) { continue; } dist = newDist; fleeEnemy = enemy; } if (fleeEnemy != null) { TempestController.RetreatPos = new PotentialHelper(HideLocation, 6).From(fleeEnemy.Pos).Get(); } else { TempestController.RetreatPos = HideLocation; } } else { TempestController.RetreatPos = null; } } if (TempestController.RetreatPos == null) { TempestController.RetreatPos = ProxyTask.Task.GetHideLocation(); } DepoweredStargates = 0; foreach (Agent agent in tyr.Units()) { if (agent.Unit.UnitType == UnitTypes.STARGATE && !agent.Unit.IsPowered && agent.Unit.BuildProgress >= 0.99) { DepoweredStargates++; } } tyr.DrawText("DepoweredStargates: " + DepoweredStargates); tyr.NexusAbilityManager.PriotitizedAbilities.Add(1568); ProxyTask.Task.EvadeEnemies = true; tyr.buildingPlacer.BuildCompact = true; tyr.TargetManager.PrefferDistant = false; tyr.TargetManager.TargetAllBuildings = true; TrainStep.WarpInLocation = ProxyTask.Task.GetHideLocation(); DefendRegionTask.Task.DefenseLocation = ProxyTask.Task.GetHideLocation(); TimingAttackTask.Task.RequiredSize = 1; TimingAttackTask.Task.RetreatSize = 0; TimingAttackTask.Task.UnitType = UnitTypes.TEMPEST; if (tyr.Frame >= 22.4 * 60 * 4) { ProxyTask.Task.Stopped = true; } else { ProxyTask.Task.Stopped = Count(UnitTypes.GATEWAY) == 0; if (ProxyTask.Task.Stopped) { ProxyTask.Task.Clear(); } } if (UpgradeType.LookUp[UpgradeType.WarpGate].Progress() >= 0.5 && IdleTask.Task.OverrideTarget == null && (tyr.EnemyRace != Race.Protoss || tyr.Frame >= 22.4 * 4 * 60)) { IdleTask.Task.OverrideTarget = tyr.MapAnalyzer.Walk(ProxyTask.Task.GetHideLocation(), tyr.MapAnalyzer.EnemyDistances, 10); } foreach (Agent agent in tyr.UnitManager.Agents.Values) { if (tyr.Frame % 224 != 0) { break; } if (agent.Unit.UnitType != UnitTypes.GATEWAY) { continue; } agent.Order(Abilities.MOVE, agent.From(tyr.MapAnalyzer.GetMainRamp(), 4)); } }
public override void OnFrame(Tyr tyr) { WorkerTask.Task.EvacuateThreatenedBases = true; foreach (Agent agent in tyr.UnitManager.Agents.Values) { if (tyr.Frame % 224 != 0) { break; } if (agent.Unit.UnitType != UnitTypes.GATEWAY) { continue; } if (Count(UnitTypes.NEXUS) < 2 && TimingAttackTask.Task.Units.Count == 0) { agent.Order(Abilities.MOVE, Main.BaseLocation.Pos); } else { agent.Order(Abilities.MOVE, tyr.TargetManager.PotentialEnemyStartLocations[0]); } } if (TotalEnemyCount(UnitTypes.ZEALOT) >= 3 || EnemyCount(UnitTypes.PHOTON_CANNON) > 0) { KillImmortals.Stopped = true; KillStalkers.Stopped = true; KillRobos.Stopped = true; } else { KillImmortals.Stopped = false; KillStalkers.Stopped = false; KillRobos.Stopped = false; } EnemyArmy = System.Math.Max(EnemyArmy, EnemyCount(UnitTypes.ZEALOT) + EnemyCount(UnitTypes.STALKER)); tyr.DrawText("Enemy army: " + EnemyArmy); if (EnemyCount(UnitTypes.PHOENIX) <= 3) { DefenseTask.AirDefenseTask.IgnoreEnemyTypes.Add(UnitTypes.PHOENIX); } else { DefenseTask.AirDefenseTask.IgnoreEnemyTypes.Remove(UnitTypes.PHOENIX); } if (tyr.EnemyStrategyAnalyzer.WorkerRushDetected && Count(UnitTypes.ZEALOT) < 2) { GasWorkerTask.WorkersPerGas = 0; } else { BalanceGas(); } if (TotalEnemyCount(UnitTypes.FORGE) > 0 && tyr.Frame <= 22.4 * 60 * 2) { EarlyForgeDetected = true; } ScoutTask.Task.ScoutType = UnitTypes.PHOENIX; ScoutTask.Task.Target = tyr.TargetManager.PotentialEnemyStartLocations[0]; if (CannonDefenseDetected && TotalEnemyCount(UnitTypes.STARGATE) + TotalEnemyCount(UnitTypes.DARK_SHRINE) + TotalEnemyCount(UnitTypes.VOID_RAY) == 0) { foreach (Agent agent in tyr.Units()) { if (agent.Unit.UnitType != UnitTypes.SENTRY) { continue; } if (agent.Unit.Energy < 75) { continue; } // Hallucinate scouting phoenix. agent.Order(154); } } if (!VoidraysDetected && TotalEnemyCount(UnitTypes.VOID_RAY) > 0) { VoidraysDetected = true; if (TimingAttackTask.Task.Units.Count < 12) { TimingAttackTask.Task.Clear(); } } if (!ZealotRushSuspected && !tyr.EnemyStrategyAnalyzer.WorkerRushDetected) { if ((Tyr.Bot.Frame >= 22.4 * 60 * 1.5 && !Tyr.Bot.EnemyStrategyAnalyzer.NoProxyGatewayConfirmed && TotalEnemyCount(UnitTypes.ASSIMILATOR) + TotalEnemyCount(UnitTypes.CYBERNETICS_CORE) == 0) || (Tyr.Bot.Frame < 22.4 * 60 * 1.5 && Tyr.Bot.EnemyStrategyAnalyzer.ThreeGateDetected)) { ZealotRushSuspected = true; } } if (!LowGroundCannons) { foreach (Unit enemy in tyr.Enemies()) { if (enemy.UnitType != UnitTypes.PHOTON_CANNON) { continue; } if (tyr.MapAnalyzer.MapHeight((int)enemy.Pos.X, (int)enemy.Pos.Y) < tyr.MapAnalyzer.MapHeight((int)tyr.TargetManager.PotentialEnemyStartLocations[0].X, (int)tyr.TargetManager.PotentialEnemyStartLocations[0].Y)) { LowGroundCannons = true; break; } } } if (!CannonDefenseDetected && TotalEnemyCount(UnitTypes.PHOTON_CANNON) + TotalEnemyCount(UnitTypes.FORGE) > 0 && tyr.Frame < 22.4 * 60 * 4 && (EarlyForgeDetected || tyr.EnemyStrategyAnalyzer.Expanded || LowGroundCannons)) { CannonDefenseDetected = true; if (TimingAttackTask.Task.Units.Count < 12) { TimingAttackTask.Task.Clear(); } } if (tyr.EnemyStrategyAnalyzer.WorkerRushDetected && Count(UnitTypes.ZEALOT) < 2) { foreach (Agent agent in tyr.UnitManager.Agents.Values) { if (agent.Unit.UnitType == UnitTypes.ASSIMILATOR && agent.Unit.BuildProgress < 0.99) { agent.Order(Abilities.CANCEL); } } } tyr.TargetManager.TargetCannons = true; if (ZealotRushSuspected) { tyr.TargetManager.TargetGateways = true; WorkerScoutTask.Task.Stopped = true; WorkerScoutTask.Task.Clear(); } if (WorkerScoutTask.Task.BaseCircled()) { WorkerScoutTask.Task.Stopped = true; WorkerScoutTask.Task.Clear(); } if (ZealotRushSuspected || Completed(UnitTypes.IMMORTAL) > 0) { foreach (WorkerDefenseTask task in WorkerDefenseTask.Tasks) { task.Stopped = true; task.Clear(); } } if (ZealotRushSuspected && Completed(UnitTypes.STALKER) >= 12) { foreach (Agent agent in tyr.Units()) { if (agent.Unit.UnitType != UnitTypes.GATEWAY) { continue; } if (agent.DistanceSq(WallIn.Wall[2].Pos) >= 2) { continue; } KillOwnUnitTask.Task.TargetTag = agent.Unit.Tag; break; } } WorkerScoutTask.Task.StartFrame = 600; ObserverScoutTask.Task.Priority = 6; tyr.NexusAbilityManager.Stopped = Count(UnitTypes.STALKER) == 0 && tyr.Frame >= 120 * 22.4; tyr.NexusAbilityManager.PriotitizedAbilities.Add(917); if (EnemyExpandFrame >= 1000000 && tyr.EnemyStrategyAnalyzer.Expanded) { EnemyExpandFrame = tyr.Frame; } if (EnemyExpandFrame < 3 * 60 * 22.4) { EarlyExpand = true; } if (VoidraysDetected || (TotalEnemyCount(UnitTypes.PHOTON_CANNON) + TotalEnemyCount(UnitTypes.FORGE) > 0 && !LowGroundCannons && !EarlyExpand)) { TimingAttackTask.Task.RequiredSize = 24; } else if (ZealotRushSuspected || (CannonDefenseDetected && EarlyExpand)) { TimingAttackTask.Task.RequiredSize = 12; } else { TimingAttackTask.Task.RequiredSize = 4; } TimingAttackTask.Task.RetreatSize = 0; if (EnemyCount(UnitTypes.ZEALOT) + EnemyCount(UnitTypes.STALKER) >= 6 && tyr.Frame < 22.4 * 60 * 5) { CancelElevator = true; WarpPrismElevatorTask.Task.Cancelled = true; } if (EnemyCount(UnitTypes.IMMORTAL) + EnemyCount(UnitTypes.VOID_RAY) > 0) { CancelElevator = true; WarpPrismElevatorTask.Task.Cancelled = true; } if (TotalEnemyCount(UnitTypes.PHOTON_CANNON) + TotalEnemyCount(UnitTypes.FORGE) > 0 && !LowGroundCannons && !EarlyExpand && TimingAttackTask.Task.Units.Count < 18 && TimingAttackTask.Task.RequiredSize > 18) { TimingAttackTask.Task.Clear(); } if (CannonDefenseDetected && !CancelElevator) { TimingAttackTask.Task.Stopped = true; TimingAttackTask.Task.Clear(); ShieldRegenTask.Task.Stopped = true; ShieldRegenTask.Task.Clear(); WarpPrismElevatorTask.Task.Stopped = false; tyr.TargetManager.PrefferDistant = false; tyr.TargetManager.TargetAllBuildings = true; PotentialHelper potential = new PotentialHelper(tyr.TargetManager.PotentialEnemyStartLocations[0], 6); potential.From(tyr.MapAnalyzer.GetEnemyRamp()); StutterController.Toward = potential.Get(); tyr.DrawSphere(new Point() { X = StutterController.Toward.X, Y = StutterController.Toward.Y, Z = tyr.MapAnalyzer.StartLocation.Z }); EvadeCannonsController.Stopped = Completed(UnitTypes.STALKER) + Completed(UnitTypes.IMMORTAL) >= 12; EvadeCannonsController.FleeToward = StutterController.Toward; FallBackController.Stopped = true; } else { TimingAttackTask.Task.Stopped = false; WarpPrismElevatorTask.Task.Stopped = true; tyr.TargetManager.PrefferDistant = true; ShieldRegenTask.Task.Stopped = false; tyr.TargetManager.TargetAllBuildings = false; StutterController.Toward = null; EvadeCannonsController.Stopped = true; FallBackController.Stopped = ZealotRushSuspected; } ForwardProbeTask.Task.Stopped = Completed(UnitTypes.STALKER) + Count(UnitTypes.ADEPT) + Completed(UnitTypes.IMMORTAL) < Math.Max(8, TimingAttackTask.Task.RequiredSize) && (!CannonDefenseDetected || !StargateDetected || EarlyExpand); if (ForwardProbeTask.Task.Stopped) { ForwardProbeTask.Task.Clear(); } if (Count(UnitTypes.NEXUS) <= 1) { IdleTask.Task.OverrideTarget = OverrideMainDefenseTarget; } else if (Count(UnitTypes.NEXUS) >= 3) { IdleTask.Task.OverrideTarget = OverrideDefenseTarget; } else { IdleTask.Task.OverrideTarget = null; } if (ZealotRushSuspected) { DefenseTask.GroundDefenseTask.BufferZone = 0; DefenseTask.GroundDefenseTask.ExpandDefenseRadius = 20; DefenseTask.GroundDefenseTask.MainDefenseRadius = 20; DefenseTask.GroundDefenseTask.MaxDefenseRadius = 120; DefenseTask.GroundDefenseTask.DrawDefenderRadius = 80; } else { DefenseTask.GroundDefenseTask.ExpandDefenseRadius = 30; DefenseTask.GroundDefenseTask.MainDefenseRadius = 30; DefenseTask.GroundDefenseTask.MaxDefenseRadius = 120; DefenseTask.GroundDefenseTask.DrawDefenderRadius = 80; } if (TotalEnemyCount(UnitTypes.TEMPEST) > 0) { DefenseTask.AirDefenseTask.ExpandDefenseRadius = 50; DefenseTask.AirDefenseTask.MainDefenseRadius = 50; DefenseTask.AirDefenseTask.MaxDefenseRadius = 120; DefenseTask.AirDefenseTask.DrawDefenderRadius = 80; } else { DefenseTask.AirDefenseTask.ExpandDefenseRadius = 30; DefenseTask.AirDefenseTask.MainDefenseRadius = 30; DefenseTask.AirDefenseTask.MaxDefenseRadius = 120; DefenseTask.AirDefenseTask.DrawDefenderRadius = 80; } //EarlyNexus = CannonDefenseDetected; EarlyNexus = false; StargateDetected = TotalEnemyCount(UnitTypes.STARGATE) + TotalEnemyCount(UnitTypes.VOID_RAY) + TotalEnemyCount(UnitTypes.PHOENIX) + TotalEnemyCount(UnitTypes.TEMPEST) + TotalEnemyCount(UnitTypes.CARRIER) + TotalEnemyCount(UnitTypes.FLEET_BEACON) > 0; }
public override void OnFrame(Tyr tyr) { if (tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.BATTLECRUISER) > 0) { GroupedAttackTask.Task.RequiredSize = 40; GroupedAttackTask.Task.RetreatSize = 10; } else { GroupedAttackTask.Task.RequiredSize = 60; GroupedAttackTask.Task.RetreatSize = 20; } if (!CannonDefenseDetected && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.PHOTON_CANNON) + tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.FORGE) >= 0 && tyr.Frame < 22.4 * 60 * 4) { CannonDefenseDetected = true; } if (!TempestDetected && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.TEMPEST) > 0) { TempestDetected = true; } MechDestroyExpandsTask.Task.RequiredSize = 10; MechDestroyExpandsTask.Task.MaxSize = 10; MechDestroyExpandsTask.Task.RetreatSize = 4; MechDestroyExpandsTask.Task.UnitType = UnitTypes.ZERGLING; MechDestroyExpandsTask.Task.Stopped = !CannonDefenseDetected || tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.STALKER) + tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.ZEALOT) + tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.IMMORTAL) + tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.PHOENIX) + tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.VOID_RAY) + tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.ORACLE) + tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.CARRIER) > 0 || tyr.Frame <= 22.4 * 60 * 4.5; if (SuspectBanshees) { if (tyr.Frame % 22 == 0) { foreach (Agent agent in tyr.UnitManager.Agents.Values) { if (agent.Unit.UnitType == UnitTypes.OVERLORD || agent.Unit.UnitType == UnitTypes.OVERSEER) { agent.Order(1692); } } } DefenseTask.AirDefenseTask.Priority = 8; IdleTask.Task.RetreatFarOverlords = false; OverlordAtNaturalTask.Task.Stopped = true; OverlordAtNaturalTask.Task.Clear(); QueenTumorTask.Task.PlaceTumorsInMain = true; QueenTumorTask.Task.Priority = 9; StutterForwardController.Stopped = false; StutterController.Stopped = true; CreeperLordTask.Task.Stopped = false; /* * foreach (DefenseSquadTask task in DefenseSquadTask.Tasks) * { * task.Priority = 8; * task.Stopped = false; * task.MaxDefenders = Math.Max(0, Completed(UnitTypes.QUEEN) / Count(UnitTypes.HATCHERY) - 1); * } */ } else { StutterForwardController.Stopped = true; StutterController.Stopped = false; CreeperLordTask.Task.Stopped = true; foreach (DefenseSquadTask task in DefenseSquadTask.Tasks) { task.Stopped = true; } } if (!SuspectBanshees && (tyr.EnemyStrategyAnalyzer.Count(UnitTypes.BANSHEE) > 0 || (tyr.EnemyStrategyAnalyzer.Count(UnitTypes.STARPORT) + tyr.EnemyStrategyAnalyzer.Count(UnitTypes.STARPORT_TECH_LAB) > 0 && tyr.Frame < 22.4 * 60 * 4))) { SuspectBanshees = true; } if (tyr.EnemyStrategyAnalyzer.FourRaxDetected) { FourRaxSuspected = true; } if (!FourRaxSuspected) { Point2D enemyRamp = tyr.MapAnalyzer.GetEnemyRamp(); int enemyBarrackWallCount = 0; foreach (Unit enemy in tyr.Enemies()) { if (enemyRamp == null) { break; } if (enemy.UnitType == UnitTypes.BARRACKS && SC2Util.DistanceSq(enemy.Pos, enemyRamp) <= 5.5 * 5.5) { enemyBarrackWallCount++; } } if (enemyBarrackWallCount >= 2) { WorkerScoutTask.Task.Stopped = true; WorkerScoutTask.Task.Clear(); FourRaxSuspected = true; } } if (SuspectBanshees && Completed(UnitTypes.HYDRALISK) < 10) { QueenInjectTask.DefenseRadius = 12; } else { QueenInjectTask.DefenseRadius = 10; } WorkerTask.Task.StopTransfers = SuspectBanshees && Completed(UnitTypes.HYDRALISK) < 10; if (SuspectBanshees) { DefenseTask.GroundDefenseTask.ExpandDefenseRadius = 14; DefenseTask.AirDefenseTask.ExpandDefenseRadius = 14; DefenseTask.GroundDefenseTask.MainDefenseRadius = 20; DefenseTask.AirDefenseTask.MainDefenseRadius = 20; } else if (SmellCheese && Completed(UnitTypes.HYDRALISK) <= 20) { DefenseTask.GroundDefenseTask.ExpandDefenseRadius = 14; } else { DefenseTask.GroundDefenseTask.ExpandDefenseRadius = 20; } DefenseTask.AirDefenseTask.MaxDefenseRadius = 100; DefenseTask.GroundDefenseTask.MaxDefenseRadius = 100; if (SuspectBanshees) { if (Natural.Owner == tyr.PlayerId) { IdleTask.Task.OverrideTarget = Natural.BaseLocation.Pos; } else { IdleTask.Task.OverrideTarget = Main.BaseLocation.Pos; } } if (SmellCheese && !ProxyCannons && Completed(UnitTypes.ZERGLING) < 20 && Count(UnitTypes.HYDRALISK_DEN) == 0) { GasWorkerTask.WorkersPerGas = 0; } else { BalanceGas(); } /* * if ((Tyr.Bot.EnemyStrategyAnalyzer.ThreeGateDetected || (Tyr.Bot.EnemyStrategyAnalyzer.Count(UnitTypes.GATEWAY) == 0 && tyr.Frame >= 22.4 * 60 * 2)) * && !Tyr.Bot.EnemyStrategyAnalyzer.Expanded * && tyr.EnemyRace == Race.Protoss * && Tyr.Bot.Frame <= 22.4 * 60 * 3.5) * SmellCheese = true; */ if (!ProxyCannons) { foreach (Unit enemy in tyr.Enemies()) { if (enemy.UnitType == UnitTypes.PHOTON_CANNON && SC2Util.DistanceSq(enemy.Pos, tyr.MapAnalyzer.StartLocation) <= 40 * 40) { ProxyCannons = true; break; } } } OverlordScoutTask.Task.ScoutMain = true; if ( tyr.EnemyStrategyAnalyzer.Count(UnitTypes.MARINE) + tyr.EnemyStrategyAnalyzer.Count(UnitTypes.VIKING_FIGHTER) + tyr.EnemyStrategyAnalyzer.Count(UnitTypes.STALKER) > 0 || tyr.EnemyStrategyAnalyzer.Count(UnitTypes.PHOTON_CANNON) >= 3) { OverlordScoutTask.Task.Stopped = true; OverlordScoutTask.Task.Clear(); } else if (SuspectBanshees) { OverlordScoutTask.Task.ScoutLocation = tyr.MapAnalyzer.GetEnemyRamp(); if (OverlordScoutTask.Task.ScoutLocation != null) { Unit supplyDepot = null; int distances = 0; foreach (Unit enemy in tyr.Enemies()) { if (enemy.UnitType != UnitTypes.SUPPLY_DEPOT && enemy.UnitType != UnitTypes.SUPPLY_DEPOT_LOWERED) { continue; } if (SC2Util.DistanceSq(OverlordScoutTask.Task.ScoutLocation, enemy.Pos) > 5 * 5) { continue; } if (tyr.MapAnalyzer.WallDistances[(int)enemy.Pos.X, (int)enemy.Pos.Y] < distances) { continue; } supplyDepot = enemy; distances = tyr.MapAnalyzer.WallDistances[(int)enemy.Pos.X, (int)enemy.Pos.Y]; } if (supplyDepot != null) { OverlordScoutTask.Task.ScoutLocation = SC2Util.To2D(supplyDepot.Pos); tyr.DrawText("SupplyDepot WallDistance: " + distances); } } } }
public override void OnFrame(Tyr tyr) { if (Stopped) { Clear(); return; } HashSet <Base> bases = new HashSet <Base>(); foreach (Base b in tyr.BaseManager.Bases) { if (b.Owner == tyr.PlayerId && (b != tyr.BaseManager.Main || !ExcludeMain)) { bases.Add(b); } } if (bases.Count == 0) { Clear(); return; } Dictionary <Base, int> defenderCounts = new Dictionary <Base, int>(); foreach (Agent agent in units) { if (AssignedBases.ContainsKey(agent.Unit.Tag)) { if (bases.Contains(AssignedBases[agent.Unit.Tag])) { AddDefender(defenderCounts, AssignedBases[agent.Unit.Tag]); } else { AssignedBases.Remove(agent.Unit.Tag); } } } tyr.DrawText("Distribute bases count: " + bases.Count); int maxDefenders; if (bases.Count > 0) { maxDefenders = units.Count / bases.Count; } else { maxDefenders = units.Count; } foreach (Agent agent in units) { if (!AssignedBases.ContainsKey(agent.Unit.Tag)) { continue; } Base assignedBase = AssignedBases[agent.Unit.Tag]; if (defenderCounts[assignedBase] <= maxDefenders + 1) { continue; } defenderCounts[assignedBase]--; AssignedBases.Remove(agent.Unit.Tag); } int basePos = 0; Base[] baseArray = new Base[bases.Count]; bases.CopyTo(baseArray); foreach (Agent agent in units) { if (AssignedBases.ContainsKey(agent.Unit.Tag)) { continue; } while (Count(defenderCounts, baseArray[basePos]) >= maxDefenders) { basePos++; if (basePos >= baseArray.Length) { basePos = 0; maxDefenders++; } } AssignedBases.Add(agent.Unit.Tag, baseArray[basePos]); AddDefender(defenderCounts, baseArray[basePos]); } foreach (Agent agent in units) { Base target = AssignedBases[agent.Unit.Tag]; if (agent.DistanceSq(target.BaseLocation.Pos) >= 6 * 6 && (agent.Unit.Orders == null || agent.Unit.Orders.Count == 0 || tyr.Frame % 10 == 0)) { tyr.MicroController.Attack(agent, target.BaseLocation.Pos); } } }
public void OnFrame(Tyr tyr) { Counts = new Dictionary <uint, int>(); CompletedCounts = new Dictionary <uint, int>(); HashSet <ulong> existingUnits = new HashSet <ulong>(); foreach (Base b in tyr.BaseManager.Bases) { b.BuildingCounts = new Dictionary <uint, int>(); b.BuildingsCompleted = new Dictionary <uint, int>(); } ActiveOrders = new HashSet <uint>(); FoodExpected = 0; // Update our unit set. foreach (Unit unit in tyr.Observation.Observation.RawData.Units) { if (unit.Owner == tyr.PlayerId) { // Count how many of each unitType we have. CollectionUtil.Increment(Counts, unit.UnitType); if (UnitTypes.EquivalentTypes.ContainsKey(unit.UnitType)) { foreach (uint t in UnitTypes.EquivalentTypes[unit.UnitType]) { CollectionUtil.Increment(Counts, t); } } if (unit.BuildProgress >= 0.9999f) { CollectionUtil.Increment(CompletedCounts, unit.UnitType); if (UnitTypes.EquivalentTypes.ContainsKey(unit.UnitType)) { foreach (uint t in UnitTypes.EquivalentTypes[unit.UnitType]) { CollectionUtil.Increment(CompletedCounts, t); } } } if (unit.Orders != null && unit.Orders.Count > 0 && Abilities.Creates.ContainsKey(unit.Orders[0].AbilityId)) { CollectionUtil.Increment(Counts, Abilities.Creates[unit.Orders[0].AbilityId]); } if (unit.BuildProgress < 1 && unit.UnitType == UnitTypes.PYLON) { FoodExpected += 8; } if (unit.Orders != null && unit.Orders.Count > 0 && unit.Orders[0].AbilityId == 1344) { FoodExpected += 8; } if (unit.Orders != null && unit.Orders.Count > 0 && unit.Orders[0].AbilityId == 1216) { CollectionUtil.Increment(Counts, UnitTypes.LAIR); } if (unit.UnitType == UnitTypes.EGG) { CollectionUtil.Increment(Counts, Abilities.Creates[unit.Orders[0].AbilityId]); } existingUnits.Add(unit.Tag); if (Agents.ContainsKey(unit.Tag)) { Agent agent = Agents[unit.Tag]; agent.Unit = unit; if (unit.UnitType == UnitTypes.LARVA && agent.LastAbility >= 0 && Abilities.Creates.ContainsKey((uint)agent.LastAbility)) { CollectionUtil.Increment(Counts, Abilities.Creates[(uint)agent.LastAbility]); } agent.Command = null; if (agent.Base != null) { CollectionUtil.Increment(agent.Base.BuildingCounts, unit.UnitType); if (unit.BuildProgress >= 0.9999f) { CollectionUtil.Increment(agent.Base.BuildingsCompleted, unit.UnitType); } } } else { if (DisappearedUnits.ContainsKey(unit.Tag)) { Agents.Add(unit.Tag, DisappearedUnits[unit.Tag]); DisappearedUnits[unit.Tag].Unit = unit; } else { Agent agent = new Agent(unit); Agents.Add(unit.Tag, agent); tyr.TaskManager.NewAgent(agent); } } if (unit.Orders != null && unit.Orders.Count > 0) { ActiveOrders.Add(unit.Orders[0].AbilityId); } } } foreach (BuildRequest request in ConstructionTask.Task.BuildRequests) { // Count how many of each unitType we intend to build. CollectionUtil.Increment(Counts, request.Type); if (request.Type == UnitTypes.PYLON) { FoodExpected += 8; } if (request.Base != null) { CollectionUtil.Increment(request.Base.BuildingCounts, request.Type); } if (request.worker.Unit.Orders == null || request.worker.Unit.Orders.Count == 0 || request.worker.Unit.Orders[0].AbilityId != BuildingType.LookUp[request.Type].Ability) { tyr.ReservedMinerals += BuildingType.LookUp[request.Type].Minerals; tyr.ReservedGas += BuildingType.LookUp[request.Type].Gas; string workerAbility = ""; if (request.worker.Unit.Orders != null && request.worker.Unit.Orders.Count > 0) { workerAbility = " Ability: " + request.worker.Unit.Orders[0].AbilityId; } tyr.DrawText("Reserving: " + BuildingType.LookUp[request.Type].Name + workerAbility); } } foreach (BuildRequest request in ConstructionTask.Task.UnassignedRequests) { // Count how many of each unitType we intend to build. CollectionUtil.Increment(Counts, request.Type); FoodExpected += 8; if (request.Base != null) { CollectionUtil.Increment(request.Base.BuildingCounts, request.Type); } tyr.ReservedMinerals += BuildingType.LookUp[request.Type].Minerals; tyr.ReservedGas += BuildingType.LookUp[request.Type].Gas; tyr.DrawText("Reserving: " + BuildingType.LookUp[request.Type].Name); } // Remove dead units. if (tyr.Observation != null && tyr.Observation.Observation != null && tyr.Observation.Observation.RawData != null && tyr.Observation.Observation.RawData.Event != null && tyr.Observation.Observation.RawData.Event.DeadUnits != null) { foreach (ulong deadUnit in tyr.Observation.Observation.RawData.Event.DeadUnits) { Agents.Remove(deadUnit); } } }
public override void OnFrame(Tyr tyr) { if (tyr.EnemyRace == Race.Protoss) { TimingAttackTask.Task.RequiredSize = 45; TimingAttackTask.Task.RetreatSize = 8; } else { TimingAttackTask.Task.RequiredSize = 70; TimingAttackTask.Task.RetreatSize = 20; } tyr.DrawText("Extractors: " + Count(UnitTypes.EXTRACTOR)); DefenseTask.Task.MainDefenseRadius = 20; DefenseTask.Task.ExpandDefenseRadius = 14; DefenseTask.Task.MaxDefenseRadius = 55; IdleTask.Task.FearEnemies = true; GoingBroodlords = tyr.EnemyRace == Race.Protoss && Completed(UnitTypes.HYDRALISK_DEN) > 0 && Completed(UnitTypes.LURKER_DEN) > 0 && Count(UnitTypes.HATCHERY) + Count(UnitTypes.LAIR) + Count(UnitTypes.HIVE) >= 2; if (tyr.EnemyRace != Race.Protoss) { tyr.DrawScreen("Wrong race.", 12, 0.65f, 0.18f); } else if (Completed(UnitTypes.HYDRALISK_DEN) == 0) { tyr.DrawScreen("No hydra den", 12, 0.65f, 0.18f); } else if (Completed(UnitTypes.LURKER_DEN) == 0) { tyr.DrawScreen("No lurker den", 12, 0.65f, 0.18f); } else if (Count(UnitTypes.HATCHERY) + Count(UnitTypes.LAIR) + Count(UnitTypes.HIVE) < 2) { tyr.DrawScreen("Not enough bases. Hatch: " + Count(UnitTypes.HATCHERY) + " Lair: " + Count(UnitTypes.LAIR) + " Hive: " + Count(UnitTypes.HIVE), 12, 0.65f, 0.18f); } else if (GoingBroodlords) { tyr.DrawScreen("Going broodlords", 12, 0.65f, 0.18f); } else { tyr.DrawScreen("Not going broodlords", 12, 0.65f, 0.18f); } if (tyr.EnemyRace == Race.Protoss) { RequiredZerglings = 0; } if (Count(UnitTypes.HYDRALISK) - 10 >= (Count(UnitTypes.LURKER) + Count(UnitTypes.LURKER_BURROWED)) * 2) { MorphingTask.Task.Morph(UnitTypes.LURKER); } if (Completed(UnitTypes.LAIR) > 0 && Count(UnitTypes.OVERSEER) < 2) { MorphingTask.Task.Morph(UnitTypes.OVERSEER); } if (FoodUsed() + Tyr.Bot.UnitManager.Count(UnitTypes.HATCHERY) * 2 + Tyr.Bot.UnitManager.Count(UnitTypes.LAIR) * 2 + Tyr.Bot.UnitManager.Count(UnitTypes.HIVE) * 2 >= ExpectedAvailableFood() - 2) { MorphingTask.Task.Morph(UnitTypes.OVERLORD); } else if (Count(UnitTypes.DRONE) >= 14 && Count(UnitTypes.SPAWNING_POOL) == 0) { } else if (ExpectedAvailableFood() > FoodUsed() + 2 && Count(UnitTypes.DRONE) < 45 - Completed(UnitTypes.EXTRACTOR) && (Count(UnitTypes.DRONE) < 40 - Completed(UnitTypes.EXTRACTOR) || Count(UnitTypes.HATCHERY) >= 3) && (Count(UnitTypes.ZERGLING) >= RequiredZerglings || Count(UnitTypes.DRONE) <= 18) && (Count(UnitTypes.LAIR) > 0 || Count(UnitTypes.DRONE) <= 24)) { MorphingTask.Task.Morph(UnitTypes.DRONE); } else if (Completed(UnitTypes.SPAWNING_POOL) > 0 && Count(UnitTypes.ZERGLING) < RequiredZerglings && ExpectedAvailableFood() > FoodUsed() + 4 && (Count(UnitTypes.SPINE_CRAWLER) >= 2 || Minerals() >= 200)) { MorphingTask.Task.Morph(UnitTypes.ZERGLING); } else if (Completed(UnitTypes.HYDRALISK_DEN) > 0 && (Count(UnitTypes.HYDRALISK) < 15 || Count(UnitTypes.LURKER_DEN) > 0) && (Count(UnitTypes.HYDRALISK) - 20 < Count(UnitTypes.LURKER) * 2 || Gas() >= 150) && ExpectedAvailableFood() > FoodUsed() + 4 && !GoingBroodlords) { MorphingTask.Task.Morph(UnitTypes.HYDRALISK); } }
public override void OnFrame(Tyr tyr) { tyr.NexusAbilityManager.PriotitizedAbilities.Add(1568); ProxyTask.Task.UseCloseHideLocation = true; tyr.buildingPlacer.BuildCompact = true; tyr.TargetManager.PrefferDistant = false; tyr.TargetManager.TargetAllBuildings = true; TrainStep.WarpInLocation = ProxyTask.Task.GetHideLocation(); if (!printed) { foreach (Agent agent in Tyr.Bot.Units()) { if (agent.Unit.UnitType != UnitTypes.PYLON) { continue; } if (agent.Unit.BuildProgress < 1) { continue; } if (agent.DistanceSq(TrainStep.WarpInLocation) >= 30 * 30) { continue; } printed = true; } } if (StutterController.Toward == null && tyr.TargetManager.PotentialEnemyStartLocations.Count == 1 && Completed(UnitTypes.WARP_PRISM) > 0) { Point2D enemyBaseCenter = new PotentialHelper(tyr.TargetManager.PotentialEnemyStartLocations[0], 12).To(WarpPrismElevatorTask.Task.StagingArea).Get(); StutterController.Toward = new PotentialHelper(enemyBaseCenter, 6).From(tyr.MapAnalyzer.GetEnemyRamp()).Get(); } if (Completed(UnitTypes.IMMORTAL) < RequiredImmortals) { TimingAttackTask.Task.RequiredSize = 8; TimingAttackTask.Task.RetreatSize = 4; } else { TimingAttackTask.Task.RequiredSize = 4; TimingAttackTask.Task.RetreatSize = 0; } ProxyTask.Task.Stopped = Count(UnitTypes.GATEWAY) == 0; if (ProxyTask.Task.Stopped) { ProxyTask.Task.Clear(); } if (DefendProxyTask.Base == Main) { Point2D proxyLocation = ProxyTask.Task.GetHideLocation(); if (proxyLocation != null) { DefendProxyTask.OverrideDefenseLocation = proxyLocation; DefendProxyTask.OverrideIdleLocation = proxyLocation; foreach (Base b in tyr.BaseManager.Bases) { if (SC2Util.DistanceSq(b.BaseLocation.Pos, proxyLocation) <= 20 * 20) { DefendProxyTask.Base = b; } } } } if (UpgradeType.LookUp[UpgradeType.WarpGate].Progress() >= 0.5 && IdleTask.Task.OverrideTarget == null && (tyr.EnemyRace != Race.Protoss || tyr.Frame >= 22.4 * 4 * 60)) { DefendProxyTask.Stopped = false; } else { DefendProxyTask.Stopped = AdeptHarass.Get().DetectedPreviously; } tyr.DrawText("DefendProxyTask.Stopped: " + DefendProxyTask.Stopped); if (DefendProxyTask.Stopped) { DefendProxyTask.Clear(); } if (DropInMain && (Completed(UnitTypes.WARP_PRISM) > 0 || tyr.Frame >= 22.4 * 6 * 60)) { WarpPrismElevatorTask.Task.Stopped = false; } else { WarpPrismElevatorTask.Task.Stopped = true; WarpPrismElevatorTask.Task.Clear(); } if (Completed(UnitTypes.OBSERVER) > 0) { StalkerAttackNaturalController.Stopped = true; } if (!DefendReapers && tyr.EnemyStrategyAnalyzer.Count(UnitTypes.REAPER) > 0 && UpgradeType.LookUp[UpgradeType.WarpGate].Done()) { foreach (Unit enemy in tyr.Enemies()) { if (enemy.UnitType != UnitTypes.REAPER) { continue; } if (SC2Util.DistanceSq(enemy.Pos, tyr.MapAnalyzer.StartLocation) <= 30 * 30) { DefendReapers = true; ReaperDefenseTask.MaxDefenders = 1; break; } } } }
public override void OnFrame(Tyr tyr) { if (tyr.Observation.ActionErrors != null) { foreach (ActionError error in tyr.Observation.ActionErrors) { DebugUtil.WriteLine("Error with ability " + error.AbilityId + ": " + error.Result); } } if (!EcoCheeseSuspected && tyr.EnemyStrategyAnalyzer.Expanded && tyr.Frame <= 22.4 * 60 * 2 && tyr.EnemyStrategyAnalyzer.Count(UnitTypes.GATEWAY) == 0) { EcoCheeseSuspected = true; } if (tyr.EnemyStrategyAnalyzer.Count(UnitTypes.STALKER) + tyr.EnemyStrategyAnalyzer.Count(UnitTypes.ADEPT) > 0 || tyr.EnemyStrategyAnalyzer.Count(UnitTypes.ZEALOT) >= 3) { EcoCheeseSuspected = false; } BunkerDefendersTask.Task.LeaveBunkers = EcoCheeseSuspected; MarineHarassController.Disabled = !EcoCheeseSuspected; if ((tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.STALKER) >= 7 || (tyr.EnemyStrategyAnalyzer.Count(UnitTypes.GATEWAY) >= 3 && tyr.EnemyStrategyAnalyzer.Count(UnitTypes.CYBERNETICS_CORE) > 0)) && tyr.Frame < 22.4 * 60f * 3.5) { FourGateStalkerSuspected = true; } StalkerEmergency = FourGateStalkerSuspected && (Completed(UnitTypes.SIEGE_TANK) < 2 || Completed(UnitTypes.MARAUDER) < 4) && Completed(UnitTypes.MARAUDER) + Completed(UnitTypes.MARINE) + Completed(UnitTypes.SIEGE_TANK) + Completed(UnitTypes.CYCLONE) < 15; if (FourGateStalkerSuspected && ((Completed(UnitTypes.SIEGE_TANK) >= 2 && Completed(UnitTypes.MARAUDER) >= 3) || Count(UnitTypes.COMMAND_CENTER) >= 2)) { IdleTask.Task.OverrideTarget = SC2Util.Point((tyr.MapAnalyzer.GetMainRamp().X + Natural.BaseLocation.Pos.X) / 2f, (tyr.MapAnalyzer.GetMainRamp().Y + Natural.BaseLocation.Pos.Y) / 2f); } else { IdleTask.Task.OverrideTarget = null; } SiegeAtRampTask.Task.Stopped = !FourGateStalkerSuspected || Count(UnitTypes.THOR) > 0; SiegeBelowRampTask.Task.Stopped = !FourGateStalkerSuspected || Count(UnitTypes.THOR) > 0; if (FourGateStalkerSuspected && Completed(UnitTypes.SIEGE_TANK) < 2 && Completed(UnitTypes.THOR) < 2 && Count(UnitTypes.COMMAND_CENTER) > Completed(UnitTypes.COMMAND_CENTER) && Tyr.Bot.EnemyStrategyAnalyzer.TotalCount(UnitTypes.STARGATE) == 0) { foreach (Agent agent in tyr.UnitManager.Agents.Values) { if (agent.Unit.UnitType == UnitTypes.COMMAND_CENTER && agent.Unit.BuildProgress < 0.99) { agent.Order(Abilities.CANCEL); } } } tyr.TargetManager.TargetCannons = true; if (!OraclesDetected && tyr.EnemyStrategyAnalyzer.Count(UnitTypes.ORACLE) > 0) { OraclesDetectedFrame = tyr.Frame; } OraclesDetected = tyr.Frame - OraclesDetectedFrame < 30 * 22.4; if (Tyr.Bot.EnemyStrategyAnalyzer.TotalCount(UnitTypes.COLOSUS) + Tyr.Bot.EnemyStrategyAnalyzer.TotalCount(UnitTypes.ROBOTICS_BAY) + Tyr.Bot.EnemyStrategyAnalyzer.TotalCount(UnitTypes.ROBOTICS_FACILITY) > 0) { CollosusSuspected = true; } if (CollosusSuspected || tyr.EnemyStrategyAnalyzer.Count(UnitTypes.TEMPEST) > 0 || CannonsDetected) { DesiredVikings = 10; } else if (SkyTossDetected) { DesiredVikings = 5; } foreach (Task task in DefenseSquadTask.Tasks) { task.Stopped = !OraclesDetected; if (!OraclesDetected) { task.Clear(); } task.Priority = 8; } if (ZealotRushConfirmed) { TimingAttackTask.Task.RequiredSize = 20; TimingAttackTask.Task.RetreatSize = 6; } else if (EcoCheeseSuspected) { TimingAttackTask.Task.RequiredSize = 3; TimingAttackTask.Task.RetreatSize = 0; } else if (Completed(UnitTypes.COMMAND_CENTER) < 2 || FourGateStalkerSuspected || tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.TEMPEST) > 0) { TimingAttackTask.Task.RequiredSize = 40; TimingAttackTask.Task.RetreatSize = 10; } else if (CollosusSuspected) { if (Completed(UnitTypes.VIKING_FIGHTER) == 0) { TimingAttackTask.Task.Clear(); TimingAttackTask.Task.Stopped = true; } else { TimingAttackTask.Task.Stopped = false; } TimingAttackTask.Task.RequiredSize = 40; } else if (WorkerRushDetected) { TimingAttackTask.Task.RequiredSize = 8; TimingAttackTask.Task.RetreatSize = 0; } else if (DTsSuspected) { TimingAttackTask.Task.RequiredSize = 25; TimingAttackTask.Task.RetreatSize = 8; } else if (CannonsDetected) { TimingAttackTask.Task.RequiredSize = 15; TimingAttackTask.Task.RetreatSize = 8; } else { TimingAttackTask.Task.RequiredSize = 30; TimingAttackTask.Task.RetreatSize = 10; } tyr.DrawText("Attack sent: " + TimingAttackTask.Task.AttackSent); tyr.DrawText("RequiredSize: " + TimingAttackTask.Task.RequiredSize); if (!GatewayPushDetected) { if (tyr.EnemyStrategyAnalyzer.Count(UnitTypes.CYBERNETICS_CORE) > 0 && tyr.EnemyStrategyAnalyzer.Count(UnitTypes.GATEWAY) >= 3) { GatewayPushDetected = true; } if (tyr.EnemyStrategyAnalyzer.Count(UnitTypes.ADEPT) > 0) { GatewayPushDetected = true; } if (tyr.EnemyStrategyAnalyzer.Count(UnitTypes.STALKER) >= 3) { GatewayPushDetected = true; } } if (GatewayPushDetected) { WorkerScoutTask.Task.Stopped = true; WorkerScoutTask.Task.Clear(); } if (tyr.EnemyStrategyAnalyzer.Count(UnitTypes.GATEWAY) > 0 && tyr.Frame >= 22.4 * 90 && tyr.Frame < 22.4 * 110) { WorkerScoutTask.Task.Stopped = true; WorkerScoutTask.Task.Clear(); } if (tyr.EnemyStrategyAnalyzer.Count(UnitTypes.ASSIMILATOR) + tyr.EnemyStrategyAnalyzer.Count(UnitTypes.CYBERNETICS_CORE) > 0 && tyr.Frame >= 22.4 * 75 && tyr.Frame < 22.4 * 110) { WorkerScoutTask.Task.Stopped = true; WorkerScoutTask.Task.Clear(); } if ((ZealotRushSuspected || tyr.EnemyStrategyAnalyzer.Count(UnitTypes.PHOTON_CANNON) > 0 || WorkerRushDetected) && tyr.Frame >= 22.4 * 110) { WorkerScoutTask.Task.Stopped = true; WorkerScoutTask.Task.Clear(); } if (FourGateStalkerSuspected) { DefenseTask.AirDefenseTask.ExpandDefenseRadius = 15; DefenseTask.GroundDefenseTask.ExpandDefenseRadius = 15; DefenseTask.GroundDefenseTask.MainDefenseRadius = 20; } else { DefenseTask.AirDefenseTask.ExpandDefenseRadius = 20; DefenseTask.GroundDefenseTask.ExpandDefenseRadius = 20; } DefenseTask.AirDefenseTask.MaxDefenseRadius = 80; DefenseTask.GroundDefenseTask.MaxDefenseRadius = 80; RepairTask.Task.WallIn = WallIn; TransformTask.Task.HellionsToHellbats(); TransformTask.Task.ThorsToSingleTarget(); if (!ZealotRushConfirmed && Tyr.Bot.EnemyRace == Race.Protoss && tyr.Frame < 22.4 * 60 * 4 && Tyr.Bot.EnemyStrategyAnalyzer.TotalCount(UnitTypes.ZEALOT) >= 5) { ZealotRushConfirmed = true; } if (ZealotRushConfirmed && Completed(UnitTypes.HELLION) + Completed(UnitTypes.HELLBAT) + Completed(UnitTypes.MARAUDER) < 6) { foreach (Agent agent in tyr.UnitManager.Agents.Values) { if (agent.Unit.UnitType == UnitTypes.COMMAND_CENTER && agent.Unit.BuildProgress < 0.99 && agent.DistanceSq(Main.BaseLocation.Pos) >= 4 * 4) { agent.Order(Abilities.CANCEL); } } } if (!ZealotRushSuspected && Tyr.Bot.EnemyRace == Race.Protoss) { if ((Tyr.Bot.Frame >= 22.4 * 60 * 1.5 && !Tyr.Bot.EnemyStrategyAnalyzer.NoProxyGatewayConfirmed) || (Tyr.Bot.Frame < 22.4 * 60 * 1.5 && Tyr.Bot.EnemyStrategyAnalyzer.ThreeGateDetected)) { ZealotRushSuspected = true; } } if (!CannonsDetected) { if (tyr.EnemyStrategyAnalyzer.Count(UnitTypes.PHOTON_CANNON) > 0 || tyr.EnemyStrategyAnalyzer.Count(UnitTypes.FORGE) > 0) { CannonsDetected = true; } } if (WorkerRushDefenseTask.Task.WorkerRushHappening) { WorkerRushDetected = true; } tyr.OrbitalAbilityManager.SaveEnergy = 100; if (tyr.Frame >= (int)(22.4 * 60f * 2.5) && !EarlyScanSet && tyr.EnemyStrategyAnalyzer.Count(UnitTypes.GATEWAY) == 1 && tyr.EnemyStrategyAnalyzer.Count(UnitTypes.FORGE) == 0 && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.STALKER) == 0 && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.ADEPT) == 0 && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.ADEPT_PHASE_SHIFT) == 0) { EarlyScanSet = true; tyr.OrbitalAbilityManager.ScanCommands.Add(new ScanCommand() { Pos = tyr.TargetManager.PotentialEnemyStartLocations[0], FromFrame = (int)(22.4 * 60 * 3) }); } if (tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.GATEWAY) >= 2 && (tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.CYBERNETICS_CORE) + tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.ASSIMILATOR) + tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.STALKER) + tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.ADEPT) + tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.ADEPT_PHASE_SHIFT) > 0) && tyr.Frame >= 22.4 * 60f * 2.5 && !ScanTimingsSet) { ScanTimingsSet = true; if (!EarlyScanSet) { EarlyScanSet = true; tyr.OrbitalAbilityManager.ScanCommands.Add(new ScanCommand() { Pos = tyr.TargetManager.PotentialEnemyStartLocations[0], FromFrame = (int)(22.4 * 60 * 3) }); } tyr.OrbitalAbilityManager.ScanCommands.Add(new ScanCommand() { Pos = tyr.TargetManager.PotentialEnemyStartLocations[0], FromFrame = (int)(22.4 * 60 * 11.5) }); tyr.OrbitalAbilityManager.ScanCommands.Add(new ScanCommand() { Pos = tyr.MapAnalyzer.GetEnemyNatural().Pos, FromFrame = (int)(22.4 * 60 * 11.5 + 22.4) }); } if (!GatewayPushDetected && !ScanTimingsSet && tyr.Frame >= 22.4 * 60f * 2.75) { ScanTimingsSet = true; tyr.OrbitalAbilityManager.ScanCommands.Add(new ScanCommand() { Pos = tyr.TargetManager.PotentialEnemyStartLocations[0], FromFrame = (int)(22.4 * 60 * 4) }); tyr.OrbitalAbilityManager.ScanCommands.Add(new ScanCommand() { Pos = tyr.TargetManager.PotentialEnemyStartLocations[0], FromFrame = (int)(22.4 * 60 * 5.5) }); tyr.OrbitalAbilityManager.ScanCommands.Add(new ScanCommand() { Pos = tyr.MapAnalyzer.GetEnemyNatural().Pos, FromFrame = (int)(22.4 * 60 * 5.5 + 22.4) }); } if (tyr.EnemyStrategyAnalyzer.Count(UnitTypes.DARK_SHRINE) + tyr.EnemyStrategyAnalyzer.Count(UnitTypes.DARK_TEMPLAR) + tyr.EnemyStrategyAnalyzer.Count(UnitTypes.TWILIGHT_COUNSEL) > 0) { DTsSuspected = true; } if (tyr.EnemyStrategyAnalyzer.Count(UnitTypes.STARGATE) + tyr.EnemyStrategyAnalyzer.Count(UnitTypes.VOID_RAY) + tyr.EnemyStrategyAnalyzer.Count(UnitTypes.CARRIER) + tyr.EnemyStrategyAnalyzer.Count(UnitTypes.INTERCEPTOR) + tyr.EnemyStrategyAnalyzer.Count(UnitTypes.TEMPEST) + tyr.EnemyStrategyAnalyzer.Count(UnitTypes.PHOENIX) + tyr.EnemyStrategyAnalyzer.Count(UnitTypes.ORACLE) > 0) { SkyTossDetected = true; } if (tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.TEMPEST) > 0) { TimingAttackTask.Task.CustomControllers = new List <CustomController>(); TransformTask.Task.Priority = 10; } }
public override void OnFrame(Tyr tyr) { if (FourRaxSuspected && Gas() >= 200) { GasWorkerTask.WorkersPerGas = 1; } else if (FourRaxSuspected && Minerals() <= 200 && Count(UnitTypes.STALKER) < 10) { GasWorkerTask.WorkersPerGas = 2; } else { BalanceGas(); } if (WorkerScoutTask.Task.BaseCircled()) { WorkerScoutTask.Task.Stopped = true; WorkerScoutTask.Task.Clear(); } CloakedBanshee = TotalEnemyCount(UnitTypes.BANSHEE) > 0; WaitForDetectionController.Stopped = !CloakedBanshee; tyr.DrawText("CloakedBanshee: " + CloakedBanshee); WorkerScoutTask.Task.StartFrame = 600; ObserverScoutTask.Task.Priority = 6; /* * if (TotalEnemyCount(UnitTypes.BANSHEE) > 0 || FourRaxSuspected) * ForwardProbeTask.Task.Stopped = true; * else if (Completed(UnitTypes.IMMORTAL) >= 2) * ForwardProbeTask.Task.Stopped = false; * else if (Completed(UnitTypes.STALKER) + Count(UnitTypes.IMMORTAL) < 4) * ForwardProbeTask.Task.Stopped = true; * * if (ForwardProbeTask.Task.Stopped) * ForwardProbeTask.Task.Clear(); */ tyr.NexusAbilityManager.Stopped = Count(UnitTypes.STALKER) == 0 && tyr.Frame >= 120 * 22.4; tyr.NexusAbilityManager.PriotitizedAbilities.Add(917); if (tyr.EnemyStrategyAnalyzer.Count(UnitTypes.BATTLECRUISER) > 0) { BattlecruisersDetected = true; } if (tyr.EnemyStrategyAnalyzer.FourRaxDetected) { FourRaxSuspected = true; } if (ProxyDetected.Get().Detected) { FourRaxSuspected = true; } if (WorkerScoutTask.Task.BaseCircled() && tyr.Frame < 22.4 * 60 * 2 && TotalEnemyCount(UnitTypes.BARRACKS) == 0) { FourRaxSuspected = true; } if (!FourRaxSuspected) { Point2D enemyRamp = tyr.MapAnalyzer.GetEnemyRamp(); int enemyBarrackWallCount = 0; foreach (Unit enemy in tyr.Enemies()) { if (enemyRamp == null) { break; } if (enemy.UnitType == UnitTypes.BARRACKS && SC2Util.DistanceSq(enemy.Pos, enemyRamp) <= 5.5 * 5.5) { enemyBarrackWallCount++; } } if (enemyBarrackWallCount >= 2) { WorkerScoutTask.Task.Stopped = true; WorkerScoutTask.Task.Clear(); FourRaxSuspected = true; } } if (FourRaxSuspected) { tyr.TargetManager.TargetAllBuildings = true; FallBackController.Stopped = true; } tyr.TargetManager.SkipPlanetaries = true; ForceFieldRampTask.Task.Stopped = !FourRaxSuspected || Completed(UnitTypes.STALKER) >= 18; if (ForceFieldRampTask.Task.Stopped) { ForceFieldRampTask.Task.Clear(); } if (FourRaxSuspected && Completed(UnitTypes.STALKER) < 10) { foreach (Agent agent in tyr.Units()) { if (agent.Unit.UnitType != UnitTypes.NEXUS) { continue; } if (agent.Unit.BuildProgress >= 0.99) { continue; } agent.Order(Abilities.CANCEL); } } tyr.DrawText("Defending units: " + DefenseTask.GroundDefenseTask.Units.Count); tyr.DrawText("Is defending: " + DefenseTask.GroundDefenseTask.IsDefending()); if (FourRaxSuspected) { TimingAttackTask.Task.RequiredSize = 18; } else { TimingAttackTask.Task.RequiredSize = 4; TimingAttackTask.Task.RetreatSize = 0; } foreach (WorkerDefenseTask task in WorkerDefenseTask.Tasks) { task.Stopped = Completed(UnitTypes.ZEALOT) >= 5; } if (tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.REAPER) >= 3 || tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.BANSHEE) > 0) { TimingAttackTask.Task.DefendOtherAgents = false; } if (Count(UnitTypes.NEXUS) <= 1) { IdleTask.Task.OverrideTarget = OverrideMainDefenseTarget; } else if (Count(UnitTypes.NEXUS) >= 3) { IdleTask.Task.OverrideTarget = OverrideDefenseTarget; } else { IdleTask.Task.OverrideTarget = null; } if (FourRaxSuspected && Completed(UnitTypes.STALKER) < 18) { DefenseTask.GroundDefenseTask.BufferZone = 0; DefenseTask.GroundDefenseTask.ExpandDefenseRadius = 20; DefenseTask.GroundDefenseTask.MainDefenseRadius = 20; DefenseTask.GroundDefenseTask.MaxDefenseRadius = 120; DefenseTask.GroundDefenseTask.DrawDefenderRadius = 80; } else { DefenseTask.GroundDefenseTask.ExpandDefenseRadius = 30; DefenseTask.GroundDefenseTask.MainDefenseRadius = 30; DefenseTask.GroundDefenseTask.MaxDefenseRadius = 120; DefenseTask.GroundDefenseTask.DrawDefenderRadius = 80; } DefenseTask.AirDefenseTask.ExpandDefenseRadius = 30; DefenseTask.AirDefenseTask.MainDefenseRadius = 30; DefenseTask.AirDefenseTask.MaxDefenseRadius = 120; DefenseTask.AirDefenseTask.DrawDefenderRadius = 80; if (Tyr.Bot.EnemyStrategyAnalyzer.EarlyPool && !Tyr.Bot.EnemyStrategyAnalyzer.Expanded && Completed(UnitTypes.ZEALOT) < 2) { foreach (Agent agent in tyr.UnitManager.Agents.Values) { if (agent.Unit.UnitType == UnitTypes.NEXUS && agent.Unit.BuildProgress < 0.99) { agent.Order(Abilities.CANCEL); } } } }
public override void OnFrame(Tyr tyr) { tyr.DrawText("HydraTransitionFrame: " + HydraTransitionFrame); int enemyNaturalWorkerCount = 0; BaseLocation enemyNatural = tyr.MapAnalyzer.GetEnemyNatural(); bool enemyNaturalRemains = enemyNatural == null; foreach (Unit enemy in tyr.Enemies()) { if (enemyNatural == null) { break; } if (UnitTypes.ResourceCenters.Contains(enemy.UnitType) && !enemy.IsFlying && SC2Util.DistanceSq(enemy.Pos, enemyNatural.Pos) < 2 * 2) { enemyNaturalRemains = true; continue; } if (!UnitTypes.WorkerTypes.Contains(enemy.UnitType)) { continue; } if (SC2Util.DistanceSq(enemy.Pos, enemyNatural.Pos) > 14 * 14) { continue; } enemyNaturalWorkerCount++; } bool zerglingInEnemyNatural = false; foreach (Agent agent in tyr.UnitManager.Agents.Values) { if (agent.Unit.UnitType == UnitTypes.ZERGLING && agent.DistanceSq(enemyNatural.Pos) <= 10 * 10) { zerglingInEnemyNatural = true; } } if (AllowHydraTransition && HydraTransitionFrame >= 1000000000 && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.PHOTON_CANNON) >= 3) { HydraTransitionFrame = tyr.Frame; } if (AllowHydraTransition && HydraTransitionFrame >= 1000000000 && tyr.Frame >= 22.4 * 60 * 5.5) { HydraTransitionFrame = tyr.Frame; } if (AllowHydraTransition && HydraTransitionFrame >= 1000000000 && Count(UnitTypes.ZERGLING) >= 25 && zerglingInEnemyNatural && enemyNaturalWorkerCount == 0 && !enemyNaturalRemains) { HydraTransitionFrame = (int)(tyr.Frame + 22.4 * 10); } if (AllowHydraTransition && HydraTransitionFrame >= 1000000000 && Count(UnitTypes.ZERGLING) >= 25 && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.REAPER) >= 2) { HydraTransitionFrame = (int)(tyr.Frame + 22.4 * 10); } if (DefendEnemyNaturalTask != null) { DefendEnemyNaturalTask.Stopped = tyr.EnemyStrategyAnalyzer.Count(UnitTypes.PHOTON_CANNON) < 3 || tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.COLOSUS) > 0; if (DefendEnemyNaturalTask.Stopped) { DefendEnemyNaturalTask.Clear(); } } if (HydraTransitionFrame < 1000000000 || tyr.EnemyRace != Race.Terran) { OverlordSuicideTask.Task.Stopped = true; OverlordSuicideTask.Task.Clear(); } else { OverlordSuicideTask.Task.Stopped = false; } if (TimingAttackTask.Task.AttackSent && !OverlordSuicideTask.Task.Suicide) { foreach (Agent agent in tyr.UnitManager.Agents.Values) { if (agent.Unit.UnitType == UnitTypes.ZERGLING && agent.DistanceSq(tyr.TargetManager.PotentialEnemyStartLocations[0]) <= 80 * 80) { OverlordSuicideTask.Task.Suicide = true; } } } if (tyr.TargetManager.PotentialEnemyStartLocations.Count <= 1) { WorkerScoutTask.Task.Stopped = true; } if (UpgradeType.LookUp[UpgradeType.MetabolicBoost].Done()) { SafeZerglingsFromReapersTask.Task.Stopped = true; SafeZerglingsFromReapersTask.Task.Clear(); } if (MeleeUpgrade == 0 && Tyr.Bot.Observation.Observation.RawData.Player.UpgradeIds.Contains(53)) { MeleeUpgrade = 1; } else if (MeleeUpgrade == 1 && Tyr.Bot.Observation.Observation.RawData.Player.UpgradeIds.Contains(54)) { MeleeUpgrade = 2; } else if (MeleeUpgrade == 2 && Tyr.Bot.Observation.Observation.RawData.Player.UpgradeIds.Contains(55)) { MeleeUpgrade = 3; } if (ArmorUpgrade == 0 && Tyr.Bot.Observation.Observation.RawData.Player.UpgradeIds.Contains(56)) { ArmorUpgrade = 1; } else if (ArmorUpgrade == 1 && Tyr.Bot.Observation.Observation.RawData.Player.UpgradeIds.Contains(57)) { ArmorUpgrade = 2; } else if (ArmorUpgrade == 2 && Tyr.Bot.Observation.Observation.RawData.Player.UpgradeIds.Contains(58)) { ArmorUpgrade = 3; } ResearchingUpgrades = 0; for (uint ability = 1186; ability <= 1191; ability++) { if (Tyr.Bot.UnitManager.ActiveOrders.Contains(ability)) { ResearchingUpgrades++; } } if (!Tyr.Bot.Observation.Observation.RawData.Player.UpgradeIds.Contains(66) && !Tyr.Bot.UnitManager.ActiveOrders.Contains(1253)) { if (Gas() < 92) { GasWorkerTask.WorkersPerGas = 3; } else if (Gas() < 96) { GasWorkerTask.WorkersPerGas = 2; } else if (Gas() < 100) { GasWorkerTask.WorkersPerGas = 1; } else if (Gas() >= 100) { GasWorkerTask.WorkersPerGas = 0; } } else if (TimingAttackTask.Task.AttackSent || tyr.Frame >= HydraTransitionFrame) { GasWorkerTask.WorkersPerGas = 3; } else { GasWorkerTask.WorkersPerGas = 0; } if (tyr.EnemyStrategyAnalyzer.Count(UnitTypes.PHOTON_CANNON) >= 3 && Completed(UnitTypes.HYDRALISK) < 20 && Completed(UnitTypes.ZERGLING) >= 40) { TimingAttackTask.Task.Clear(); TimingAttackTask.Task.Stopped = true; } else { TimingAttackTask.Task.Stopped = false; } if (tyr.EnemyStrategyAnalyzer.Count(UnitTypes.PHOTON_CANNON) >= 3 && Completed(UnitTypes.ZERGLING) >= 40) { TimingAttackTask.Task.RequiredSize = 70; TimingAttackTask.Task.RetreatSize = 5; } else if (tyr.Frame >= HydraTransitionFrame && Count(UnitTypes.HYDRALISK) < 20 && !UpgradeType.LookUp[UpgradeType.MetabolicBoost].Done()) { TimingAttackTask.Task.RequiredSize = 50; TimingAttackTask.Task.RetreatSize = 5; } else if (tyr.Frame >= HydraTransitionFrame && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.COLOSUS) > 0) { TimingAttackTask.Task.RequiredSize = 40; TimingAttackTask.Task.RetreatSize = 8; } else if (tyr.Frame >= HydraTransitionFrame) { TimingAttackTask.Task.RequiredSize = 30; TimingAttackTask.Task.RetreatSize = 5; } else if (TimingAttackTask.Task.AttackSent) { TimingAttackTask.Task.RequiredSize = 20; TimingAttackTask.Task.RetreatSize = 0; } else { TimingAttackTask.Task.RequiredSize = 50; TimingAttackTask.Task.RetreatSize = 0; } DefenseTask.GroundDefenseTask.MainDefenseRadius = 20; DefenseTask.GroundDefenseTask.ExpandDefenseRadius = 18; DefenseTask.GroundDefenseTask.MaxDefenseRadius = 55; DefenseTask.AirDefenseTask.MainDefenseRadius = 20; DefenseTask.AirDefenseTask.ExpandDefenseRadius = 18; DefenseTask.AirDefenseTask.MaxDefenseRadius = 55; }
public override void OnFrame(Tyr tyr) { DefendMarines = tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.BARRACKS) >= 3 && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.REFINERY) == 0 && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.REAPER) == 0 && false; if (tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.REAPER) >= 3 && tyr.Frame <= 210 * 22.4) { DefendReapers = true; RequiredSize = 6; } if (RequiredSize > 6) { if (Completed(UnitTypes.CARRIER) >= 12) { RequiredSize = 6; } foreach (Unit enemy in tyr.Enemies()) { if ((enemy.UnitType == UnitTypes.MARAUDER || enemy.UnitType == UnitTypes.MARAUDER) && SC2Util.DistanceSq(tyr.MapAnalyzer.StartLocation, enemy.Pos) <= 40 * 40) { RequiredSize = 6; break; } } } foreach (Task task in WorkerDefenseTask.Tasks) { task.Stopped = true; } tyr.buildingPlacer.BuildCompact = true; WorkerTask.Task.StopTransfers = true; HideBaseTask.Task.MoveOutFrame = 672; ConstructionTask.Task.CancelBlockedBuildings = false; ConstructionTask.Task.OnlyCloseWorkers = false; ConstructionTask.Task.MaxWorkerDist = 30; tyr.NexusAbilityManager.PriotitizedAbilities.Add(948); tyr.NexusAbilityManager.PriotitizedAbilities.Add(950); tyr.DrawText("Required size: " + RequiredSize); FlyerAttackTask.Task.RequiredSize = RequiredSize; FlyerDestroyTask.Task.RequiredSize = RequiredSize; IdleTask.Task.FearEnemies = true; DefenseTask.AirDefenseTask.IgnoreEnemyTypes.Add(UnitTypes.VIKING_FIGHTER); if (Count(UnitTypes.PROBE) <= 6) { BaseWorkers.WorkersPerGas = 0; } else if (Count(UnitTypes.PROBE) <= 12) { BaseWorkers.WorkersPerGas = 1; } else if (Count(UnitTypes.PROBE) <= 18) { BaseWorkers.WorkersPerGas = 2; } else { BaseWorkers.WorkersPerGas = 3; } if (tyr.Frame == 118) { tyr.Chat("Time for some monobattles!"); } if (tyr.Frame == 163) { if (BuildCarriers) { tyr.Chat("I choose Carriers! :D"); } else { tyr.Chat("I choose Skillrays! :D"); } } if (!LiftingDetected) { foreach (Unit unit in tyr.Enemies()) { if (unit.IsFlying && UnitTypes.BuildingTypes.Contains(unit.UnitType)) { LiftingDetected = true; } } } if (LiftingDetected && tyr.EnemyManager.EnemyBuildings.Count == 0 && !ChasingLiftedBuildings) { ChasingLiftedBuildings = true; tyr.TaskManager.Add(new ElevatorChaserTask()); } if (!DefendRush && tyr.Frame <= 4800 && Tyr.Bot.EnemyRace != Race.Zerg) { int enemyCount = 0; foreach (Unit enemy in tyr.Enemies()) { if (SC2Util.DistanceSq(enemy.Pos, tyr.MapAnalyzer.StartLocation) <= 40 * 40) { enemyCount++; } } if (enemyCount >= 3) { DefendRush = true; } } if (Count(UnitTypes.STARGATE) > 0) { HideBaseTask.Task.BuildNexus = true; } }
public override void OnFrame(Tyr tyr) { BalanceGas(); FallBackController.Stopped = (Count(UnitTypes.NEXUS) < 3 && TimingAttackTask.Task.Units.Count == 0) || tyr.EnemyStrategyAnalyzer.EarlyPool || MassZerglings; StutterForwardController.Stopped = Count(UnitTypes.NEXUS) >= 3 || TimingAttackTask.Task.Units.Count > 0 || Completed(UnitTypes.ZEALOT) > 0; HodorTask.Task.Stopped = Count(UnitTypes.NEXUS) >= 3 || TimingAttackTask.Task.Units.Count > 0 || (tyr.EnemyStrategyAnalyzer.EarlyPool && Completed(UnitTypes.ZEALOT) >= 2); if (HodorTask.Task.Stopped) { HodorTask.Task.Clear(); } if (tyr.EnemyStrategyAnalyzer.EarlyPool || tyr.Frame >= 1800) { WorkerScoutTask.Task.Stopped = true; WorkerScoutTask.Task.Clear(); } HodorTask.Task.Target = WallIn.Wall[2].Pos; foreach (Agent agent in tyr.UnitManager.Agents.Values) { if (tyr.Frame % 224 != 0) { break; } if (agent.Unit.UnitType != UnitTypes.GATEWAY) { continue; } if (Count(UnitTypes.NEXUS) < 3 && TimingAttackTask.Task.Units.Count == 0) { agent.Order(Abilities.MOVE, Natural.BaseLocation.Pos); } else { agent.Order(Abilities.MOVE, tyr.TargetManager.PotentialEnemyStartLocations[0]); } } if (!MassZerglings && !tyr.EnemyStrategyAnalyzer.EarlyPool && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.ZERGLING) >= 60 && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.ROACH) == 0 && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.HYDRALISK) == 0) { MassZerglings = true; TimingAttackTask.Task.Clear(); } tyr.DrawText("Zergling count: " + tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.ZERGLING)); //WorkerScoutTask.Task.StartFrame = 600; ObserverScoutTask.Task.Priority = 6; ForwardProbeTask.Task.Stopped = Completed(UnitTypes.STALKER) + Count(UnitTypes.ADEPT) + Count(UnitTypes.IMMORTAL) < 12; if (ForwardProbeTask.Task.Stopped) { ForwardProbeTask.Task.Clear(); } if (tyr.EnemyStrategyAnalyzer.EarlyPool) { tyr.NexusAbilityManager.Stopped = Count(UnitTypes.ZEALOT) == 0; tyr.NexusAbilityManager.PriotitizedAbilities.Add(916); } tyr.NexusAbilityManager.PriotitizedAbilities.Add(917); if (tyr.EnemyStrategyAnalyzer.EarlyPool || MassZerglings) { TimingAttackTask.Task.RequiredSize = 24; } else { TimingAttackTask.Task.RequiredSize = 12; } TimingAttackTask.Task.RetreatSize = 0; foreach (WorkerDefenseTask task in WorkerDefenseTask.Tasks) { task.Stopped = Completed(UnitTypes.ZEALOT) >= 5; } if (Count(UnitTypes.NEXUS) >= 3) { IdleTask.Task.OverrideTarget = OverrideDefenseTarget; } else { IdleTask.Task.OverrideTarget = NaturalDefensePos; } DefenseTask.GroundDefenseTask.ExpandDefenseRadius = 30; DefenseTask.GroundDefenseTask.MainDefenseRadius = tyr.EnemyStrategyAnalyzer.EarlyPool ? 50 : 30; DefenseTask.GroundDefenseTask.MaxDefenseRadius = 120; DefenseTask.GroundDefenseTask.DrawDefenderRadius = 80; DefenseTask.AirDefenseTask.ExpandDefenseRadius = 30; DefenseTask.AirDefenseTask.MainDefenseRadius = 30; DefenseTask.AirDefenseTask.MaxDefenseRadius = 120; DefenseTask.AirDefenseTask.DrawDefenderRadius = 80; }
public override void OnFrame(Tyr tyr) { TimingAttackTask.Task.DefendOtherAgents = false; if (TotalEnemyCount(UnitTypes.BANSHEE) == 0 && Completed(UnitTypes.IMMORTAL) >= (DoubleRobo ? 4 : 2)) { TimingAttackTask.Task.RequiredSize = 4; } else { TimingAttackTask.Task.RequiredSize = RequiredSize; } if (!ImmortalNearEnemy) { foreach (Agent agent in tyr.Units()) { if (agent.Unit.UnitType == UnitTypes.IMMORTAL && agent.DistanceSq(tyr.TargetManager.PotentialEnemyStartLocations[0]) <= 20 * 20) { ImmortalNearEnemy = true; } } } tyr.DrawText("Immortal near enemey: " + ImmortalNearEnemy); if (AggressiveMicro && (ImmortalNearEnemy || tyr.Frame >= 22.4 * 60 * 5) && EnemyCount(UnitTypes.ZEALOT) == 0) { StutterForwardController.Stopped = false; StutterController.Stopped = true; } else { StutterForwardController.Stopped = true; StutterController.Stopped = false; } KillImmortals.Stopped = EnemyCount(UnitTypes.ZEALOT) >= 0; KillStalkers.Stopped = EnemyCount(UnitTypes.ZEALOT) >= 0; ScoutTask.Task.ScoutType = UnitTypes.PHOENIX; ScoutTask.Task.Target = tyr.TargetManager.PotentialEnemyStartLocations[0]; if (Count(UnitTypes.PHOENIX) > 0) { PhoenixScoutSent = true; } if (!PhoenixScoutSent && tyr.EnemyRace != SC2APIProtocol.Race.Zerg) { foreach (Agent agent in tyr.Units()) { if (agent.Unit.UnitType != UnitTypes.SENTRY) { continue; } if (agent.Unit.Energy < 75) { continue; } // Hallucinate scouting phoenix. agent.Order(154); } } }
public void LeapFrog(Tyr tyr) { List <Agent> tanks = GetTanks(); foreach (Agent tank in tanks) { if (tyr.MapAnalyzer.EnemyDistances[(int)tank.Unit.Pos.X, (int)tank.Unit.Pos.Y] <= 50 || tank.DistanceSq(tyr.TargetManager.PotentialEnemyStartLocations[0]) <= 20 * 20) { CurrentState = State.Kill; break; } } int tanksSieged = 0; int tanksUnsieged = 0; foreach (Agent agent in units) { if (agent.Unit.UnitType == UnitTypes.SIEGE_TANK) { tanksUnsieged++; } else if (agent.Unit.UnitType == UnitTypes.SIEGE_TANK_SIEGED) { if (UnsiegingTanks.Contains(agent.Unit.Tag)) { tanksUnsieged++; } else { tanksSieged++; } } } int allowedUnsiegedTanks = (tanksUnsieged + tanksSieged) / 2; if (allowedUnsiegedTanks < 2) { allowedUnsiegedTanks = 2; } List <Agent> potentialUnsiegers = GetPotentialUnsiegers(); foreach (Agent agent in potentialUnsiegers) { if (allowedUnsiegedTanks - tanksUnsieged <= 0) { break; } bool enemyClose = false; foreach (Unit enemy in tyr.Enemies()) { if (!UnitTypes.CanAttackGround(enemy.UnitType) && !UnitTypes.BuildingTypes.Contains(enemy.UnitType)) { continue; } if (!UnitTypes.RangedTypes.Contains(enemy.UnitType) && !UnitTypes.BuildingTypes.Contains(enemy.UnitType)) { continue; } if (enemy.IsFlying) { continue; } if (agent.DistanceSq(enemy) <= 13 * 13) { enemyClose = true; break; } } if (enemyClose) { tyr.DrawSphere(agent.Unit.Pos, 1, new Color() { R = 0, G = 255, B = 0 }); } } foreach (Agent agent in potentialUnsiegers) { if (allowedUnsiegedTanks - tanksUnsieged <= 0) { break; } bool enemyClose = false; foreach (Unit enemy in tyr.Enemies()) { if (!UnitTypes.CanAttackGround(enemy.UnitType) && !UnitTypes.BuildingTypes.Contains(enemy.UnitType)) { continue; } if (!UnitTypes.RangedTypes.Contains(enemy.UnitType) && !UnitTypes.BuildingTypes.Contains(enemy.UnitType)) { continue; } if (enemy.IsFlying) { continue; } if (agent.DistanceSq(enemy) <= 13 * 13) { enemyClose = true; break; } } if (enemyClose) { continue; } allowedUnsiegedTanks--; UnsiegingTanks.Add(agent.Unit.Tag); } float closestDistance = 1000000; foreach (Agent agent in Units) { if (UnsiegingTanks.Contains(agent.Unit.Tag)) { tyr.DrawSphere(agent.Unit.Pos); } if (agent.Unit.UnitType != UnitTypes.SIEGE_TANK_SIEGED || UnsiegingTanks.Contains(agent.Unit.Tag)) { continue; } tyr.DrawLine(agent, tyr.TargetManager.PotentialEnemyStartLocations[0]); float distSq = agent.DistanceSq(tyr.TargetManager.PotentialEnemyStartLocations[0]); if (distSq < closestDistance) { closestDistance = distSq; } } float minimumDist = (float)Math.Sqrt(closestDistance) + 8; float farthestDistance = 0; foreach (Agent agent in Units) { if (agent.Unit.UnitType != UnitTypes.SIEGE_TANK_SIEGED || UnsiegingTanks.Contains(agent.Unit.Tag)) { continue; } float distSq = agent.DistanceSq(tyr.TargetManager.PotentialEnemyStartLocations[0]); if (distSq >= minimumDist * minimumDist) { continue; } if (distSq > farthestDistance) { farthestDistance = distSq; } } farthestDistance = (float)Math.Sqrt(farthestDistance); closestDistance = (float)Math.Sqrt(closestDistance); tyr.DrawText("Closest tank dist: " + closestDistance); tyr.DrawText("Farthest tank dist: " + farthestDistance); foreach (Agent agent in Units) { if (agent.Unit.UnitType == UnitTypes.SIEGE_TANK) { if (!UnsiegingTanks.Contains(agent.Unit.Tag)) { agent.Order(Abilities.SIEGE); } else { float dist = agent.DistanceSq(tyr.TargetManager.PotentialEnemyStartLocations[0]); if (dist < (farthestDistance - 6) * (farthestDistance - 6) || dist < (closestDistance - 2) + (closestDistance - 2) && SufficientlySpread(agent)) { UnsiegingTanks.Remove(agent.Unit.Tag); agent.Order(Abilities.UNSIEGE); } else { Attack(agent, tyr.TargetManager.PotentialEnemyStartLocations[0]); } } } else if (agent.Unit.UnitType == UnitTypes.SIEGE_TANK_SIEGED) { if (UnsiegingTanks.Contains(agent.Unit.Tag)) { bool closeEnemy = false; foreach (Unit enemy in Tyr.Bot.Enemies()) { if (!UnitTypes.CanAttackGround(enemy.UnitType) && !UnitTypes.BuildingTypes.Contains(enemy.UnitType)) { continue; } if (!UnitTypes.RangedTypes.Contains(enemy.UnitType) && !UnitTypes.BuildingTypes.Contains(enemy.UnitType)) { continue; } if (enemy.IsFlying) { continue; } if (agent.DistanceSq(enemy) <= 13 * 13) { closeEnemy = true; break; } } if (!closeEnemy) { agent.Order(Abilities.UNSIEGE); } } } else { if (agent.Unit.UnitType == UnitTypes.HELLBAT || agent.Unit.UnitType == UnitTypes.HELLION || agent.Unit.UnitType == UnitTypes.MARINE) { Agent closestTank = null; float distance = 18 * 18; foreach (Agent tank in tanks) { float newDist = tank.DistanceSq(agent); if (newDist < distance) { closestTank = tank; distance = newDist; } } if (distance >= 5 * 5 && closestTank != null) { agent.Order(Abilities.MOVE, SC2Util.To2D(closestTank.Unit.Pos)); continue; } } Attack(agent, tyr.TargetManager.PotentialEnemyStartLocations[0]); } } }
public override void OnFrame(Tyr tyr) { if (units.Count == 0) { return; } Unit fleeEnemy = null; float dist = 10 * 10; foreach (Unit enemy in tyr.Enemies()) { if (!UnitTypes.AirAttackTypes.Contains(enemy.UnitType)) { continue; } float newDist = units[0].DistanceSq(enemy); if (newDist < dist) { fleeEnemy = enemy; dist = newDist; } } if (fleeEnemy != null) { PotentialHelper helper = new PotentialHelper(units[0].Unit.Pos); helper.Magnitude = 4; helper.From(fleeEnemy.Pos); units[0].Order(Abilities.MOVE, helper.Get()); tyr.DrawText("Raven fleeing!"); return; } if (tyr.Frame % 5 == 0) { return; } Point2D target = tyr.TargetManager.AttackTarget; Agent closest = null; dist = 1000000; foreach (Agent agent in tyr.UnitManager.Agents.Values) { if (!UnitTypes.CombatUnitTypes.Contains(agent.Unit.UnitType)) { continue; } float newDist = agent.DistanceSq(target); if (newDist < dist) { closest = agent; dist = newDist; } } int bases = 0; foreach (Base b in tyr.BaseManager.Bases) { if (b.ResourceCenter != null) { bases++; } } Point2D defenseLocation; if (bases >= 2) { defenseLocation = tyr.BaseManager.NaturalDefensePos; } else { defenseLocation = tyr.BaseManager.MainDefensePos; } foreach (Agent agent in units) { if (closest == null) { tyr.DrawText("Raven returning!"); agent.Order(Abilities.MOVE, defenseLocation); } else { tyr.DrawText("Raven moving out!"); agent.Order(Abilities.MOVE, SC2Util.To2D(closest.Unit.Pos)); } } }
public override void OnFrame(Tyr tyr) { BalanceGas(); ArchonMergeTask.Task.MergePos = OverrideDefenseTarget; FallBackController.Stopped = true; StutterForwardController.Stopped = Count(UnitTypes.NEXUS) >= 3 || TimingAttackTask.Task.Units.Count > 0 || Completed(UnitTypes.ZEALOT) > 0; if (!AggressiveZerglings && tyr.Frame <= 22.4 * 60 * 7) { int closeEnemyZerglingCount = 0; foreach (Unit enemy in tyr.Enemies()) { if (enemy.UnitType != UnitTypes.ZERGLING) { continue; } if (SC2Util.DistanceSq(enemy.Pos, tyr.MapAnalyzer.StartLocation) <= 50 * 50) { closeEnemyZerglingCount++; } } if (AggressiveZerglings) { tyr.DrawText("Close zerglings: " + closeEnemyZerglingCount); } if (closeEnemyZerglingCount >= 20) { AggressiveZerglings = true; } } if (AggressiveZerglings) { tyr.DrawText("Aggressive zerglings."); } int wallDone = 0; foreach (WallBuilding building in WallIn.Wall) { if (!BuildingType.LookUp.ContainsKey(building.Type)) { wallDone++; continue; } foreach (Agent agent in tyr.UnitManager.Agents.Values) { if (agent.DistanceSq(building.Pos) <= 1 * 1) { wallDone++; break; } } } tyr.DrawText("Wall count: " + wallDone); HodorTask.Task.Stopped = Count(UnitTypes.NEXUS) >= 3 || TimingAttackTask.Task.Units.Count > 0 || (tyr.EnemyStrategyAnalyzer.EarlyPool && Completed(UnitTypes.ZEALOT) >= 2) || wallDone < WallIn.Wall.Count; if (HodorTask.Task.Stopped) { HodorTask.Task.Clear(); } if (tyr.EnemyStrategyAnalyzer.EarlyPool || tyr.Frame >= 1800) { WorkerScoutTask.Task.Stopped = true; WorkerScoutTask.Task.Clear(); } HodorTask.Task.Target = WallIn.Wall[2].Pos; foreach (Agent agent in tyr.UnitManager.Agents.Values) { if (tyr.Frame % 224 != 0) { break; } if (agent.Unit.UnitType != UnitTypes.GATEWAY) { continue; } if (Count(UnitTypes.NEXUS) < 3 && TimingAttackTask.Task.Units.Count == 0) { agent.Order(Abilities.MOVE, Natural.BaseLocation.Pos); } else { agent.Order(Abilities.MOVE, tyr.TargetManager.PotentialEnemyStartLocations[0]); } } if (!MassZerglings && !tyr.EnemyStrategyAnalyzer.EarlyPool && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.ZERGLING) >= 60 && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.ROACH) == 0 && tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.HYDRALISK) == 0) { MassZerglings = true; TimingAttackTask.Task.Clear(); } tyr.DrawText("Zergling count: " + tyr.EnemyStrategyAnalyzer.TotalCount(UnitTypes.ZERGLING)); //WorkerScoutTask.Task.StartFrame = 600; ObserverScoutTask.Task.Priority = 6; ForwardProbeTask.Task.Stopped = Completed(UnitTypes.STALKER) + Count(UnitTypes.ADEPT) + Count(UnitTypes.IMMORTAL) < 12; if (ForwardProbeTask.Task.Stopped) { ForwardProbeTask.Task.Clear(); } if (tyr.EnemyStrategyAnalyzer.EarlyPool) { tyr.NexusAbilityManager.Stopped = Count(UnitTypes.ZEALOT) == 0; tyr.NexusAbilityManager.PriotitizedAbilities.Add(916); } tyr.NexusAbilityManager.PriotitizedAbilities.Add(917); if (UpgradeType.LookUp[UpgradeType.ProtossGroundWeapons1].Done()) { TimingAttackTask.Task.RequiredSize = 24; } else { TimingAttackTask.Task.RequiredSize = 40; } TimingAttackTask.Task.RetreatSize = 0; foreach (WorkerDefenseTask task in WorkerDefenseTask.Tasks) { task.Stopped = Completed(UnitTypes.ZEALOT) >= 5; } if (Count(UnitTypes.NEXUS) >= 3) { IdleTask.Task.OverrideTarget = OverrideDefenseTarget; } else { IdleTask.Task.OverrideTarget = NaturalDefensePos; } DefenseTask.GroundDefenseTask.ExpandDefenseRadius = 30; DefenseTask.GroundDefenseTask.MainDefenseRadius = tyr.EnemyStrategyAnalyzer.EarlyPool ? 50 : 30; DefenseTask.GroundDefenseTask.MaxDefenseRadius = 120; DefenseTask.GroundDefenseTask.DrawDefenderRadius = 80; DefenseTask.AirDefenseTask.ExpandDefenseRadius = 30; DefenseTask.AirDefenseTask.MainDefenseRadius = 30; DefenseTask.AirDefenseTask.MaxDefenseRadius = 120; DefenseTask.AirDefenseTask.DrawDefenderRadius = 80; }