public bool HasUnit(uint id) { if (GameConstants.IsWorker(id) || GameConstants.IsLarva(id)) { return(true); } if (id == BlizzardConstants.Unit.Hatchery) { return(intelManager.StructuresSelf().Any(u => (u.UnitType == id || u.UnitType == BlizzardConstants.Unit.Lair || u.UnitType == BlizzardConstants.Unit.Hive) && u.BuildProgress == 1f)); } if (id == BlizzardConstants.Unit.Lair) { return(intelManager.StructuresSelf().Any(u => (u.UnitType == id || u.UnitType == BlizzardConstants.Unit.Hive) && u.BuildProgress == 1f)); } return(intelManager.StructuresSelf().Any(u => u.UnitType == id && u.BuildProgress == 1f) || intelManager.UnitsSelf().Any(u => u.UnitType == id)); }
public void OnStart() { factories = new List <ProductionFacility>(); intelManager.StructuresSelf(BlizzardConstants.Unit.Factory, BlizzardConstants.Unit.FactoryReactor) .ToList().ForEach(b => factories.Add(new ProductionFacility(b))); squads = new Dictionary <string, Squad>(); unitToSquad = new Dictionary <ulong, string>(); currentSquad = squadRepo.Create(NextSquadName()); // Register handlers intelManager.Handler.RegisterHandler(Case.UnitAddedSelf, OnUnitBuilt); intelManager.Handler.RegisterHandler(Case.UnitDestroyed, OnUnitDestroyed); intelManager.Handler.RegisterHandler(Case.StructureAddedSelf, OnStructureBuilt); intelManager.Handler.RegisterHandler(Case.StructureDestroyed, OnStructureDestroyed); }
public void OnStart() { if (GameConstants.ParticipantRace != Race.Zerg) { return; } _queenSquadId = _squadRepo.Create("Queens").Id; var hatcheries = _squadRepo.Create("Hatcheries"); hatcheries.AddUnit(_intel.StructuresSelf().First(u => u.UnitType == BlizzardConstants.Unit.Hatchery)); _hatcheriesId = hatcheries.Id; _intel.Handler.RegisterHandler(Case.UnitAddedSelf, u => { if (u.UnitType == BlizzardConstants.Unit.Queen) { _squadRepo.Get().First(g => g.Name.Equals("Queens")).Units.Add(u); } }); _intel.Handler.RegisterHandler(Case.StructureAddedSelf, u => { if (u.UnitType == BlizzardConstants.Unit.Hatchery || u.UnitType == BlizzardConstants.Unit.Lair || u.UnitType == BlizzardConstants.Unit.Hive) { _squadRepo.Get().First(g => g.Name.Equals("Hatcheries")).Units.Add(u); } }); }
private bool ProduceUnit(ProductionOrder order) { var ids = techTree.GetProducersID(order.Unit); IUnit producer = null; if (GameConstants.RequiresTechLab(order.Unit.UnitId)) { producer = intelManager.StructuresSelf(ids).FirstOrDefault(b => b.AddOnTag != 0 && b.Orders.Count == 0 && GameConstants.IsTechLab(GetBuilding(b.AddOnTag).UnitType)); } else { producer = intelManager.StructuresSelf(ids).FirstOrDefault(b => b.BuildProgress == 1f && ((b.Orders.Count == 0) || (b.AddOnTag != 0 && GameConstants.IsReactor(GetBuilding(b.AddOnTag).UnitType) && b.Orders.Count < 2 && !GameConstants.IsReactorAbility(b.Orders.First().AbilityId)))); } if (producer == null || !ReserveRessource(order.Unit, false)) { return(false); } producer.Orders.Add(new UnitOrder()); // Fake order to prevent adding multiple units in same game loop order.Status = ProductionOrder.OrderStatus.Commissioned; rawManager.QueueActions(RawCommand(order.Unit.AbilityId, producer.Tag)); return(true); }
public void OnStart() { _mainBuildingTypes = new List <uint>(); switch (GameConstants.ParticipantRace) { case NydusNetwork.API.Protocol.Race.NoRace: break; case NydusNetwork.API.Protocol.Race.Terran: _mainBuildingTypes.Add(BlizzardConstants.Unit.CommandCenter); _mainBuildingTypes.Add(BlizzardConstants.Unit.OrbitalCommand); _mainBuildingTypes.Add(BlizzardConstants.Unit.PlanetaryFortress); workerType = BlizzardConstants.Unit.SCV; break; case NydusNetwork.API.Protocol.Race.Zerg: _mainBuildingTypes.Add(BlizzardConstants.Unit.Hatchery); _mainBuildingTypes.Add(BlizzardConstants.Unit.Lair); _mainBuildingTypes.Add(BlizzardConstants.Unit.Hive); workerType = BlizzardConstants.Unit.Drone; break; case NydusNetwork.API.Protocol.Race.Protoss: _mainBuildingTypes.Add(BlizzardConstants.Unit.Nexus); workerType = BlizzardConstants.Unit.Probe; break; case NydusNetwork.API.Protocol.Race.Random: break; } _mainBuildings = _squadRepository.Create("MainBuildings"); _refineries = _squadRepository.Create("Refineries"); _mainBuildings.AddUnit(_intel.StructuresSelf().First(u => _mainBuildingTypes.Contains(u.UnitType))); _intel.Handler.RegisterHandler(Case.StructureAddedSelf, u => { if (_mainBuildingTypes.Contains(u.UnitType)) { _mainBuildings.AddUnit(u); _baseAmount++; } if (GameConstants.RaceRefinery == u.UnitType) { _refineries.AddUnit(u); } }); }
public static List <IColony> GetOwnColonies(IIntelManager intelManager) { var ownColonies = new List <IColony>(); var commandCenters = intelManager.StructuresSelf() .Where(u => GameConstants.IsHeadquarter(u.UnitType)) .Where(u => u.BuildProgress > 0.98) .ToList(); foreach (var colony in intelManager.Colonies) { if (commandCenters.Any(cc => colony.Structures.Contains(cc))) { ownColonies.Add(colony); } } return(ownColonies); }
public void OnStart() { starports = new List <ProductionFacility>(); loneUnits = new HashSet <IUnit>(); fleet = squadRepo.Create(SQUAD_NAME); // Register handlers intelManager.Handler.RegisterHandler(Case.StructureAddedSelf, OnStructureBuilt); intelManager.Handler.RegisterHandler(Case.StructureDestroyed, OnStructureDestroyed); intelManager.Handler.RegisterHandler(Case.UnitAddedSelf, OnUnitBuilt); intelManager.Handler.RegisterHandler(Case.UnitDestroyed, OnUnitDestroyed); if (!intelManager.StructuresSelf(BlizzardConstants.Unit.Starport).Any()) { productionManager.QueueUnit(BlizzardConstants.Unit.Starport, lowPriority: true, desiredPosition: snapshot.LeastExpandedColony.Point, spacing: 2); } }
public void OnStep() { // Now the Combat Manager is not as forgiving. It expects specific commands and when an // invalid point/target/ability is given units will do nothing if (_intel.GameLoop > 9000 && _intel.GameLoop < 9300) { if (_first) { _log?.LogMessage("performing invalid actions every loop"); _first = false; } // Bogous point - never do this _combatManger.AttackMove(_lousBoys, new Point2D { X = -400, Y = 500 }); _combatManger.Move(_lousBoys, new Point2D { X = -400, Y = 500 }); // Bogous tag - never do this _combatManger.Attack(_lousBoys, 500); var BC = _lousBoys.Units.First(u => u.UnitType == BlizzardConstants.Unit.Battlecruiser); _combatManger.UseTargetlessAbility(BlizzardConstants.Ability.GeneralStimpack, BC.Tag); } // However if you give it correct input it will execute the command as given // even if you, like Lazy Lou dont want to attack the enemy, but your own base else if (_intel.GameLoop > 9300) { if (_second) { _log?.LogMessage("attacking every loop"); _second = false; } var ownBuilding = _intel.StructuresSelf().FirstOrDefault(); if (ownBuilding != null) { _combatManger.Attack(_lousBoys, ownBuilding.Tag); } } // Include the classname of this file in the setup file to see Lazy Lou get his battle cruiser (and a reprimand from the production manager) }
public void OnStep() { snapshot.UpdateState(intelManager); if (intelManager.GameLoop % 100 == 0) { Console.WriteLine("Attacking: " + snapshot.Attacking); Helpers.PrintProductionQueue(intelManager); activeTactics.ForEach(t => Console.WriteLine(t.GetType().Name)); } // 0. Build basic econ and defense startupSequenceDone = CheckStartupDone(); // 1. Assess threats? (10%) var ownUnitCount = intelManager.UnitsSelf().Count(); var enemyUnitCount = intelManager.UnitsEnemy().Count(); if (snapshot.BaseThreats.Sum(kv => kv.Value.Count) > (0.1 * ownUnitCount)) { snapshot.Attacking = false; snapshot.EconomyMode = EconomyMode.Standby; } else if (ownUnitCount > enemyUnitCount * 1.2) { snapshot.Attacking = true; snapshot.EconomyMode = EconomyMode.Expand; } else { snapshot.Attacking = false; // Build up as default snapshot.EconomyMode = EconomyMode.Expand; } // 2. Coordinate modules if (intelManager.StructuresSelf(BlizzardConstants.Unit.Barracks).Any() && !IsTacticActive(typeof(InfantryModule))) { AddTactic(new InfantryModule(snapshot, intelManager, productionManager, combatManager, squadRepo)); } if (startupSequenceDone) { if (!infantryUpgraded) { QueueInfantryUpgrades(); infantryUpgraded = true; } if (intelManager.GameLoop > 900 && // 1 m 30 sec? !IsTacticActive(typeof(MechModule))) { AddTactic(new MechModule(snapshot, intelManager, productionManager, combatManager, squadRepo)); } if (intelManager.GameLoop > 3000 && // 5 m? !IsTacticActive(typeof(AirModule))) { AddTactic(new AirModule(snapshot, intelManager, productionManager, combatManager, squadRepo)); } } // 3. Try to be ahead on supply if (snapshot.RemainingSupply < 10 && !IsBuildingSupplyDepot()) { productionManager.QueueUnit(BlizzardConstants.Unit.SupplyDepot, lowPriority: true, desiredPosition: snapshot.LeastExpandedColony.Point); } }
public static List <IUnit> CompletedStructuresSelf(IIntelManager intelManager, params uint[] types) { var structsSelf = intelManager.StructuresSelf(types).ToList(); return(intelManager.StructuresSelf(types).Where(BuildCompleted).ToList()); }
public IntelResponse BundleIntel(IntelRequest request) { AbathurMap map = null; if (request.Map) { map = new AbathurMap { } } ; Score score = null; if (request.Score) { score = _intel.CurrentScore; } PlayerCommon playerCommon = null; if (request.Common) { playerCommon = _intel.Common; } ICollection <UpgradeData> upgradeSelf = null; if (request.UpgradesSelf) { upgradeSelf = _intel.UpgradesSelf; } ICollection <IUnit> alliedBuilding = null; if (request.BuildingsSelf) { alliedBuilding = _intel.StructuresSelf().ToList(); } ICollection <IUnit> alliedWorkers = null; if (request.WorkersSelf) { alliedWorkers = _intel.WorkersSelf().ToList(); } ICollection <IUnit> alliedUnits = null; if (request.WorkersSelf) { alliedUnits = _intel.UnitsSelf().ToList(); } ICollection <IUnit> structuresEnemy = null; if (request.StructuresEnemy) { structuresEnemy = _intel.WorkersEnemy().ToList(); } ICollection <IUnit> unitsEnemy = null; if (request.UnitsEnemy) { unitsEnemy = _intel.WorkersEnemy().ToList(); } ICollection <IUnit> workersEnemy = null; if (request.WorkersEnemy) { workersEnemy = _intel.WorkersEnemy().ToList(); } IColony primaryColony = null; if (request.PrimaryColony) { primaryColony = _intel.PrimaryColony; } IEnumerable <IColony> colonies = null; if (request.Colonies) { colonies = _intel.Colonies; } ICollection <IUnit> mineralFields = null; if (request.MineralFields) { mineralFields = _intel.MineralFields.ToList(); } ICollection <IUnit> vespeneGeysers = null; if (request.VespeneGeysers) { vespeneGeysers = _intel.VespeneGeysers.ToList(); } ICollection <IUnit> destructibles = null; if (request.Destructibles) { destructibles = _intel.Destructibles().ToList(); } ICollection <UnitTypeData> productionQueue = null; if (request.ProductionQueue) { productionQueue = _intel.ProductionQueue.ToList(); } IEnumerable <Squad> squads = null; if (request.Squads) { squads = _squadRepo.Get(); } uint gameloop = 0; if (request.GameLoop) { gameloop = _intel.GameLoop; } return(new IntelResponse { Map = map, Score = score, Common = playerCommon, UpgradesSelf = { upgradeSelf }, BuildingsSelf = { Convert(alliedBuilding) }, WorkersSelf = { Convert(alliedWorkers) }, UnitsSelf = { Convert(alliedUnits) }, StructuresEnemy = { Convert(structuresEnemy) }, WorkersEnemy = { Convert(workersEnemy) }, UnitsEnemy = { Convert(unitsEnemy) }, PrimaryColony = Convert(primaryColony), Colonies = { Convert(colonies.ToList()) }, MineralFields = { Convert(mineralFields) }, VespeneGeysers = { Convert(vespeneGeysers) }, Destructibles = { Convert(destructibles) }, ProductionQueue = { productionQueue }, Squads = { squads.Select(Convert) }, GameLoop = gameloop }); }