Esempio n. 1
0
        public override void OnFrame(Tyr tyr)
        {
            Point2D targetLocation  = GetTarget();
            bool    starportsRemain = false;

            /*
             * foreach (Unit unit in tyr.Enemies())
             *  if (unit.UnitType == UnitTypes.STARPORT)
             *  {
             *      starportsRemain = true;
             *      Search = true;
             *      break;
             *  }
             */
            tyr.DrawText("Search: " + Search);
            tyr.DrawSphere(targetLocation);
            foreach (Agent agent in units)
            {
                Unit target = Targetting.GetTarget(agent);
                if (Search)
                {
                    if (target != null && (target.UnitType == UnitTypes.STARPORT ||
                                           (UnitTypes.AirAttackTypes.Contains(target.UnitType) && agent.DistanceSq(target) <= 15 * 15)))
                    {
                        agent.Order(Abilities.ATTACK, target.Tag);
                        tyr.DrawLine(agent.Unit.Pos, target.Pos);
                    }
                    else
                    {
                        agent.Order(Abilities.MOVE, targetLocation);
                    }

                    if (agent.DistanceSq(targetLocation) <= 4 * 4 && !starportsRemain)
                    {
                        Search = false;
                    }
                }
                else
                {
                    if (target != null)
                    {
                        agent.Order(Abilities.ATTACK, target.Tag);
                        tyr.DrawLine(agent.Unit.Pos, target.Pos);
                    }
                    else
                    {
                        agent.Order(Abilities.ATTACK, targetLocation);
                    }
                }
            }
        }
Esempio n. 2
0
        public override void OnFrame(Tyr tyr)
        {
            tyr.DrawText("Replenishing scvs: " + Units.Count);
            List <Agent>            unassignedSCVs   = new List <Agent>();
            Dictionary <ulong, int> alreadyRepairing = new Dictionary <ulong, int>();

            foreach (Agent agent in Units)
            {
                tyr.DrawSphere(agent.Unit.Pos);
                if (RepairMap.ContainsKey(agent.Unit.Tag) &&
                    !NeedsRepairing.Contains(RepairMap[agent.Unit.Tag]))
                {
                    RepairMap.Remove(agent.Unit.Tag);
                }

                if (!RepairMap.ContainsKey(agent.Unit.Tag))
                {
                    unassignedSCVs.Add(agent);
                }
                else
                {
                    if (!alreadyRepairing.ContainsKey(RepairMap[agent.Unit.Tag]))
                    {
                        alreadyRepairing.Add(RepairMap[agent.Unit.Tag], 1);
                    }
                    else
                    {
                        alreadyRepairing[RepairMap[agent.Unit.Tag]]++;
                    }
                }
            }

            foreach (ulong tag in NeedsRepairing)
            {
                if (!alreadyRepairing.ContainsKey(tag))
                {
                    alreadyRepairing[tag] = 0;
                }
                while (alreadyRepairing[tag] == 0 &&
                       unassignedSCVs.Count > 0)
                {
                    alreadyRepairing[tag]++;
                    RepairMap.Add(unassignedSCVs[unassignedSCVs.Count - 1].Unit.Tag, tag);
                    unassignedSCVs.RemoveAt(unassignedSCVs.Count - 1);
                }
            }

            for (int i = unassignedSCVs.Count - 1; i >= 0; i--)
            {
                IdleTask.Task.Add(unassignedSCVs[i]);
                Units.Remove(unassignedSCVs[i]);
            }

            foreach (Agent agent in Units)
            {
                tyr.DrawLine(agent, tyr.UnitManager.Agents[RepairMap[agent.Unit.Tag]].Unit.Pos);
                agent.Order(Abilities.MOVE, RepairMap[agent.Unit.Tag]);
            }
        }
        public override void OnFrame(Tyr tyr)
        {
            if (mineral == null && tyr.BaseManager.Main.BaseLocation.MineralFields.Count > 0)
            {
                mineral = tyr.BaseManager.Main.BaseLocation.MineralFields[0];
            }

            Unit  closestEnemy = null;
            float distance     = 10 * 10;
            float hp           = 1000;

            foreach (Unit enemy in tyr.Enemies())
            {
                float newDist = SC2Util.DistanceSq(mineral.Pos, enemy.Pos);
                if (newDist < 2 * 2)
                {
                    if (enemy.Health < hp)
                    {
                        closestEnemy = enemy;
                        distance     = newDist;
                        hp           = enemy.Health;
                    }
                }
                else if (newDist < distance)
                {
                    closestEnemy = enemy;
                    distance     = newDist;
                }
            }
            foreach (Agent agent in Units)
            {
                if (closestEnemy != null && (agent.DistanceSq(closestEnemy) > 2 * 2 || agent.DistanceSq(mineral.Pos) <= 2 * 2))
                {
                    agent.Order(Abilities.ATTACK, closestEnemy.Tag);
                    tyr.DrawLine(agent, closestEnemy.Pos);
                }
                else
                {
                    agent.Order(Abilities.MOVE, mineral.Tag);
                }
            }
        }
