public SetExtendedMotd(VBot bot, MotdModule motd) : base(bot, "extendedset", motd) { }
public EmulateMotd(VBot bot, MotdModule motd) : base(bot, "Emulate", motd) { }
public GetMotdSetter(VBot bot, MotdModule motd) : base(bot, "Setter", motd) { }
public RemoveMotd(VBot bot, MotdModule motd) : base(bot, "Remove", motd) { }
public void Analyse(VBot bot) { // // get the start location // foreach (Agent unit in Controller.GetAgents(Units.ResourceCenters)) { StartLocation = new Base { Location = unit.Unit.Pos } } ; // // get location of all the bases // // get location of each mineral field and vespene geyser List <MineralField> mineralFields = new List <MineralField>(); foreach (Unit mf in Controller.GetUnits(Units.MineralFields)) { mineralFields.Add(new MineralField { Location = mf.Pos, UnitType = mf.UnitType }); } List <VespeneGeyser> vespeneGeysers = new List <VespeneGeyser>(); foreach (Unit vg in Controller.GetUnits(Units.GasGeysers)) { vespeneGeysers.Add(new VespeneGeyser { Location = vg.Pos, UnitType = vg.UnitType }); } //group them into set of mineral fields List <MineralField> checkedMineralFields = new List <MineralField>(); List <VespeneGeyser> checkedVespeneGeysers = new List <VespeneGeyser>(); int currentSet = 0; foreach (MineralField mf in mineralFields) { if (checkedMineralFields.Contains(mf)) // checks if mf has been used and skips if true { continue; } BaseLocations.Add(new Base()); checkedMineralFields.Add(mf); // adds mf to checklist and current set BaseLocations[currentSet].MineralPatches.Add(mf); // gets rest of local mfs to add to set and check for (int i = 0; i < BaseLocations[currentSet].MineralPatches.Count; i++) { MineralField mfLocal = BaseLocations[currentSet].MineralPatches[i]; foreach (MineralField mf2 in mineralFields) { if (checkedMineralFields.Contains(mf2)) // potiental source of error - mf2 =/= mf { continue; } if (GetDistance2D(mf2.Location, mfLocal.Location) > 5) // skip if not within 5 { continue; } // we want to add this minefield to our mf set and checked list BaseLocations[currentSet].MineralPatches.Add(mf2); checkedMineralFields.Add(mf2); } } currentSet++; } // add gas geysers foreach (Base baseLoc in BaseLocations) { foreach (VespeneGeyser vg in vespeneGeysers) { if (checkedVespeneGeysers.Contains(vg)) { continue; } foreach (MineralField mf in baseLoc.MineralPatches) { if (GetDistance2D(mf.Location, vg.Location) < 10) { checkedVespeneGeysers.Add(vg); baseLoc.VespeneGeysers.Add(vg); break; } } } } // get average position of each mineral cluster foreach (Base baseLocation in BaseLocations) { // find average location of cluster float x = 0; float y = 0; foreach (MineralField mf in baseLocation.MineralPatches) { x += mf.Location.X; y += mf.Location.Y; } foreach (VespeneGeyser vg in baseLocation.VespeneGeysers) { x += vg.Location.X; y += vg.Location.Y; } // average cluster location float avgX = x / (baseLocation.MineralPatches.Count + baseLocation.VespeneGeysers.Count); float avgY = y / (baseLocation.MineralPatches.Count + baseLocation.VespeneGeysers.Count); Point averageOfCluster = new Point { X = avgX, Y = avgY }; avgX = (int)avgX + 0.5f; avgY = (int)avgX + 0.5f; // check placement of surrounding tiles Point tempLoc = null; float closestDist = 1000000; for (int i = 0; i < 20; i++) { for (int j = 0; j <= i; j++) { float maxDist; Point newPos; newPos = new Point { X = averageOfCluster.X + i - j, Y = averageOfCluster.Y + j }; maxDist = checkPosition(newPos, baseLocation); if (maxDist < closestDist) { tempLoc = newPos; closestDist = maxDist; } newPos = new Point { X = averageOfCluster.X + i - j, Y = averageOfCluster.Y - j }; maxDist = checkPosition(newPos, baseLocation); if (maxDist < closestDist) { tempLoc = newPos; closestDist = maxDist; } newPos = new Point { X = averageOfCluster.X - i + j, Y = averageOfCluster.Y + j }; maxDist = checkPosition(newPos, baseLocation); if (maxDist < closestDist) { tempLoc = newPos; closestDist = maxDist; } newPos = new Point { X = averageOfCluster.X - i + j, Y = averageOfCluster.Y - j }; maxDist = checkPosition(newPos, baseLocation); if (maxDist < closestDist) { tempLoc = newPos; closestDist = maxDist; } } } // final tile placement should be tempLoc.. add it to base locatoins baseLocation.Location = tempLoc; } // order bases List <Base> orderedLocations = BaseLocations.OrderBy(b => GetDistance2D(b.Location, StartLocation.Location)).ToList(); BaseLocations = orderedLocations; StartLocation.MineralPatches = BaseLocations[0].MineralPatches; StartLocation.VespeneGeysers = BaseLocations[0].VespeneGeysers; // get enemy locations foreach (Point2D startLocation in VBot.Bot.GameInfo.StartRaw.StartLocations) { if (GetDistance2D(StartLocation.Location, startLocation) < 10) { continue; } EnemyStartLocations.Add(startLocation); } TargetAttackLocation = EnemyStartLocations[0]; // generate distances from enemies main base DistancesToEnemy = GenerateDistances(EnemyStartLocations[0]); }
public CurrentMotdTick(VBot bot, MotdModule motd) : base(bot, "Tick", motd) { }
public MotdCommand(VBot bot, string command, MotdModule motd) : base(bot, "!" + motd.GetName() + command) { this.motd = motd; }
public GetMOTD(VBot bot, MotdModule motd) : base(bot, "get", motd) { }
public Search(VBot bot, SearchClassEntry SearchEntry) : base(bot, SearchEntry.Command) { this.SearchData = SearchEntry; }