Пример #1
0
        Point2D GetBestTimeWarpLocation(IOrderedEnumerable <KeyValuePair <Point, float> > locations)
        {
            foreach (var location in locations)
            {
                if (location.Value < 150)
                {
                    return(null);
                }

                var placement = new Point2D {
                    X = location.Key.X, Y = location.Key.Y
                };
                bool good = true;
                if (!MapDataService.SelfVisible(placement))
                {
                    continue;
                }

                if (good)
                {
                    return(placement);
                }
            }
            return(null);
        }
Пример #2
0
        public UnitManager(ActiveUnitData activeUnitData, SharkyUnitData sharkyUnitData, SharkyOptions sharkyOptions, TargetPriorityService targetPriorityService, CollisionCalculator collisionCalculator, MapDataService mapDataService, DebugService debugService, DamageService damageService, UnitDataService unitDataService)
        {
            ActiveUnitData = activeUnitData;

            SharkyUnitData        = sharkyUnitData;
            SharkyOptions         = sharkyOptions;
            TargetPriorityService = targetPriorityService;
            CollisionCalculator   = collisionCalculator;
            MapDataService        = mapDataService;
            DebugService          = debugService;
            DamageService         = damageService;
            UnitDataService       = unitDataService;

            ActiveUnitData.EnemyUnits   = new ConcurrentDictionary <ulong, UnitCalculation>();
            ActiveUnitData.SelfUnits    = new ConcurrentDictionary <ulong, UnitCalculation>();
            ActiveUnitData.NeutralUnits = new ConcurrentDictionary <ulong, UnitCalculation>();

            ActiveUnitData.Commanders = new ConcurrentDictionary <ulong, UnitCommander>();

            ActiveUnitData.DeadUnits = new List <ulong>();

            TargetPriorityCalculationFrame = 0;

            UndeadTypes = new List <UnitTypes> {
                UnitTypes.ZERG_BROODLING, UnitTypes.ZERG_EGG, UnitTypes.ZERG_LARVA, UnitTypes.TERRAN_KD8CHARGE, UnitTypes.ZERG_OVERLORD, UnitTypes.ZERG_OVERLORDCOCOON, UnitTypes.ZERG_OVERLORDTRANSPORT, UnitTypes.ZERG_TRANSPORTOVERLORDCOCOON
            };
        }
Пример #3
0
 public TargetingService(ActiveUnitData activeUnitData, MapDataService mapDataService, BaseData baseData, TargetingData targetingData)
 {
     ActiveUnitData = activeUnitData;
     MapDataService = mapDataService;
     BaseData       = baseData;
     TargetingData  = targetingData;
 }
Пример #4
0
 public ProxyLocationService(BaseData baseData, TargetingData targetingData, IPathFinder pathFinder, MapDataService mapDataService, AreaService areaService)
 {
     BaseData       = baseData;
     TargetingData  = targetingData;
     PathFinder     = pathFinder;
     MapDataService = mapDataService;
     AreaService    = areaService;
 }
Пример #5
0
 public ProtossBuildingPlacement(ActiveUnitData activeUnitData, SharkyUnitData sharkyUnitData, DebugService debugService, MapDataService mapDataService, BuildingService buildingService, IBuildingPlacement wallOffPlacement)
 {
     ActiveUnitData   = activeUnitData;
     SharkyUnitData   = sharkyUnitData;
     DebugService     = debugService;
     MapDataService   = mapDataService;
     BuildingService  = buildingService;
     WallOffPlacement = wallOffPlacement;
 }
Пример #6
0
 public MapController(MapDataService mapDataService,
                      ElevationMapService elevationMapService,
                      BitmapHelperService bitmapHelperService,
                      TopoMapService topoMapService)
 {
     MapDataService            = mapDataService;
     ElevationTransformService = elevationMapService;
     BitmapHelperService       = bitmapHelperService;
     TopoMapService            = topoMapService;
 }
        public JsonResult GetShowData(int?addressSysNo = null)
        {
            var companySysNo   = CurrUser.CompanySysNo;
            var mapDataService = new MapDataService(companySysNo);
            var result         = mapDataService.GetShowModel(addressSysNo);

            return(Json(new AjaxResult {
                Success = true, Data = result
            }));
        }
