コード例 #1
0
        public bool RetreatForce()
        {
            if (!Interface().forces.ContainsKey(currentForce))
            {
                return(false);
            }

            ForceLocations loc = ForceLocations.NaturalChoke;

            UpdateUnits();

            if (!Interface().forcePoints.ContainsKey(loc))
            {
                loc = ForceLocations.OwnStart;
            }

            Interface().forces[currentForce].Where(unit => unit.SCUnit.move(new Position(Interface().forcePoints[loc]), true));

            foreach (UnitAgent unit in Interface().forces[currentForce].Where(unit => unit.SCUnit.getTargetPosition().getDistance(new Position(Interface().forcePoints[loc])) < DELTADISTANCE))
            {
                Interface().forces[loc].Add(unit);
            }

            Interface().forces[currentForce].RemoveAll(unit => unit.SCUnit.getTargetPosition().getDistance(new Position(Interface().forcePoints[loc])) < DELTADISTANCE);

            return(true);
        }
コード例 #2
0
        private ForceLocations ClosestLocation(Unit unit, ForceLocations first, ForceLocations second)
        {
            double distanceFirst  = Interface().baseLocations[(int)first].getDistance(unit.getTilePosition());
            double distanceSecond = Interface().baseLocations[(int)second].getDistance(unit.getTilePosition());

            return((distanceFirst < distanceSecond) ? first : second);
        }
コード例 #3
0
        public bool SelectForceExtension()
        {
            currentForce = ForceLocations.Extension;

            if (Interface().baseLocations.ContainsKey((int)ForceLocations.Extension))
            {
                return(true);
            }
            currentForce = ForceLocations.OwnStart;

            return(false);
        }
コード例 #4
0
        public bool SelectForceNatural()
        {
            currentForce = ForceLocations.Natural;

            if (Interface().baseLocations.ContainsKey((int)ForceLocations.Natural))
            {
                return(true);
            }
            currentForce = ForceLocations.OwnStart;

            return(false);
        }
コード例 #5
0
        void IStarcraftBot.onStart()
        {
            bwapi.Broodwar.setLocalSpeed(0);
            bwapi.Broodwar.setFrameSkip(200);
            System.Console.WriteLine("Starting Match!");
            bwapi.Broodwar.sendText("This is HellBot a poshSHARP based planning agent!");
            mapDim         = new int[2];
            ActivePlayers  = new Dictionary <string, Player>();
            UnitDiscovered = new Dictionary <long, Unit>();
            UnitEvade      = new Dictionary <long, Unit>();
            UnitShow       = new Dictionary <long, Unit>();
            UnitHide       = new Dictionary <long, Unit>();

            UnitCreated   = new Dictionary <long, Unit>();
            UnitDestroyed = new Dictionary <long, Unit>();
            UnitMorphed   = new Dictionary <long, Unit>();
            UnitTrained   = new Dictionary <long, Unit>();
            UnitRenegade  = new Dictionary <long, Unit>();

            baseLocations    = new Dictionary <int, TilePosition>();
            currentBuildSite = BuildSite.StartingLocation;

            foreach (Player pl in bwapi.Broodwar.getPlayers())
            {
                ActivePlayers.Add(pl.getName(), pl);
            }
            if (ActivePlayers.ContainsKey(Self().getName()))
            {
                ActivePlayers.Remove(Self().getName());
            }

            forces      = new Dictionary <ForceLocations, List <UnitAgent> >();
            forcePoints = new Dictionary <ForceLocations, TilePosition>();

            // initiating the starting location
            if (Self().getStartLocation() is TilePosition)
            {
                baseLocations[(int)BuildSite.StartingLocation] = Self().getStartLocation();
                forcePoints[ForceLocations.OwnStart]           = Self().getStartLocation();
            }

            // Get all base locations to be used for scouting and attacking
            basePositions = bwta.getBaseLocations().Where(baseLoc => bwta.getGroundDistance(Self().getStartLocation(), baseLoc.getTilePosition()) > 0).OrderBy(baseLoc => bwta.getGroundDistance(Self().getStartLocation(), baseLoc.getTilePosition()));
            basePositions.Reverse();

            currentForcePoint = ForceLocations.OwnStart;
            currentBuildSite  = BuildSite.StartingLocation;
        }
コード例 #6
0
        void IStarcraftBot.onStart()
        {
            System.Console.WriteLine("Starting Match!");
            bwapi.Broodwar.sendText("Hello world! This is POSH!");
            mapDim         = new int[2];
            ActivePlayers  = new Dictionary <string, Player>();
            UnitDiscovered = new Dictionary <long, Unit>();
            UnitEvade      = new Dictionary <long, Unit>();
            UnitShow       = new Dictionary <long, Unit>();
            UnitHide       = new Dictionary <long, Unit>();

            UnitCreated   = new Dictionary <long, Unit>();
            UnitDestroyed = new Dictionary <long, Unit>();
            UnitMorphed   = new Dictionary <long, Unit>();
            UnitTrained   = new Dictionary <long, Unit>();
            UnitRenegade  = new Dictionary <long, Unit>();

            baseLocations    = new Dictionary <int, TilePosition>();
            currentBuildSite = BuildSite.StartingLocation;

            foreach (Player pl in bwapi.Broodwar.getPlayers())
            {
                ActivePlayers.Add(pl.getName(), pl);
            }
            if (ActivePlayers.ContainsKey(Self().getName()))
            {
                ActivePlayers.Remove(Self().getName());
            }

            forces      = new Dictionary <ForceLocations, List <UnitAgent> >();
            forcePoints = new Dictionary <ForceLocations, TilePosition>();

            // initiating the starting location
            if (Self().getStartLocation() is TilePosition)
            {
                baseLocations[(int)BuildSite.StartingLocation] = Self().getStartLocation();
                forcePoints[ForceLocations.OwnStart]           = Self().getStartLocation();
            }

            currentForcePoint = ForceLocations.OwnStart;
            currentBuildSite  = BuildSite.StartingLocation;
        }
コード例 #7
0
        // Attack specified location
        protected bool AttackLocation(ForceLocations location)
        {
            TacticalAgent agent = null;

            // check which key the location contains
            if (fights.ContainsKey(location))
            {
                agent = fights[location];
            }
            else if (selectedForce != null && selectedForce.Count > 0)
            {
                agent = new TacticalAgent(selectedForce, log);
                fights.Add(location, agent);
            }
            if (agent.MySquad.Count > 0)
            { // update the squat by removing dead units
                agent.MySquad.RemoveAll(unit => unit.HealthLevelOk == 0);
            }
            if (agent.MySquad.Count == 0)
            {
                fights.Remove(location); //Own Amy annihilated
                return(false);
            }

            if (agent.MySquad[0].SCUnit.getPosition().getApproxDistance(new Position(Interface().baseLocations[(int)location])) < 5 * DELTADISTANCE ||
                location == ForceLocations.NotAssigned || agent.MySquad[0].SCUnit.isUnderAttack())    //larger distance to not be over the base
            {
                agent.ExecuteBestActionForSquad();
            }
            else
            {
                agent.MySquad.All(ua => ua.SCUnit.rightClick(new Position(Interface().baseLocations[(int)location])));
            }

            return(true);
        }
コード例 #8
0
        public bool SelectForceStartingLocation()
        {
            currentForce = ForceLocations.OwnStart;

            return(true);
        }