コード例 #1
0
        private IUnit GetWorker(IPosition position)
        {
            position = position ?? intelManager.PrimaryColony;
            var worker = position.GetClosest(intelManager.WorkersSelf().Where(o => o.Orders.Count == 0));

            if (worker != null)
            {
                worker.Orders.Add(new UnitOrder {
                });                                   // Add decoy order to prevent it from being used this frame.
                return(worker);
            }
            var minerals = intelManager.MineralFields.Select(mf => mf.Tag);

            return(worker = position.GetClosest(intelManager.WorkersSelf().Where(o => o.Orders.Count == 1 && minerals.Contains(o.Orders.First().TargetUnitTag))));
        }
コード例 #2
0
        public void OnStep()
        {
            if (intelManager.GameLoop % 100 == 0)
            {
                state.OwnColonies.ForEach(c =>
                                          Console.WriteLine($"Col: {c.Id}, workers: {c.Workers.Count} / {OptimalMineralWorkers(c)}"));
                Console.WriteLine($"Total workers {intelManager.WorkersSelf().Count()}");
            }

            if (intelManager.GameLoop % 5 == 0)             // We don't need to be that high-frequency..
            {
                switch (state.EconomyMode)
                {
                case EconomyMode.Standby:
                    // TODO: call down MULEs
                    break;

                case EconomyMode.Expand:
                    state.OwnColonies.ForEach(FillColonyWorkers);

                    if (intelManager.GameLoop > 600 &&
                        state.OwnColonies.All(c => GetEconomyState(c) == EconomyState.Saturated || GetEconomyState(c) == EconomyState.Surplus) &&
                        !intelManager.ProductionQueue.Any(u => u.UnitId == BlizzardConstants.Unit.CommandCenter))
                    {
                        var expansionSpot = FindExpansionSpace();
                        productionManager.QueueUnit(BlizzardConstants.Unit.CommandCenter,
                                                    desiredPosition: expansionSpot.Point, lowPriority: true);
                    }
                    break;
                }

                BalanceWorkers();
            }
        }
コード例 #3
0
        public void OnStep()
        {
            var workerAmount = _intel.WorkersSelf().Count();

            if (!_intel.ProductionQueue.Any() && workerAmount < _baseAmount * 16)
            {
                for (int i = _intel.WorkersSelf().Count(); i < _baseAmount * 16; i++)
                {
                    _productionManager.QueueUnit(workerType);
                }
            }
            else if (!_intel.ProductionQueue.Any())   //TODO Seemingly 4 SCV's get stuck in the production queue but is never made(using AutoExpand and AutoSupply)
            {
                var curCol = _mainBuildings.Units.First();
                //TODO Use AStar distance rather than a Euclidian distance
                var nextCol = _intel.Colonies.OrderBy(c => MathServices.EuclidianDistance(curCol.Point, c.Point)).FirstOrDefault(col => col.Structures.Count == 0);
                if (nextCol != null)
                {
                    _productionManager.QueueUnit(_mainBuildingTypes.First(), nextCol.Point, 3);//TODO the placement algorithm does not take mineral spacing from HQ's into account and giving a spacing of 3 will make other objects block the HQ's
                }
            }
        }
コード例 #4
0
ファイル: AutoScouter.cs プロジェクト: codedjinn/Abathur
        public void OnStart()
        {
            _scouting = false;
            _eStart   = _intel.Colonies.First(c => c.IsStartingLocation).Point;
            _scout    = _intel.WorkersSelf().FirstOrDefault();
            if (_scout == null)
            {
                _logger.LogWarning("No Scout available. AutoScouter doing nothing."); return;
            }

            _intel.Handler.RegisterHandler(Case.WorkerDestroyed, u => {
                if (u.Tag == _scout.Tag)
                {
                    _scout = _intel.WorkersSelf().FirstOrDefault(sc => sc.Tag != _scout.Tag);
                    if (_scout == null)
                    {
                        _logger.LogWarning("No Scout available. AutoScouter doing nothing."); return;
                    }
                    _scouting = false;
                }
            });
        }
コード例 #5
0
        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
            });
        }