Esempio n. 4
0
        public override void OnFrame(Tyr tyr)
        {
            while (unassignedAgents.Count > 0 && UnassignedRequests.Count > 0)
            {
                UnassignedRequests[UnassignedRequests.Count - 1].worker = unassignedAgents[unassignedAgents.Count - 1];
                UnassignedRequests[UnassignedRequests.Count - 1].LastImprovementFrame = Tyr.Bot.Frame;
                UnassignedRequests[UnassignedRequests.Count - 1].Closest = unassignedAgents[unassignedAgents.Count - 1].DistanceSq(UnassignedRequests[UnassignedRequests.Count - 1].Pos);
                BuildRequests.Add(UnassignedRequests[UnassignedRequests.Count - 1]);
                UnassignedRequests.RemoveAt(UnassignedRequests.Count - 1);
                unassignedAgents.RemoveAt(unassignedAgents.Count - 1);
            }

            for (int i = BuildRequests.Count - 1; i >= 0; i--)
            {
                BuildRequest buildRequest = BuildRequests[i];
                bool         completed    = false;
                if (buildRequest.worker != null)
                {
                    float newDist = buildRequest.worker.DistanceSq(buildRequest.Pos);
                    if (newDist < buildRequest.Closest)
                    {
                        buildRequest.Closest = newDist;
                        buildRequest.LastImprovementFrame = Tyr.Bot.Frame;
                    }
                    else if (Tyr.Bot.Frame - buildRequest.LastImprovementFrame >= 448)
                    {
                        UnassignedRequests.Add(buildRequest);
                        BlockedWorkers.Add(buildRequest.worker.Unit.Tag);
                        BuildRequests[i] = BuildRequests[BuildRequests.Count - 1];
                        BuildRequests.RemoveAt(BuildRequests.Count - 1);
                        IdleTask.Task.Add(buildRequest.worker);
                        units.Remove(buildRequest.worker);
                    }
                }
                foreach (Agent agent in tyr.UnitManager.Agents.Values)
                {
                    if (agent.Unit.UnitType == buildRequest.Type && SC2Util.DistanceSq(agent.Unit.Pos, buildRequest.Pos) <= 1)
                    {
                        completed  = true;
                        agent.Base = buildRequest.Base;
                        break;
                    }
                }
                if (completed)
                {
                    BuildRequests[i] = BuildRequests[BuildRequests.Count - 1];
                    BuildRequests.RemoveAt(BuildRequests.Count - 1);
                    IdleTask.Task.Add(buildRequest.worker);
                    units.Remove(buildRequest.worker);
                }
                else if (!tyr.UnitManager.Agents.ContainsKey(buildRequest.worker.Unit.Tag))
                {
                    buildRequest.worker = null;
                    UnassignedRequests.Add(buildRequest);
                    BuildRequests[i] = BuildRequests[BuildRequests.Count - 1];
                    BuildRequests.RemoveAt(BuildRequests.Count - 1);
                }
                else if (CancelBlockedBuildings && Unbuildable(buildRequest))
                {
                    BuildRequests[i] = BuildRequests[BuildRequests.Count - 1];
                    BuildRequests.RemoveAt(BuildRequests.Count - 1);
                    IdleTask.Task.Add(buildRequest.worker);
                    units.Remove(buildRequest.worker);
                }
                else if (buildRequest.worker.Unit.Orders.Count == 0 ||
                         buildRequest.worker.Unit.Orders[0].AbilityId != BuildingType.LookUp[buildRequest.Type].Ability ||
                         (buildRequest.worker.Unit.Orders[0].TargetWorldSpacePos != null && buildRequest.worker.Unit.Orders[0].TargetWorldSpacePos.X != buildRequest.Pos.X) ||
                         (buildRequest.worker.Unit.Orders[0].TargetWorldSpacePos != null && buildRequest.worker.Unit.Orders[0].TargetWorldSpacePos.Y != buildRequest.Pos.Y) ||
                         (buildRequest is BuildRequestGas && ((BuildRequestGas)buildRequest).Gas.Tag != buildRequest.worker.Unit.Orders[0].TargetUnitTag))
                {
                    Tyr.Bot.ReservedMinerals += BuildingType.LookUp[buildRequest.Type].Minerals;
                    Tyr.Bot.ReservedGas      += BuildingType.LookUp[buildRequest.Type].Gas;

                    if (buildRequest is BuildRequestGas)
                    {
                        tyr.DrawLine(buildRequest.worker, ((BuildRequestGas)buildRequest).Gas.Pos);
                    }
                    else
                    {
                        tyr.DrawLine(buildRequest.worker, SC2Util.Point(buildRequest.Pos.X, buildRequest.Pos.Y, buildRequest.worker.Unit.Pos.Z));
                    }
                    if (tyr.Observation.Observation.PlayerCommon.Minerals < BuildingType.LookUp[buildRequest.Type].Minerals ||
                        tyr.Observation.Observation.PlayerCommon.Vespene < BuildingType.LookUp[buildRequest.Type].Gas)
                    {
                        Point2D target = buildRequest is BuildRequestGas?SC2Util.To2D(((BuildRequestGas)buildRequest).Gas.Pos) : buildRequest.Pos;

                        if (buildRequest.worker.DistanceSq(target) > 3 * 3)
                        {
                            buildRequest.worker.Order(Abilities.MOVE, target);
                            continue;
                        }
                    }

                    if (buildRequest is BuildRequestGas)
                    {
                        buildRequest.worker.Order(BuildingType.LookUp[buildRequest.Type].Ability, ((BuildRequestGas)buildRequest).Gas.Tag);
                    }
                    else
                    {
                        buildRequest.worker.Order(BuildingType.LookUp[buildRequest.Type].Ability, buildRequest.Pos);
                    }
                }
            }

            foreach (BuildRequest request in UnassignedRequests)
            {
                Tyr.Bot.DrawText("BuildRequest: " + UnitTypes.LookUp[request.Type].Name);
            }
            foreach (BuildRequest request in BuildRequests)
            {
                Tyr.Bot.DrawText("BuildRequest: " + UnitTypes.LookUp[request.Type].Name);
            }
        }