Пример #8
0
        bool UnloadUnits(UnitCommander commander, Point2D defensivePoint, int frame, out List <SC2APIProtocol.Action> action)
        {
            action = null;

            // TODO: if already unloading all return false and it will unload as it moves?

            if (commander.UnitCalculation.Unit.Orders.Any(o => o.AbilityId == (uint)Abilities.UNLOADALLAT_WARPPRISM || o.AbilityId == (uint)Abilities.UNLOADUNIT_WARPPRISM))
            {
                // if a unit has been in there for more than a second, warp prism must be on unloadable ground, move to a new area then try again
                if (commander.LoadTimes.Any(l => l.Value > 100))
                {
                    action = commander.Order(frame, Abilities.MOVE, defensivePoint);
                }

                return(true);
            }

            if (!MapDataService.PathWalkable(commander.UnitCalculation.Unit.Pos))
            {
                return(false);
            }

            foreach (var passenger in commander.UnitCalculation.Unit.Passengers)
            {
                if (!commander.LoadTimes.ContainsKey(passenger.Tag))
                {
                    commander.LoadTimes[passenger.Tag] = frame;
                }

                // use LoadTimes to calculate weapon cooldown
                if (commander.UnitCalculation.Unit.Shield + commander.UnitCalculation.Unit.Health < 50 || passenger.Shield > 25) // unload any units that regained shields, or if warp prism dying
                {
                    action = commander.UnloadSpecificUnit(frame, Abilities.UNLOADUNIT_WARPPRISM, passenger.Tag);
                    return(true);
                }
                else
                {
                    if (!ActiveUnitData.SelfUnits.ContainsKey(passenger.Tag))
                    {
                        action = commander.Order(frame, Abilities.UNLOADALLAT_WARPPRISM, null, commander.UnitCalculation.Unit.Tag);
                        return(true);
                    }
                    else
                    {
                        var weapon = ActiveUnitData.SelfUnits[passenger.Tag].Weapon;
                        if (weapon == null || (frame - commander.LoadTimes[passenger.Tag]) / SharkyOptions.FramesPerSecond > weapon.Speed) // unload any units ready to fire
                        {
                            action = commander.UnloadSpecificUnit(frame, Abilities.UNLOADUNIT_WARPPRISM, passenger.Tag);
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Пример #9
0
 public FindHiddenBaseTask(BaseData baseData, TargetingData targetingData, MapDataService mapDataService, IIndividualMicroController individualMicroController, int desiredCount = 15, bool enabled = true, float priority = -1f)
 {
     BaseData                  = baseData;
     TargetingData             = targetingData;
     MapDataService            = mapDataService;
     IndividualMicroController = individualMicroController;
     DesiredCount              = desiredCount;
     Priority                  = priority;
     Enabled        = enabled;
     UnitCommanders = new List <UnitCommander>();
 }
 public MyBansheeHarassTask(BaseData baseManager, TargetingData targetingData, MapDataService mapDataService, MyBansheeMicroController bansheeController, int desiredCount = 1, bool enabled = true, float priority = -1f)
 {
     BaseData               = baseManager;
     TargetingData          = targetingData;
     MapDataService         = mapDataService;
     BansheeMicroController = bansheeController;
     DesiredCount           = desiredCount;
     Priority               = priority;
     Enabled        = enabled;
     UnitCommanders = new List <UnitCommander>();
 }
Пример #11
0
 // TODO: if 5 dts have died, end the task
 public DarkTemplarHarassTask(BaseData baseData, TargetingData targetingData, MapDataService mapDataService, DarkTemplarMicroController darkTemplarMicroController, int desiredCount = 5, bool enabled = true, float priority = -1f)
 {
     BaseData                   = baseData;
     TargetingData              = targetingData;
     MapDataService             = mapDataService;
     DarkTemplarMicroController = darkTemplarMicroController;
     DesiredCount               = desiredCount;
     Priority                   = priority;
     Enabled        = enabled;
     UnitCommanders = new List <UnitCommander>();
 }
Пример #12
0
 public LateGameOracleHarassTask(BaseData baseData, TargetingData targetingData, MapDataService mapDataService, OracleMicroController oracleMicroController, int desiredCount = 2, bool enabled = true, float priority = -1f)
 {
     BaseData              = baseData;
     TargetingData         = targetingData;
     MapDataService        = mapDataService;
     OracleMicroController = oracleMicroController;
     DesiredCount          = desiredCount;
     Priority              = priority;
     Enabled        = enabled;
     UnitCommanders = new List <UnitCommander>();
 }
Пример #13
0
        bool NavigateToSupportUnit(UnitCommander commander, Point2D target, int frame, out List <SC2APIProtocol.Action> action)
        {
            if (MapDataService.PathWalkable(commander.UnitCalculation.Unit.Pos))                                                                                // if it is in unplaceable terrain, can't unload
            {
                if (commander.UnitCalculation.Unit.Shield + commander.UnitCalculation.Unit.Health < 50 || commander.UnitCalculation.EnemiesInRangeOf.Count > 0) // if warp prism dying or enemies nearby unload
                {
                    action = commander.Order(frame, Abilities.UNLOADALLAT_WARPPRISM, null, commander.UnitCalculation.Unit.Tag);
                    return(true);
                }

                foreach (var passenger in commander.UnitCalculation.Unit.Passengers)
                {
                    var passengerUnit = ActiveUnitData.Commanders[passenger.Tag].UnitCalculation.Unit;
                    var unit          = ActiveUnitData.Commanders[passenger.Tag].UnitCalculation;

                    foreach (var enemyAttack in commander.UnitCalculation.NearbyEnemies)
                    {
                        if (DamageService.CanDamage(unit, enemyAttack) && InRange(commander.UnitCalculation.Position, enemyAttack.Position, unit.Range + passengerUnit.Radius + enemyAttack.Unit.Radius) && MapDataService.MapHeight(commander.UnitCalculation.Unit.Pos) == MapDataService.MapHeight(enemyAttack.Unit.Pos))
                        {
                            if (!enemyAttack.UnitClassifications.Contains(UnitClassification.ArmyUnit) && !InRange(commander.UnitCalculation.Position, enemyAttack.Position, 2 + passengerUnit.Radius + enemyAttack.Unit.Radius))
                            {
                                continue;
                            }
                            // if an enemy is in range drop the unit
                            //action = commander.Order(frame, Abilities.UNLOADALLAT_WARPPRISM, null, commander.UnitCalculation.Unit.Tag); // TODO: dropping a specific unit not working, can only drop all, change it if they ever fix the api
                            action = commander.UnloadSpecificUnit(frame, Abilities.UNLOADUNIT_WARPPRISM, passenger.Tag);
                            return(true);
                        }
                    }
                }

                if (InRange(new Vector2(target.X, target.Y), commander.UnitCalculation.Position, 3)) // if made it to the target just drop
                {
                    action = commander.Order(frame, Abilities.UNLOADALLAT_WARPPRISM, null, commander.UnitCalculation.Unit.Tag);
                    return(true);
                }
            }

            if (commander.UnitCalculation.Unit.CargoSpaceMax > commander.UnitCalculation.Unit.CargoSpaceTaken && commander.UnitCalculation.Unit.Shield + commander.UnitCalculation.Unit.Health > 50) // find more units to load
            {
                var friendly = commander.UnitCalculation.NearbyAllies.Where(u => !u.Unit.IsFlying && u.Unit.BuildProgress == 1 && u.UnitClassifications.Contains(UnitClassification.ArmyUnit) && !commander.UnitCalculation.Unit.Passengers.Any(p => p.Tag == u.Unit.Tag) && commander.UnitCalculation.Unit.CargoSpaceMax - commander.UnitCalculation.Unit.CargoSpaceTaken >= UnitDataService.CargoSize((UnitTypes)u.Unit.UnitType) && u.EnemiesInRange.Count == 0 && u.EnemiesInRangeOf.Count == 0).OrderBy(u => Vector2.DistanceSquared(commander.UnitCalculation.Position, u.Position)).FirstOrDefault();

                if (friendly != null)
                {
                    action = commander.Order(frame, Abilities.LOAD, null, friendly.Unit.Tag);
                    return(true);
                }
            }

            action = commander.Order(frame, Abilities.MOVE, target);
            return(true);
        }
Пример #14
0
        public WorkerScoutTask(SharkyUnitData sharkyUnitData, TargetingData targetingData, MapDataService mapDataService, bool enabled, float priority, IIndividualMicroController individualMicroController, DebugService debugService, BaseData baseData, AreaService areaService)
        {
            SharkyUnitData            = sharkyUnitData;
            TargetingData             = targetingData;
            MapDataService            = mapDataService;
            Priority                  = priority;
            IndividualMicroController = individualMicroController;
            DebugService              = debugService;
            BaseData                  = baseData;
            AreaService               = areaService;

            UnitCommanders = new List <UnitCommander>();
            Enabled        = enabled;
        }
Пример #15
0
        public OracleWorkerHarassTask(TargetingData targetingData, BaseData baseData, ChatService chatService, MapDataService mapDataService, MapData mapData, OracleMicroController oracleMicroController, int desiredCount = 1, bool enabled = true, float priority = -1f)
        {
            TargetingData         = targetingData;
            BaseData              = baseData;
            ChatService           = chatService;
            MapDataService        = mapDataService;
            MapData               = mapData;
            OracleMicroController = oracleMicroController;

            DesiredCount = desiredCount;
            Enabled      = enabled;
            Priority     = priority;

            UnitCommanders = new List <UnitCommander>();
        }
Пример #16
0
        public IActionResult GetSatellite(float lat1, float lon1, float lat2, float lon2, int zoom = 9)
        {
            var request = new MapBBoxRequest()
            {
                Lon1    = lon1,
                Lon2    = lon2,
                Lat1    = lat1,
                Lat2    = lat2,
                MapName = "mapbox.satellite",
                Zoom    = zoom
            };
            var imageTask = MapDataService.GetBitmapForRegion(request);

            imageTask.Wait();
            return(File(BitmapHelperService.Bitmap2Bytes(imageTask.Result), "image/jpg"));
        }
Пример #17
0
        public IActionResult GetHeightMap(float lat1, float lon1, float lat2, float lon2, int zoom = 9)
        {
            var request = new MapBBoxRequest()
            {
                Lon1    = lon1,
                Lon2    = lon2,
                Lat1    = lat1,
                Lat2    = lat2,
                MapName = "mapbox.terrain-rgb",
                Zoom    = zoom
            };
            var imageTask = MapDataService.GetBitmapForRegion(request);

            imageTask.Wait();

            var heightMap = ElevationTransformService.TransformElevationToHeightMap(imageTask.Result);

            return(File(BitmapHelperService.Bitmap2Bytes(heightMap), "image/jpg"));
        }
Пример #18
0
        public List <SC2APIProtocol.Action> NavigateToPoint(UnitCommander commander, Point2D target, Point2D defensivePoint, Point2D groupCenter, int frame)
        {
            List <SC2APIProtocol.Action> action = null;

            if (PreOffenseOrder(commander, target, defensivePoint, null, null, frame, out action))
            {
                return(action);
            }

            if (MapDataService.InEnemyDetection(commander.UnitCalculation.Unit.Pos))
            {
                if (commander.UnitCalculation.NearbyEnemies.Count(e => e.DamageAir) > 0)
                {
                    if (commander.RetreatPathFrame + 20 < frame)
                    {
                        commander.RetreatPath      = SharkyPathFinder.GetSafeAirPath(target.X, target.Y, commander.UnitCalculation.Unit.Pos.X, commander.UnitCalculation.Unit.Pos.Y, frame);
                        commander.RetreatPathFrame = frame;
                    }

                    if (FollowPath(commander, frame, out action))
                    {
                        return(action);
                    }
                }

                if (AvoidTargettedDamage(commander, target, defensivePoint, frame, out action))
                {
                    return(action);
                }

                if (AvoidDamage(commander, target, defensivePoint, frame, out action))
                {
                    return(action);
                }
            }

            NavigateToTarget(commander, target, groupCenter, null, Formation.Normal, frame, out action);

            return(action);
        }
Пример #19
0
        public IActionResult GetElevation(float lat1, float lon1, float lat2, float lon2, int zoom = 9)
        {
            var request = new MapBBoxRequest()
            {
                Lon1    = lon1,
                Lon2    = lon2,
                Lat1    = lat1,
                Lat2    = lat2,
                MapName = "mapbox.terrain-rgb",
                Zoom    = zoom
            };
            var imageTask = MapDataService.GetBitmapForRegion(request);

            imageTask.Wait();

            var image = imageTask.Result;

            return(File(BitmapHelperService.Bitmap2Bytes(image), "image/jpg"));

            // return $"data:image/png;base64,{SigBase64}";
            // return $"COORD1 {lat1}, {lon1}";
        }
Пример #20
0
        public WarpPrismElevatorTask(TargetingData targetingData, IMicroController microController, WarpPrismMicroController warpPrismMicroController, ProxyLocationService proxyLocationService, MapDataService mapDataService, DebugService debugService, UnitDataService unitDataService, ActiveUnitData activeUnitData, ChatService chatService, AreaService areaService, List <DesiredUnitsClaim> desiredUnitsClaims, float priority, bool enabled = true)
        {
            TargetingData            = targetingData;
            MicroController          = microController;
            WarpPrismMicroController = warpPrismMicroController;
            ProxyLocationService     = proxyLocationService;
            MapDataService           = mapDataService;
            DebugService             = debugService;
            UnitDataService          = unitDataService;
            ActiveUnitData           = activeUnitData;
            AreaService = areaService;
            ChatService = chatService;

            DesiredUnitsClaims = desiredUnitsClaims;
            Priority           = priority;
            Enabled            = enabled;
            UnitCommanders     = new List <UnitCommander>();

            Enabled = true;

            PickupRangeSquared = 25;
        }
Пример #21
0
        public WorkerScoutGasStealTask(SharkyUnitData sharkyUnitData, TargetingData targetingData, MacroData macroData, MapDataService mapDataService,
                                       bool enabled, float priority, DebugService debugService, BaseData baseData, AreaService areaService, MapData mapData, BuildingService buildingService, ActiveUnitData activeUnitData)
        {
            SharkyUnitData  = sharkyUnitData;
            TargetingData   = targetingData;
            MacroData       = macroData;
            MapDataService  = mapDataService;
            Priority        = priority;
            DebugService    = debugService;
            BaseData        = baseData;
            AreaService     = areaService;
            BuildingService = buildingService;
            MapData         = mapData;
            ActiveUnitData  = activeUnitData;

            UnitCommanders = new List <UnitCommander>();
            Enabled        = enabled;

            BlockExpansion  = false;
            HidePylonInBase = false;
            BlockWall       = false;
        }
Пример #22
0
        bool StartWarping(UnitCommander commander, int frame, out List <SC2APIProtocol.Action> action)
        {
            action = null;

            if (!MapDataService.PathWalkable(commander.UnitCalculation.Unit.Pos))
            {
                return(false);
            }
            if (ActiveUnitData.Commanders.Values.Where(v => v.UnitCalculation.Unit.UnitType == (uint)UnitTypes.PROTOSS_WARPGATE && !v.UnitCalculation.Unit.IsActive && v.WarpInAlmostOffCooldown(frame, SharkyOptions.FramesPerSecond, SharkyUnitData)).Count() == 0)
            {
                return(false);
            }
            if (commander.UnitCalculation.Unit.Shield > 25 && !commander.UnitCalculation.NearbyAllies.Any(v => (v.Unit.UnitType == (uint)UnitTypes.PROTOSS_PYLON || v.Unit.UnitType == (uint)UnitTypes.PROTOSS_WARPPRISMPHASING) && DistanceSquared(commander.UnitCalculation, v) < 400)) // not near any pylons or other warping prisms
            {
                if (commander.UnitCalculation.Unit.UnitType == (uint)UnitTypes.PROTOSS_WARPPRISM)
                {
                    action = commander.Order(frame, Abilities.MORPH_WARPPRISMPHASINGMODE, allowSpam: true);
                    return(true);
                }
            }
            return(false);
        }
Пример #23
0
        public bool SupportArmy(UnitCommander commander, Point2D target, Point2D defensivePoint, Point2D groupCenter, int frame, out List <SC2APIProtocol.Action> action, IEnumerable <UnitCalculation> supportableUnits = null)
        {
            action = null;

            UpdateLoadTimes(commander);

            if (commander.UnitCalculation.Unit.Shield < commander.UnitCalculation.Unit.ShieldMax / 2)
            {
                if (AvoidTargettedDamage(commander, target, defensivePoint, frame, out action))
                {
                    return(true);
                }

                if (AvoidDamage(commander, target, defensivePoint, frame, out action))
                {
                    return(true);
                }

                if (commander.UnitCalculation.Unit.Shield < 1)
                {
                    if (Retreat(commander, target, defensivePoint, frame, out action))
                    {
                        return(true);
                    }
                }
            }

            // follow behind at the range of pickup
            var unitToSupport = GetSupportTarget(commander, target, defensivePoint, supportableUnits);

            if (unitToSupport == null)
            {
                return(false);
            }

            if (!commander.UnitCalculation.NearbyAllies.Any(a => a.Unit.Tag == unitToSupport.Unit.Tag))
            {
                if (Vector2.DistanceSquared(commander.UnitCalculation.Position, new Vector2(target.X, target.Y)) > Vector2.DistanceSquared(unitToSupport.Position, new Vector2(target.X, target.Y)))
                {
                    if (NavigateToSupportUnit(commander, target, frame, out action))
                    {
                        return(true);
                    }
                }
            }

            if (UnloadUnits(commander, defensivePoint, frame, out action))
            {
                return(true);
            }

            var moveTo = GetPickupSpot(new Point2D {
                X = unitToSupport.Unit.Pos.X, Y = unitToSupport.Unit.Pos.Y
            }, defensivePoint);

            if (commander.UnitCalculation.Unit.Orders.Any(o => o.AbilityId == (uint)Abilities.UNLOADALLAT_WARPPRISM || o.AbilityId == (uint)Abilities.UNLOADUNIT_WARPPRISM) || !MapDataService.PathWalkable(moveTo)) // TODO: does this groundpathable thing work right?
            {
                moveTo = new Point2D {
                    X = unitToSupport.Unit.Pos.X, Y = unitToSupport.Unit.Pos.Y
                };
            }

            if (InRange(new Vector2(moveTo.X, moveTo.Y), commander.UnitCalculation.Position, 2) && InRange(unitToSupport.Position, commander.UnitCalculation.Position, PickupRange))
            {
                //look at all units within pickup range, ordered by proximity to their closeest enemy
                // get average hp + shields of back
                // if unit is in front half weapon is off cooldown and (has below that hp + shields or could die in one hit) pick it up
                var friendliesInRange = commander.UnitCalculation.NearbyAllies.Where(u => !commander.UnitCalculation.Unit.Passengers.Any(p => p.Tag == u.Unit.Tag) && InRange(u.Position, commander.UnitCalculation.Position, PickupRange)).OrderBy(u => ClosestEnemyDistance(u));
                var frontHalf         = friendliesInRange.Take(friendliesInRange.Count() / 2);
                var backHalf          = friendliesInRange.Skip(friendliesInRange.Count() / 2);
                var backAverageHealth = backHalf.Sum(u => u.Unit.Health + u.Unit.Shield) / backHalf.Count();
                foreach (var friendly in frontHalf)
                {
                    if (commander.UnitCalculation.Unit.CargoSpaceMax - commander.UnitCalculation.Unit.CargoSpaceTaken >= UnitDataService.CargoSize((UnitTypes)friendly.Unit.UnitType))
                    {
                        if (ShouldLoadUnit(friendly, backAverageHealth, frame))
                        {
                            action = commander.Order(frame, Abilities.LOAD, null, friendly.Unit.Tag);
                            return(true);
                        }
                    }
                }

                if (friendliesInRange.Count() < 4)
                {
                    foreach (var friendly in friendliesInRange)
                    {
                        if (commander.UnitCalculation.Unit.CargoSpaceMax - commander.UnitCalculation.Unit.CargoSpaceTaken >= UnitDataService.CargoSize((UnitTypes)friendly.Unit.UnitType))
                        {
                            if (ShouldLoadUnit(friendly, friendly.Unit.Health + (friendly.Unit.ShieldMax / 2), frame))
                            {
                                if (friendly.Unit.WeaponCooldown > 0 && friendly.Unit.Shield < friendly.Unit.ShieldMax / 2)
                                {
                                    action = commander.Order(frame, Abilities.LOAD, null, friendly.Unit.Tag);
                                    return(true);
                                }
                            }
                        }
                    }
                }

                foreach (var friendly in friendliesInRange.Where(f => f.EnemiesInRangeOf.Count() > 0 && f.Range > 2).OrderBy(f => f.Unit.Shield).ThenBy(f => f.Unit.Health))
                {
                    if (commander.UnitCalculation.Unit.CargoSpaceMax - commander.UnitCalculation.Unit.CargoSpaceTaken >= UnitDataService.CargoSize((UnitTypes)friendly.Unit.UnitType))
                    {
                        if (friendly.Unit.WeaponCooldown > 0)
                        {
                            action = commander.Order(frame, Abilities.LOAD, null, friendly.Unit.Tag);
                            return(true);
                        }
                    }
                }

                StartWarping(commander, frame, out action);
                return(true);
            }
            else
            {
                // move to pickup the friendly closest to the enemy
                if (StopWarping(commander, frame, out action))
                {
                    return(true);
                }

                action = commander.Order(frame, Abilities.MOVE, moveTo);
                return(true);
            }
        }
Пример #24
0
 public ColossusMicroController(MapDataService mapDataService, SharkyUnitData unitDataManager, ActiveUnitData activeUnitData, DebugService debugService, IPathFinder sharkyPathFinder, BaseData baseData, SharkyOptions sharkyOptions, DamageService damageService, UnitDataService unitDataService, TargetingData targetingData, MicroPriority microPriority, bool groupUpEnabled, CollisionCalculator collisionCalculator)
     : base(mapDataService, unitDataManager, activeUnitData, debugService, sharkyPathFinder, baseData, sharkyOptions, damageService, unitDataService, targetingData, microPriority, groupUpEnabled)
 {
     CollisionCalculator = collisionCalculator;
 }
Пример #25
0
        protected override UnitCalculation GetBestTarget(UnitCommander commander, Point2D target, int frame)
        {
            var existingAttackOrder = commander.UnitCalculation.Unit.Orders.Where(o => o.AbilityId == (uint)Abilities.ATTACK || o.AbilityId == (uint)Abilities.ATTACK_ATTACK).FirstOrDefault();

            var range = commander.UnitCalculation.Range;

            var attacks = new List <UnitCalculation>(commander.UnitCalculation.EnemiesInRange.Where(u => u.Unit.DisplayType == DisplayType.Visible)); // units that are in range right now

            UnitCalculation bestAttack = null;

            if (attacks.Count > 0)
            {
                var oneShotKills = attacks.Where(a => a.Unit.Health + a.Unit.Shield < GetDamage(commander.UnitCalculation.Weapons, a.Unit, a.UnitTypeData) && !a.Unit.BuffIds.Contains((uint)Buffs.IMMORTALOVERLOAD));
                if (oneShotKills.Count() > 0)
                {
                    if (existingAttackOrder != null)
                    {
                        var existing = oneShotKills.FirstOrDefault(o => o.Unit.Tag == existingAttackOrder.TargetUnitTag);
                        if (existing != null)
                        {
                            return(existing); // just keep attacking the same unit
                        }
                    }

                    var oneShotKill = GetBestTargetFromList(commander, oneShotKills, existingAttackOrder);
                    if (oneShotKill != null)
                    {
                        return(oneShotKill);
                    }
                    else
                    {
                        commander.BestTarget = oneShotKills.OrderBy(o => o.Dps).FirstOrDefault();
                        return(commander.BestTarget);
                    }
                }

                bestAttack = GetBestTargetFromList(commander, attacks, existingAttackOrder);
                if (bestAttack != null && (bestAttack.UnitClassifications.Contains(UnitClassification.ArmyUnit) || bestAttack.UnitClassifications.Contains(UnitClassification.DefensiveStructure) || (bestAttack.UnitClassifications.Contains(UnitClassification.Worker) && bestAttack.EnemiesInRange.Any(e => e.Unit.Tag == commander.UnitCalculation.Unit.Tag))))
                {
                    commander.BestTarget = bestAttack;
                    return(bestAttack);
                }
            }

            attacks = new List <UnitCalculation>(); // nearby units not in range right now
            foreach (var enemyAttack in commander.UnitCalculation.NearbyEnemies)
            {
                if (enemyAttack.Unit.DisplayType == DisplayType.Visible && DamageService.CanDamage(commander.UnitCalculation, enemyAttack) && !InRange(enemyAttack.Position, commander.UnitCalculation.Position, range + enemyAttack.Unit.Radius + commander.UnitCalculation.Unit.Radius))
                {
                    attacks.Add(enemyAttack);
                }
            }

            var safeAttacks = attacks.Where(a => a.Damage < commander.UnitCalculation.Unit.Health);

            if (safeAttacks.Count() > 0)
            {
                var bestOutOfRangeAttack = GetBestTargetFromList(commander, safeAttacks, existingAttackOrder);
                if (bestOutOfRangeAttack != null && (bestOutOfRangeAttack.UnitClassifications.Contains(UnitClassification.ArmyUnit) || bestOutOfRangeAttack.UnitClassifications.Contains(UnitClassification.DefensiveStructure)))
                {
                    commander.BestTarget = bestOutOfRangeAttack;
                    return(bestOutOfRangeAttack);
                }
                if (bestAttack == null)
                {
                    bestAttack = bestOutOfRangeAttack;
                }
            }

            if (commander.UnitCalculation.Unit.Health < 6)
            {
                return(null);
            }

            if (attacks.Count > 0)
            {
                var bestOutOfRangeAttack = GetBestTargetFromList(commander, attacks, existingAttackOrder);
                if (bestOutOfRangeAttack != null && (bestOutOfRangeAttack.UnitClassifications.Contains(UnitClassification.ArmyUnit) || bestOutOfRangeAttack.UnitClassifications.Contains(UnitClassification.DefensiveStructure)))
                {
                    commander.BestTarget = bestOutOfRangeAttack;
                    return(bestOutOfRangeAttack);
                }
                if (bestAttack == null)
                {
                    bestAttack = bestOutOfRangeAttack;
                }
            }

            if (!MapDataService.SelfVisible(target)) // if enemy main is unexplored, march to enemy main
            {
                var fakeMainBase = new Unit(commander.UnitCalculation.Unit);
                fakeMainBase.Pos = new Point {
                    X = target.X, Y = target.Y, Z = 1
                };
                fakeMainBase.Alliance = Alliance.Enemy;
                return(new UnitCalculation(fakeMainBase, 0, SharkyUnitData, SharkyOptions, UnitDataService, frame));
            }
            var unitsNearEnemyMain = ActiveUnitData.EnemyUnits.Values.Where(e => e.Unit.UnitType != (uint)UnitTypes.ZERG_LARVA && InRange(new Vector2(target.X, target.Y), e.Position, 20));

            if (unitsNearEnemyMain.Count() > 0 && InRange(new Vector2(target.X, target.Y), commander.UnitCalculation.Position, 100))
            {
                attacks = new List <UnitCalculation>(); // enemies in the main enemy base
                foreach (var enemyAttack in unitsNearEnemyMain)
                {
                    if (enemyAttack.Unit.DisplayType == DisplayType.Visible && DamageService.CanDamage(commander.UnitCalculation, enemyAttack))
                    {
                        attacks.Add(enemyAttack);
                    }
                }
                if (attacks.Count > 0)
                {
                    var bestMainAttack = GetBestTargetFromList(commander, attacks, existingAttackOrder);
                    if (bestMainAttack != null && (bestMainAttack.UnitClassifications.Contains(UnitClassification.ArmyUnit) || bestMainAttack.UnitClassifications.Contains(UnitClassification.DefensiveStructure)))
                    {
                        commander.BestTarget = bestMainAttack;
                        return(bestMainAttack);
                    }
                    if (bestAttack == null)
                    {
                        bestAttack = bestMainAttack;
                    }
                }
            }

            commander.BestTarget = bestAttack;
            return(bestAttack);
        }
Пример #26
0
 public ZealotMicroController(MapDataService mapDataService, SharkyUnitData sharkyUnitData, ActiveUnitData activeUnitData, DebugService debugService, IPathFinder sharkyPathFinder, BaseData baseData, SharkyOptions sharkyOptions, DamageService damageService, UnitDataService unitDataService, TargetingData targetingData, MicroPriority microPriority, bool groupUpEnabled)
     : base(mapDataService, sharkyUnitData, activeUnitData, debugService, sharkyPathFinder, baseData, sharkyOptions, damageService, unitDataService, targetingData, microPriority, groupUpEnabled)
 {
 }
Пример #27
0
        public DefaultSharkyBot(GameConnection gameConnection)
        {
            var debug = false;

#if DEBUG
            debug = true;
#endif

            var framesPerSecond = 22.4f;

            SharkyOptions = new SharkyOptions {
                Debug = debug, FramesPerSecond = framesPerSecond, TagsEnabled = true
            };
            MacroData  = new MacroData();
            AttackData = new AttackData {
                ArmyFoodAttack = 30, ArmyFoodRetreat = 25, Attacking = false, UseAttackDataManager = true, CustomAttackFunction = true, RetreatTrigger = 1f, AttackTrigger = 1.5f
            };
            TargetingData = new TargetingData {
                HiddenEnemyBase = false
            };
            BaseData       = new BaseData();
            ActiveChatData = new ActiveChatData();
            EnemyData      = new EnemyData();
            SharkyUnitData = new SharkyUnitData();

            UnitDataService = new UnitDataService(SharkyUnitData);

            Managers = new List <IManager>();

            DebugService = new DebugService(SharkyOptions);
            DebugManager = new DebugManager(gameConnection, SharkyOptions, DebugService);
            Managers.Add(DebugManager);

            UpgradeDataService  = new UpgradeDataService();
            BuildingDataService = new BuildingDataService();
            TrainingDataService = new TrainingDataService();
            AddOnDataService    = new AddOnDataService();
            MorphDataService    = new MorphDataService();
            WallDataService     = new WallDataService();

            UnitDataManager = new UnitDataManager(UpgradeDataService, BuildingDataService, TrainingDataService, AddOnDataService, MorphDataService, SharkyUnitData);
            Managers.Add(UnitDataManager);

            MapData               = new MapData();
            MapDataService        = new MapDataService(MapData);
            AreaService           = new AreaService(MapDataService);
            TargetPriorityService = new TargetPriorityService(SharkyUnitData);
            CollisionCalculator   = new CollisionCalculator();
            ActiveUnitData        = new ActiveUnitData();
            UnitCountService      = new UnitCountService(ActiveUnitData, SharkyUnitData);
            DamageService         = new DamageService();

            UnitManager = new UnitManager(ActiveUnitData, SharkyUnitData, SharkyOptions, TargetPriorityService, CollisionCalculator, MapDataService, DebugService, DamageService, UnitDataService);
            MapManager  = new MapManager(MapData, ActiveUnitData, SharkyOptions, SharkyUnitData, DebugService, WallDataService);
            Managers.Add(MapManager);
            Managers.Add(UnitManager);

            EnemyRaceManager = new EnemyRaceManager(ActiveUnitData, SharkyUnitData, EnemyData);
            Managers.Add(EnemyRaceManager);

            SharkyPathFinder         = new SharkyPathFinder(new Roy_T.AStar.Paths.PathFinder(), MapData, MapDataService, DebugService);
            SharkySimplePathFinder   = new SharkySimplePathFinder(MapDataService);
            SharkyAdvancedPathFinder = new SharkyAdvancedPathFinder(new Roy_T.AStar.Paths.PathFinder(), MapData, MapDataService, DebugService);
            NoPathFinder             = new SharkyNoPathFinder();
            BuildingService          = new BuildingService(MapData, ActiveUnitData, TargetingData, BaseData);
            ChokePointService        = new ChokePointService(SharkyPathFinder, MapDataService, BuildingService);
            ChokePointsService       = new ChokePointsService(SharkyPathFinder, ChokePointService);

            BaseManager = new BaseManager(SharkyUnitData, ActiveUnitData, SharkyPathFinder, UnitCountService, BaseData);
            Managers.Add(BaseManager);

            TargetingManager = new TargetingManager(SharkyUnitData, BaseData, MacroData, TargetingData, MapData, ChokePointService, ChokePointsService, DebugService);
            Managers.Add(TargetingManager);

            BuildOptions = new BuildOptions {
                StrictGasCount = false, StrictSupplyCount = false, StrictWorkerCount = false
            };
            MacroSetup       = new MacroSetup();
            WallOffPlacement = new HardCodedWallOffPlacement(ActiveUnitData, SharkyUnitData, DebugService, MapData, BuildingService, TargetingData, BaseData);
            //WallOffPlacement = new WallOffPlacement(ActiveUnitData, SharkyUnitData, DebugService, MapData, BuildingService, TargetingData);
            ProtossBuildingPlacement = new ProtossBuildingPlacement(ActiveUnitData, SharkyUnitData, DebugService, MapDataService, BuildingService, WallOffPlacement);
            TerranBuildingPlacement  = new TerranBuildingPlacement(ActiveUnitData, SharkyUnitData, DebugService, BuildingService);
            ZergBuildingPlacement    = new ZergBuildingPlacement(ActiveUnitData, SharkyUnitData, DebugService, BuildingService);
            BuildingPlacement        = new BuildingPlacement(ProtossBuildingPlacement, TerranBuildingPlacement, ZergBuildingPlacement, BaseData, ActiveUnitData, BuildingService, SharkyUnitData);
            BuildingBuilder          = new BuildingBuilder(ActiveUnitData, TargetingData, BuildingPlacement, SharkyUnitData, BaseData);

            WarpInPlacement = new WarpInPlacement(ActiveUnitData, DebugService, MapData);

            Morpher             = new Morpher(ActiveUnitData);
            BuildPylonService   = new BuildPylonService(MacroData, BuildingBuilder, SharkyUnitData, ActiveUnitData, BaseData, TargetingData, BuildingService);
            BuildDefenseService = new BuildDefenseService(MacroData, BuildingBuilder, SharkyUnitData, ActiveUnitData, BaseData, TargetingData, BuildOptions);

            ChronoData   = new ChronoData();
            NexusManager = new NexusManager(ActiveUnitData, SharkyUnitData, ChronoData);
            Managers.Add(NexusManager);
            ShieldBatteryManager = new ShieldBatteryManager(ActiveUnitData);
            Managers.Add(ShieldBatteryManager);
            PhotonCannonManager = new PhotonCannonManager(ActiveUnitData);
            Managers.Add(PhotonCannonManager);

            OrbitalManager = new OrbitalManager(ActiveUnitData, BaseData, EnemyData);
            Managers.Add(OrbitalManager);

            HttpClient         = new HttpClient();
            ChatHistory        = new ChatHistory();
            ChatDataService    = new ChatDataService();
            EnemyNameService   = new EnemyNameService();
            EnemyPlayerService = new EnemyPlayerService(EnemyNameService);
            ChatService        = new ChatService(ChatDataService, SharkyOptions, ActiveChatData);
            ChatManager        = new ChatManager(HttpClient, ChatHistory, SharkyOptions, ChatDataService, EnemyPlayerService, EnemyNameService, ChatService, ActiveChatData);
            Managers.Add((IManager)ChatManager);

            ProxyLocationService = new ProxyLocationService(BaseData, TargetingData, SharkyPathFinder, MapDataService, AreaService);

            var individualMicroController = new IndividualMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.LiveAndAttack, false);

            var adeptMicroController           = new AdeptMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.LiveAndAttack, false);
            var adeptShadeMicroController      = new AdeptShadeMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.LiveAndAttack, false);
            var archonMicroController          = new ArchonMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.AttackForward, false);
            var colossusMicroController        = new ColossusMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.LiveAndAttack, false, CollisionCalculator);
            var darkTemplarMicroController     = new DarkTemplarMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.LiveAndAttack, false);
            var disruptorMicroController       = new DisruptorMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.LiveAndAttack, false);
            var disruptorPhasedMicroController = new DisruptorPhasedMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.AttackForward, false);
            var highTemplarMicroController     = new HighTemplarMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.LiveAndAttack, false);
            var mothershipMicroController      = new MothershipMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.LiveAndAttack, false);
            var oracleMicroController          = new OracleMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.LiveAndAttack, false);
            var observerMicroController        = new ObserverMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.LiveAndAttack, false);
            var phoenixMicroController         = new PhoenixMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.LiveAndAttack, true);
            var sentryMicroController          = new SentryMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.StayOutOfRange, true);
            var stalkerMicroController         = new StalkerMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.LiveAndAttack, false);
            var tempestMicroController         = new TempestMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.LiveAndAttack, false);
            var voidrayMicroController         = new VoidRayMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.LiveAndAttack, false);
            var carrierMicroController         = new CarrierMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.LiveAndAttack, false);
            var warpPrismpMicroController      = new WarpPrismMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.LiveAndAttack, false);
            var zealotMicroController          = new ZealotMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.AttackForward, false);

            var zerglingMicroController = new ZerglingMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.AttackForward, false);

            var marineMicroController  = new MarineMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.LiveAndAttack, false);
            var reaperMicroController  = new ReaperMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.LiveAndAttack, false);
            var bansheeMicroController = new BansheeMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.LiveAndAttack, false);

            var workerDefenseMicroController    = new IndividualMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.LiveAndAttack, false, 3);
            var workerProxyScoutMicroController = new WorkerScoutMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.AttackForward, false);

            var oracleHarassMicroController = new OracleMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.LiveAndAttack, false);
            var reaperHarassMicroController = new ReaperMicroController(MapDataService, SharkyUnitData, ActiveUnitData, DebugService, SharkyAdvancedPathFinder, BaseData, SharkyOptions, DamageService, UnitDataService, TargetingData, MicroPriority.LiveAndAttack, false);

            var individualMicroControllers = new Dictionary <UnitTypes, IIndividualMicroController>
            {
                { UnitTypes.PROTOSS_ADEPT, adeptMicroController },
                { UnitTypes.PROTOSS_ADEPTPHASESHIFT, adeptShadeMicroController },
                { UnitTypes.PROTOSS_ARCHON, archonMicroController },
                { UnitTypes.PROTOSS_COLOSSUS, colossusMicroController },
                { UnitTypes.PROTOSS_DARKTEMPLAR, darkTemplarMicroController },
                { UnitTypes.PROTOSS_DISRUPTOR, disruptorMicroController },
                { UnitTypes.PROTOSS_DISRUPTORPHASED, disruptorPhasedMicroController },
                { UnitTypes.PROTOSS_HIGHTEMPLAR, highTemplarMicroController },
                { UnitTypes.PROTOSS_MOTHERSHIP, mothershipMicroController },
                { UnitTypes.PROTOSS_ORACLE, oracleMicroController },
                { UnitTypes.PROTOSS_PHOENIX, phoenixMicroController },
                { UnitTypes.PROTOSS_SENTRY, sentryMicroController },
                { UnitTypes.PROTOSS_STALKER, stalkerMicroController },
                { UnitTypes.PROTOSS_TEMPEST, tempestMicroController },
                { UnitTypes.PROTOSS_VOIDRAY, voidrayMicroController },
                { UnitTypes.PROTOSS_CARRIER, carrierMicroController },
                { UnitTypes.PROTOSS_WARPPRISM, warpPrismpMicroController },
                { UnitTypes.PROTOSS_WARPPRISMPHASING, warpPrismpMicroController },
                { UnitTypes.PROTOSS_ZEALOT, zealotMicroController },
                { UnitTypes.PROTOSS_OBSERVER, observerMicroController },

                { UnitTypes.ZERG_ZERGLING, zerglingMicroController },

                { UnitTypes.TERRAN_MARINE, marineMicroController },
                { UnitTypes.TERRAN_MARAUDER, marineMicroController },
                { UnitTypes.TERRAN_REAPER, reaperMicroController },
                { UnitTypes.TERRAN_BANSHEE, bansheeMicroController }
            };

            MicroData = new MicroData {
                IndividualMicroControllers = individualMicroControllers, IndividualMicroController = individualMicroController
            };

            DefenseService   = new DefenseService(ActiveUnitData);
            TargetingService = new TargetingService(ActiveUnitData, MapDataService, BaseData, TargetingData);
            MicroController  = new MicroController(MicroData);

            MicroTaskData = new MicroTaskData {
                MicroTasks = new Dictionary <string, IMicroTask>()
            };

            var defenseSquadTask        = new DefenseSquadTask(ActiveUnitData, TargetingData, DefenseService, MicroController, new ArmySplitter(AttackData, TargetingData, ActiveUnitData, DefenseService, MicroController), new List <DesiredUnitsClaim>(), 0, false);
            var workerScoutTask         = new WorkerScoutTask(SharkyUnitData, TargetingData, MapDataService, false, 0.5f, workerDefenseMicroController, DebugService, BaseData, AreaService);
            var workerScoutGasStealTask = new WorkerScoutGasStealTask(SharkyUnitData, TargetingData, MacroData, MapDataService, false, 0.5f, DebugService, BaseData, AreaService, MapData, BuildingService, ActiveUnitData);
            var findHiddenBaseTask      = new FindHiddenBaseTask(BaseData, TargetingData, MapDataService, individualMicroController, 15, false, 0.5f);
            var proxyScoutTask          = new ProxyScoutTask(SharkyUnitData, TargetingData, BaseData, SharkyOptions, false, 0.5f, workerProxyScoutMicroController);
            var miningDefenseService    = new MiningDefenseService(BaseData, ActiveUnitData, workerDefenseMicroController, DebugService);
            var miningTask               = new MiningTask(SharkyUnitData, BaseData, ActiveUnitData, 1, miningDefenseService, MacroData, BuildOptions);
            var queenInjectTask          = new QueenInjectsTask(ActiveUnitData, 1.1f, UnitCountService);
            var attackTask               = new AttackTask(MicroController, TargetingData, ActiveUnitData, DefenseService, MacroData, AttackData, TargetingService, MicroTaskData, new ArmySplitter(AttackData, TargetingData, ActiveUnitData, DefenseService, MicroController), new EnemyCleanupService(MicroController), 2);
            var adeptWorkerHarassTask    = new AdeptWorkerHarassTask(BaseData, TargetingData, adeptMicroController, 2, false);
            var oracleWorkerHarassTask   = new OracleWorkerHarassTask(TargetingData, BaseData, ChatService, MapDataService, MapData, oracleHarassMicroController, 1, false);
            var lateGameOracleHarassTask = new LateGameOracleHarassTask(BaseData, TargetingData, MapDataService, oracleHarassMicroController, 1, false);
            var reaperWorkerHarassTask   = new ReaperWorkerHarassTask(BaseData, TargetingData, reaperHarassMicroController, 2, false);
            var hallucinationScoutTask   = new HallucinationScoutTask(TargetingData, BaseData, false, .5f);
            var wallOffTask              = new WallOffTask(SharkyUnitData, TargetingData, ActiveUnitData, MacroData, WallOffPlacement, false, .25f);
            var destroyWallOffTask       = new DestroyWallOffTask(ActiveUnitData, false, .25f);

            MicroTaskData.MicroTasks[defenseSquadTask.GetType().Name]        = defenseSquadTask;
            MicroTaskData.MicroTasks[workerScoutGasStealTask.GetType().Name] = workerScoutGasStealTask;
            MicroTaskData.MicroTasks[workerScoutTask.GetType().Name]         = workerScoutTask;
            MicroTaskData.MicroTasks[findHiddenBaseTask.GetType().Name]      = findHiddenBaseTask;
            MicroTaskData.MicroTasks[proxyScoutTask.GetType().Name]          = proxyScoutTask;
            MicroTaskData.MicroTasks[miningTask.GetType().Name]               = miningTask;
            MicroTaskData.MicroTasks[queenInjectTask.GetType().Name]          = queenInjectTask;
            MicroTaskData.MicroTasks[attackTask.GetType().Name]               = attackTask;
            MicroTaskData.MicroTasks[adeptWorkerHarassTask.GetType().Name]    = adeptWorkerHarassTask;
            MicroTaskData.MicroTasks[oracleWorkerHarassTask.GetType().Name]   = oracleWorkerHarassTask;
            MicroTaskData.MicroTasks[lateGameOracleHarassTask.GetType().Name] = lateGameOracleHarassTask;
            MicroTaskData.MicroTasks[reaperWorkerHarassTask.GetType().Name]   = reaperWorkerHarassTask;
            MicroTaskData.MicroTasks[hallucinationScoutTask.GetType().Name]   = hallucinationScoutTask;
            MicroTaskData.MicroTasks[wallOffTask.GetType().Name]              = wallOffTask;
            MicroTaskData.MicroTasks[destroyWallOffTask.GetType().Name]       = destroyWallOffTask;

            MicroManager = new MicroManager(ActiveUnitData, MicroTaskData);
            Managers.Add(MicroManager);

            AttackDataManager = new AttackDataManager(AttackData, ActiveUnitData, attackTask, TargetPriorityService, TargetingData, MacroData, BaseData, DebugService);
            Managers.Add(AttackDataManager);

            BuildProxyService     = new BuildProxyService(MacroData, BuildingBuilder, SharkyUnitData, ActiveUnitData, Morpher, MicroTaskData);
            BuildingCancelService = new BuildingCancelService(ActiveUnitData, MacroData);
            MacroManager          = new MacroManager(MacroSetup, ActiveUnitData, SharkyUnitData, BuildingBuilder, SharkyOptions, BaseData, TargetingData, AttackData, WarpInPlacement, MacroData, Morpher, BuildOptions, BuildPylonService, BuildDefenseService, BuildProxyService, UnitCountService, BuildingCancelService);
            Managers.Add(MacroManager);

            EnemyStrategyHistory      = new EnemyStrategyHistory();
            EnemyData.EnemyStrategies = new Dictionary <string, IEnemyStrategy>
            {
                ["Proxy"]            = new EnemyStrategies.Proxy(EnemyStrategyHistory, ChatService, ActiveUnitData, SharkyOptions, TargetingData, DebugService, UnitCountService),
                ["WorkerRush"]       = new WorkerRush(EnemyStrategyHistory, ChatService, ActiveUnitData, SharkyOptions, TargetingData, DebugService, UnitCountService),
                ["InvisibleAttacks"] = new InvisibleAttacks(EnemyStrategyHistory, ChatService, ActiveUnitData, SharkyOptions, DebugService, UnitCountService),

                ["AdeptRush"]         = new AdeptRush(EnemyStrategyHistory, ChatService, ActiveUnitData, SharkyOptions, DebugService, UnitCountService),
                ["CannonRush"]        = new CannonRush(EnemyStrategyHistory, ChatService, ActiveUnitData, SharkyOptions, TargetingData, DebugService, UnitCountService),
                ["ProtossFastExpand"] = new ProtossFastExpand(EnemyStrategyHistory, ChatService, ActiveUnitData, SharkyOptions, DebugService, UnitCountService, TargetingData),
                ["ProxyRobo"]         = new ProxyRobo(EnemyStrategyHistory, ChatService, ActiveUnitData, SharkyOptions, DebugService, UnitCountService, TargetingData),
                ["ProxyStargate"]     = new ProxyStargate(EnemyStrategyHistory, ChatService, ActiveUnitData, SharkyOptions, DebugService, UnitCountService, TargetingData),
                ["ZealotRush"]        = new ZealotRush(EnemyStrategyHistory, ChatService, ActiveUnitData, SharkyOptions, DebugService, UnitCountService),

                ["MarineRush"]  = new MarineRush(EnemyStrategyHistory, ChatService, ActiveUnitData, SharkyOptions, DebugService, UnitCountService),
                ["BunkerRush"]  = new BunkerRush(EnemyStrategyHistory, ChatService, ActiveUnitData, SharkyOptions, TargetingData, DebugService, UnitCountService),
                ["MassVikings"] = new MassVikings(EnemyStrategyHistory, ChatService, ActiveUnitData, SharkyOptions, DebugService, UnitCountService),
                ["ThreeRax"]    = new ThreeRax(EnemyStrategyHistory, ChatService, ActiveUnitData, SharkyOptions, DebugService, UnitCountService),

                ["ZerglingRush"] = new ZerglingRush(EnemyStrategyHistory, ChatService, ActiveUnitData, SharkyOptions, DebugService, UnitCountService),
                ["RoachRavager"] = new RoachRavager(EnemyStrategyHistory, ChatService, ActiveUnitData, SharkyOptions, DebugService, UnitCountService)
            };

            EnemyStrategyManager = new EnemyStrategyManager(EnemyData);
            Managers.Add(EnemyStrategyManager);

            EmptyCounterTransitioner = new EmptyCounterTransitioner(EnemyData, SharkyOptions);

            var antiMassMarine   = new AntiMassMarine(BuildOptions, MacroData, ActiveUnitData, AttackData, ChatService, ChronoData, EmptyCounterTransitioner, UnitCountService, MicroTaskData);
            var fourGate         = new FourGate(BuildOptions, MacroData, ActiveUnitData, AttackData, ChatService, ChronoData, SharkyUnitData, EmptyCounterTransitioner, UnitCountService, MicroTaskData);
            var nexusFirst       = new NexusFirst(BuildOptions, MacroData, ActiveUnitData, AttackData, ChatService, ChronoData, EmptyCounterTransitioner, UnitCountService, MicroTaskData);
            var robo             = new Robo(BuildOptions, MacroData, ActiveUnitData, AttackData, ChatService, ChronoData, EnemyData, MicroTaskData, EmptyCounterTransitioner, UnitCountService);
            var protossRobo      = new ProtossRobo(BuildOptions, MacroData, ActiveUnitData, AttackData, ChatService, ChronoData, SharkyOptions, MicroTaskData, EnemyData, EmptyCounterTransitioner, UnitCountService);
            var everyProtossUnit = new EveryProtossUnit(BuildOptions, MacroData, ActiveUnitData, AttackData, ChatService, ChronoData, EmptyCounterTransitioner, UnitCountService, MicroTaskData);

            var protossBuilds = new Dictionary <string, ISharkyBuild>
            {
                [everyProtossUnit.Name()] = everyProtossUnit,
                [nexusFirst.Name()]       = nexusFirst,
                [robo.Name()]             = robo,
                [protossRobo.Name()]      = protossRobo,
                [fourGate.Name()]         = fourGate,
                [antiMassMarine.Name()]   = antiMassMarine
            };
            var protossSequences = new List <List <string> >
            {
                new List <string> {
                    everyProtossUnit.Name()
                },
                new List <string> {
                    nexusFirst.Name(), robo.Name(), protossRobo.Name()
                },
                new List <string> {
                    antiMassMarine.Name()
                },
                new List <string> {
                    fourGate.Name()
                }
            };
            var protossBuildSequences = new Dictionary <string, List <List <string> > >
            {
                [Race.Terran.ToString()]  = protossSequences,
                [Race.Zerg.ToString()]    = protossSequences,
                [Race.Protoss.ToString()] = protossSequences,
                [Race.Random.ToString()]  = protossSequences,
                ["Transition"]            = protossSequences
            };

            var massMarine      = new MassMarines(this);
            var battleCruisers  = new BattleCruisers(BuildOptions, MacroData, ActiveUnitData, AttackData, MicroTaskData, ChatService, UnitCountService);
            var everyTerranUnit = new EveryTerranUnit(BuildOptions, MacroData, ActiveUnitData, AttackData, ChatService, MicroTaskData, UnitCountService);
            var terranBuilds    = new Dictionary <string, ISharkyBuild>
            {
                [massMarine.Name()]      = massMarine,
                [battleCruisers.Name()]  = battleCruisers,
                [everyTerranUnit.Name()] = everyTerranUnit
            };
            var terranSequences = new List <List <string> >
            {
                new List <string> {
                    massMarine.Name(), battleCruisers.Name()
                },
                new List <string> {
                    everyTerranUnit.Name()
                },
                new List <string> {
                    battleCruisers.Name()
                },
            };
            var terranBuildSequences = new Dictionary <string, List <List <string> > >
            {
                [Race.Terran.ToString()]  = terranSequences,
                [Race.Zerg.ToString()]    = terranSequences,
                [Race.Protoss.ToString()] = terranSequences,
                [Race.Random.ToString()]  = terranSequences,
                ["Transition"]            = terranSequences
            };

            var basicZerglingRush = new BasicZerglingRush(BuildOptions, MacroData, ActiveUnitData, AttackData, ChatService, MicroTaskData, UnitCountService);
            var everyZergUnit     = new EveryZergUnit(BuildOptions, MacroData, ActiveUnitData, AttackData, MicroTaskData, ChatService, UnitCountService);
            var zergBuilds        = new Dictionary <string, ISharkyBuild>
            {
                [everyZergUnit.Name()]     = everyZergUnit,
                [basicZerglingRush.Name()] = basicZerglingRush
            };
            var zergSequences = new List <List <string> >
            {
                new List <string> {
                    everyZergUnit.Name()
                },
                new List <string> {
                    basicZerglingRush.Name(), everyZergUnit.Name()
                }
            };
            var zergBuildSequences = new Dictionary <string, List <List <string> > >
            {
                [Race.Terran.ToString()]  = zergSequences,
                [Race.Zerg.ToString()]    = zergSequences,
                [Race.Protoss.ToString()] = zergSequences,
                [Race.Random.ToString()]  = zergSequences,
                ["Transition"]            = zergSequences
            };

            MacroBalancer = new MacroBalancer(BuildOptions, ActiveUnitData, MacroData, SharkyUnitData, BaseData, UnitCountService);
            BuildChoices  = new Dictionary <Race, BuildChoices>
            {
                { Race.Protoss, new BuildChoices {
                      Builds = protossBuilds, BuildSequences = protossBuildSequences
                  } },
                { Race.Terran, new BuildChoices {
                      Builds = terranBuilds, BuildSequences = terranBuildSequences
                  } },
                { Race.Zerg, new BuildChoices {
                      Builds = zergBuilds, BuildSequences = zergBuildSequences
                  } }
            };
            BuildDecisionService = new BuildDecisionService(ChatService);
            BuildManager         = new BuildManager(BuildChoices, DebugService, MacroBalancer, BuildDecisionService, EnemyPlayerService, ChatHistory, EnemyStrategyHistory);
            Managers.Add(BuildManager);
        }