Esempio n. 5
0
        public void LeapFrog(Tyr tyr)
        {
            List <Agent> tanks = GetTanks();

            foreach (Agent tank in tanks)
            {
                if (tyr.MapAnalyzer.EnemyDistances[(int)tank.Unit.Pos.X, (int)tank.Unit.Pos.Y] <= 50 ||
                    tank.DistanceSq(tyr.TargetManager.PotentialEnemyStartLocations[0]) <= 20 * 20)
                {
                    CurrentState = State.Kill;
                    break;
                }
            }

            int tanksSieged   = 0;
            int tanksUnsieged = 0;

            foreach (Agent agent in units)
            {
                if (agent.Unit.UnitType == UnitTypes.SIEGE_TANK)
                {
                    tanksUnsieged++;
                }
                else if (agent.Unit.UnitType == UnitTypes.SIEGE_TANK_SIEGED)
                {
                    if (UnsiegingTanks.Contains(agent.Unit.Tag))
                    {
                        tanksUnsieged++;
                    }
                    else
                    {
                        tanksSieged++;
                    }
                }
            }

            int allowedUnsiegedTanks = (tanksUnsieged + tanksSieged) / 2;

            if (allowedUnsiegedTanks < 2)
            {
                allowedUnsiegedTanks = 2;
            }

            List <Agent> potentialUnsiegers = GetPotentialUnsiegers();

            foreach (Agent agent in potentialUnsiegers)
            {
                if (allowedUnsiegedTanks - tanksUnsieged <= 0)
                {
                    break;
                }

                bool enemyClose = false;
                foreach (Unit enemy in tyr.Enemies())
                {
                    if (!UnitTypes.CanAttackGround(enemy.UnitType) && !UnitTypes.BuildingTypes.Contains(enemy.UnitType))
                    {
                        continue;
                    }

                    if (!UnitTypes.RangedTypes.Contains(enemy.UnitType) && !UnitTypes.BuildingTypes.Contains(enemy.UnitType))
                    {
                        continue;
                    }

                    if (enemy.IsFlying)
                    {
                        continue;
                    }

                    if (agent.DistanceSq(enemy) <= 13 * 13)
                    {
                        enemyClose = true;
                        break;
                    }
                }
                if (enemyClose)
                {
                    tyr.DrawSphere(agent.Unit.Pos, 1, new Color()
                    {
                        R = 0, G = 255, B = 0
                    });
                }
            }

            foreach (Agent agent in potentialUnsiegers)
            {
                if (allowedUnsiegedTanks - tanksUnsieged <= 0)
                {
                    break;
                }

                bool enemyClose = false;
                foreach (Unit enemy in tyr.Enemies())
                {
                    if (!UnitTypes.CanAttackGround(enemy.UnitType) && !UnitTypes.BuildingTypes.Contains(enemy.UnitType))
                    {
                        continue;
                    }

                    if (!UnitTypes.RangedTypes.Contains(enemy.UnitType) && !UnitTypes.BuildingTypes.Contains(enemy.UnitType))
                    {
                        continue;
                    }

                    if (enemy.IsFlying)
                    {
                        continue;
                    }

                    if (agent.DistanceSq(enemy) <= 13 * 13)
                    {
                        enemyClose = true;
                        break;
                    }
                }
                if (enemyClose)
                {
                    continue;
                }

                allowedUnsiegedTanks--;
                UnsiegingTanks.Add(agent.Unit.Tag);
            }

            float closestDistance = 1000000;

            foreach (Agent agent in Units)
            {
                if (UnsiegingTanks.Contains(agent.Unit.Tag))
                {
                    tyr.DrawSphere(agent.Unit.Pos);
                }
                if (agent.Unit.UnitType != UnitTypes.SIEGE_TANK_SIEGED ||
                    UnsiegingTanks.Contains(agent.Unit.Tag))
                {
                    continue;
                }

                tyr.DrawLine(agent, tyr.TargetManager.PotentialEnemyStartLocations[0]);

                float distSq = agent.DistanceSq(tyr.TargetManager.PotentialEnemyStartLocations[0]);
                if (distSq < closestDistance)
                {
                    closestDistance = distSq;
                }
            }

            float minimumDist = (float)Math.Sqrt(closestDistance) + 8;

            float farthestDistance = 0;

            foreach (Agent agent in Units)
            {
                if (agent.Unit.UnitType != UnitTypes.SIEGE_TANK_SIEGED ||
                    UnsiegingTanks.Contains(agent.Unit.Tag))
                {
                    continue;
                }

                float distSq = agent.DistanceSq(tyr.TargetManager.PotentialEnemyStartLocations[0]);
                if (distSq >= minimumDist * minimumDist)
                {
                    continue;
                }

                if (distSq > farthestDistance)
                {
                    farthestDistance = distSq;
                }
            }

            farthestDistance = (float)Math.Sqrt(farthestDistance);
            closestDistance  = (float)Math.Sqrt(closestDistance);

            tyr.DrawText("Closest tank dist: " + closestDistance);
            tyr.DrawText("Farthest tank dist: " + farthestDistance);


            foreach (Agent agent in Units)
            {
                if (agent.Unit.UnitType == UnitTypes.SIEGE_TANK)
                {
                    if (!UnsiegingTanks.Contains(agent.Unit.Tag))
                    {
                        agent.Order(Abilities.SIEGE);
                    }
                    else
                    {
                        float dist = agent.DistanceSq(tyr.TargetManager.PotentialEnemyStartLocations[0]);
                        if (dist < (farthestDistance - 6) * (farthestDistance - 6) || dist < (closestDistance - 2) + (closestDistance - 2) &&
                            SufficientlySpread(agent))
                        {
                            UnsiegingTanks.Remove(agent.Unit.Tag);
                            agent.Order(Abilities.UNSIEGE);
                        }
                        else
                        {
                            Attack(agent, tyr.TargetManager.PotentialEnemyStartLocations[0]);
                        }
                    }
                }
                else if (agent.Unit.UnitType == UnitTypes.SIEGE_TANK_SIEGED)
                {
                    if (UnsiegingTanks.Contains(agent.Unit.Tag))
                    {
                        bool closeEnemy = false;
                        foreach (Unit enemy in Tyr.Bot.Enemies())
                        {
                            if (!UnitTypes.CanAttackGround(enemy.UnitType) && !UnitTypes.BuildingTypes.Contains(enemy.UnitType))
                            {
                                continue;
                            }

                            if (!UnitTypes.RangedTypes.Contains(enemy.UnitType) && !UnitTypes.BuildingTypes.Contains(enemy.UnitType))
                            {
                                continue;
                            }

                            if (enemy.IsFlying)
                            {
                                continue;
                            }

                            if (agent.DistanceSq(enemy) <= 13 * 13)
                            {
                                closeEnemy = true;
                                break;
                            }
                        }
                        if (!closeEnemy)
                        {
                            agent.Order(Abilities.UNSIEGE);
                        }
                    }
                }
                else
                {
                    if (agent.Unit.UnitType == UnitTypes.HELLBAT ||
                        agent.Unit.UnitType == UnitTypes.HELLION ||
                        agent.Unit.UnitType == UnitTypes.MARINE)
                    {
                        Agent closestTank = null;
                        float distance    = 18 * 18;
                        foreach (Agent tank in tanks)
                        {
                            float newDist = tank.DistanceSq(agent);
                            if (newDist < distance)
                            {
                                closestTank = tank;
                                distance    = newDist;
                            }
                        }
                        if (distance >= 5 * 5 && closestTank != null)
                        {
                            agent.Order(Abilities.MOVE, SC2Util.To2D(closestTank.Unit.Pos));
                            continue;
                        }
                    }
                    Attack(agent, tyr.TargetManager.PotentialEnemyStartLocations[0]);
                }
            }
        }
Esempio n. 6
0
        public override void OnFrame(Tyr tyr)
        {
            while (unassignedAgents.Count > 0 && UnassignedRequests.Count > 0)
            {
                UnassignedRequests[UnassignedRequests.Count - 1].worker = unassignedAgents[unassignedAgents.Count - 1];
                UnassignedRequests[UnassignedRequests.Count - 1].LastImprovementFrame = Tyr.Bot.Frame;
                UnassignedRequests[UnassignedRequests.Count - 1].Closest = unassignedAgents[unassignedAgents.Count - 1].DistanceSq(UnassignedRequests[UnassignedRequests.Count - 1].Pos);
                BuildRequests.Add(UnassignedRequests[UnassignedRequests.Count - 1]);
                UnassignedRequests.RemoveAt(UnassignedRequests.Count - 1);
                unassignedAgents.RemoveAt(unassignedAgents.Count - 1);
            }

            for (int i = BuildRequests.Count - 1; i >= 0; i--)
            {
                BuildRequest buildRequest = BuildRequests[i];
                bool         completed    = false;
                if (buildRequest.worker != null)
                {
                    float newDist = buildRequest.worker.DistanceSq(buildRequest.Pos);
                    if (newDist < buildRequest.Closest)
                    {
                        buildRequest.Closest = newDist;
                        buildRequest.LastImprovementFrame = Tyr.Bot.Frame;
                    }
                    else if (Tyr.Bot.Frame - buildRequest.LastImprovementFrame >= 448)
                    {
                        UnassignedRequests.Add(buildRequest);
                        BlockedWorkers.Add(buildRequest.worker.Unit.Tag);
                        BuildRequests[i] = BuildRequests[BuildRequests.Count - 1];
                        BuildRequests.RemoveAt(BuildRequests.Count - 1);
                        IdleTask.Task.Add(buildRequest.worker);
                        units.Remove(buildRequest.worker);
                    }
                    else if (UnitTypes.ResourceCenters.Contains(buildRequest.Type))
                    {
                        bool closeEnemy = false;
                        foreach (Unit enemy in Tyr.Bot.Enemies())
                        {
                            if (!UnitTypes.CanAttackGround(enemy.UnitType))
                            {
                                continue;
                            }
                            if (buildRequest.worker.DistanceSq(enemy) <= 8 * 8)
                            {
                                closeEnemy = true;
                                break;
                            }
                        }

                        if (closeEnemy)
                        {
                            ExpandingBlockedUntilFrame = Tyr.Bot.Frame + 224;
                            BuildRequests[i]           = BuildRequests[BuildRequests.Count - 1];
                            BuildRequests.RemoveAt(BuildRequests.Count - 1);
                            IdleTask.Task.Add(buildRequest.worker);
                            units.Remove(buildRequest.worker);
                            DebugUtil.WriteLine("Base blocked, cancelling base. BuildRequest length: " + BuildRequests.Count);
                            continue;
                        }
                    }
                }
                foreach (Agent agent in tyr.UnitManager.Agents.Values)
                {
                    if (agent.Unit.UnitType == buildRequest.Type && SC2Util.DistanceSq(agent.Unit.Pos, buildRequest.Pos) <= 1)
                    {
                        completed            = true;
                        agent.Base           = buildRequest.Base;
                        agent.AroundLocation = buildRequest.AroundLocation;
                        agent.Exact          = buildRequest.Exact;
                        break;
                    }
                }
                if (completed)
                {
                    BuildRequests[i] = BuildRequests[BuildRequests.Count - 1];
                    BuildRequests.RemoveAt(BuildRequests.Count - 1);
                    IdleTask.Task.Add(buildRequest.worker);
                    units.Remove(buildRequest.worker);
                }
                else if (!tyr.UnitManager.Agents.ContainsKey(buildRequest.worker.Unit.Tag))
                {
                    buildRequest.worker = null;
                    UnassignedRequests.Add(buildRequest);
                    BuildRequests[i] = BuildRequests[BuildRequests.Count - 1];
                    BuildRequests.RemoveAt(BuildRequests.Count - 1);
                }
                else if (CancelBlockedBuildings && Unbuildable(buildRequest))
                {
                    BuildRequests[i] = BuildRequests[BuildRequests.Count - 1];
                    BuildRequests.RemoveAt(BuildRequests.Count - 1);
                    IdleTask.Task.Add(buildRequest.worker);
                    units.Remove(buildRequest.worker);
                }
                else if (buildRequest.worker.Unit.Orders.Count == 0 ||
                         buildRequest.worker.Unit.Orders[0].AbilityId != BuildingType.LookUp[buildRequest.Type].Ability ||
                         (buildRequest.worker.Unit.Orders[0].TargetWorldSpacePos != null && buildRequest.worker.Unit.Orders[0].TargetWorldSpacePos.X != buildRequest.Pos.X) ||
                         (buildRequest.worker.Unit.Orders[0].TargetWorldSpacePos != null && buildRequest.worker.Unit.Orders[0].TargetWorldSpacePos.Y != buildRequest.Pos.Y) ||
                         (buildRequest is BuildRequestGas && ((BuildRequestGas)buildRequest).Gas.Tag != buildRequest.worker.Unit.Orders[0].TargetUnitTag))
                {
                    Tyr.Bot.ReservedMinerals += BuildingType.LookUp[buildRequest.Type].Minerals;
                    Tyr.Bot.ReservedGas      += BuildingType.LookUp[buildRequest.Type].Gas;

                    if (buildRequest is BuildRequestGas)
                    {
                        tyr.DrawLine(buildRequest.worker, ((BuildRequestGas)buildRequest).Gas.Pos);
                    }
                    else
                    {
                        tyr.DrawLine(buildRequest.worker, SC2Util.Point(buildRequest.Pos.X, buildRequest.Pos.Y, buildRequest.worker.Unit.Pos.Z));
                    }
                    if (tyr.Observation.Observation.PlayerCommon.Minerals < BuildingType.LookUp[buildRequest.Type].Minerals ||
                        tyr.Observation.Observation.PlayerCommon.Vespene < BuildingType.LookUp[buildRequest.Type].Gas)
                    {
                        Point2D target = buildRequest is BuildRequestGas?SC2Util.To2D(((BuildRequestGas)buildRequest).Gas.Pos) : buildRequest.Pos;

                        if (buildRequest.worker.DistanceSq(target) > 3 * 3)
                        {
                            buildRequest.worker.Order(Abilities.MOVE, target);
                            continue;
                        }
                    }

                    if (buildRequest is BuildRequestGas)
                    {
                        Unit gas = ((BuildRequestGas)buildRequest).Gas.Unit;
                        foreach (Unit unit in tyr.Observation.Observation.RawData.Units)
                        {
                            if (SC2Util.DistanceSq(unit.Pos, ((BuildRequestGas)buildRequest).Gas.Pos) > 2 * 2)
                            {
                                continue;
                            }
                            gas = unit;
                            break;
                        }
                        buildRequest.worker.Order(BuildingType.LookUp[buildRequest.Type].Ability, gas.Tag);
                    }
                    else
                    {
                        buildRequest.worker.Order(BuildingType.LookUp[buildRequest.Type].Ability, buildRequest.Pos);
                    }
                }
            }

            foreach (BuildRequest request in UnassignedRequests)
            {
                Tyr.Bot.DrawText("BuildRequest: " + UnitTypes.LookUp[request.Type].Name + " " + request.Pos);
            }
            foreach (BuildRequest request in BuildRequests)
            {
                Tyr.Bot.DrawText("BuildRequest: " + UnitTypes.LookUp[request.Type].Name + " " + request.Pos);
            }
        }