public Point GetTargetToAtack(Point CurLocation) { AtackPointInfo ap = new AtackPointInfo(); for (int i = 0; i < ATargets.Count; i++) { if (ATargets[i].Need > ATargets[i].Exist) { ap = ATargets[i]; ap.Exist++; ATargets.RemoveAt(i); ATargets.Add(ap); return ap.Location; } } return CurLocation; }
//��������� ������ �� BTargets void UpdateATargetsData() { int flag = 0; int i = 0; AtackPointInfo ap = new AtackPointInfo(); //���������� ������ �� ���� BTargets for (i = 0; i < ATargets.Count; i++) { ap = ATargets[i]; ap.Exist = 0; ATargets.RemoveAt(i); ATargets.Insert(i, ap); } //�������� ������ ��: foreach (NanoBot bot in NanoBots) { //ATargets if ((bot is Atacker) && (((Atacker)bot).Target.X != -1)) { flag = 0; for (i = 0; i < ATargets.Count; i++) { if (ATargets[i].Location == ((Atacker)bot).Target) { ap = ATargets[i]; ap.Exist++; ATargets.RemoveAt(i); ATargets.Insert(i, ap); flag = 1; } //���� ��� ����� �� ����, �� ��� ����������, � � ���� ������ �� ������ if (ATargets[i].Location == ((Atacker)bot).Location) { ATargets.RemoveAt(i); } } //���� � ���� ���� ����, �� � ��� � ������, �� � ���� ��� ���� if (flag == 0) { ((Atacker)bot).Target.X = -1; ((Atacker)bot).Target.Y = -1; ((Atacker)bot).StopMoving(); } } } }
//��������� ��� ������ ����� void UpdateData() { int i = 0; int flag = 0; BattlePointInfo bp = new BattlePointInfo(); AtackPointInfo ap = new AtackPointInfo(); //���������� ������ �� ���� HoshimiPoints for (i = 0; i < HoshimiPoints.Length; i++) { HoshimiPoints[i].Convoys = 0; HoshimiPoints[i].Peasants = 0; HoshimiPoints[i].Full = 0; if (HoshimiPoints[i].Needle == 1) { HoshimiPoints[i].Needle = 0; } } //���������� ������ �� ���� NavigationPoints if (NavigationPoints != null) { for (i = 0; i < NavigationPoints.Length; i++) { NavigationPoints[i].Navigators = 0; } } //���������� ������ �� ���� BTargets for (i = 0; i < BTargets.Count; i++) { bp = BTargets[i]; bp.Covered = 0; BTargets.RemoveAt(i); BTargets.Insert(i, bp); } //���������� ������ �� ���� ATargets for (i = 0; i < ATargets.Count; i++) { ap = ATargets[i]; ap.Exist = 0; ATargets.RemoveAt(i); ATargets.Insert(i, ap); } //���������� ������ �� ���� ������� for (i = 0; i < Convoys.Length; i++) { if (Convoys[i].HNumber != -1) { if (Convoys[i].IsNavigating) { NavigationPoints[Convoys[i].HNumber].Navigators++; } else { HoshimiPoints[Convoys[i].HNumber].Convoys++; } } Convoys[i].Containers = 0; Convoys[i].Defenders = 0; } //���������� ������ �� ���� ������� if (CollConvoys != null) { for (i = 0; i < CollConvoys.Length; i++) { if (CollConvoys[i].HNumber >= 0) NavigationPoints[CollConvoys[i].HNumber].Navigators++; CollConvoys[i].Containers = 0; CollConvoys[i].Defenders = 0; } } //���������� ������ �� ���� ������� if (BigConvoys != null) { for (i = 0; i < BigConvoys.Length; i++) { if (BigConvoys[i].HNumber >= 0) NavigationPoints[BigConvoys[i].HNumber].Navigators++; BigConvoys[i].Containers = 0; BigConvoys[i].Defenders = 0; } } //�������� ����� Needle`� if (OtherNanoBotsInfo != null) { foreach (NanoBotInfo bot in OtherNanoBotsInfo) { if ((bot.NanoBotType == NanoBotType.NanoNeedle) || (bot.NanoBotType == NanoBotType.NanoBlocker)) { for (i = 0; i < HoshimiPoints.Length; i++) { if (bot.Location == HoshimiPoints[i].Location) { HoshimiPoints[i].Needle = 2; } } } } } //�������� ������ ��: foreach(NanoBot bot in NanoBots) { //NavigationPoints if((bot is Navigator)&&(((Navigator)bot).NPNumber >= 0)) { NavigationPoints[((Navigator)bot).NPNumber].Navigators++; } if ((bot is Doctor) && (((Doctor)bot).NPNumber >= 0)) { NavigationPoints[((Doctor)bot).NPNumber].Navigators++; } //HoshimiPoints (collectors & containers) if ((bot is Container)&&(((Container)bot).HPNumber >= 0)) { HoshimiPoints[((Container)bot).HPNumber].Peasants++; } //HoshimiPoints (Needles) if ((bot is Needle) && (((Needle)bot).HPNumber >= 0)) { HoshimiPoints[((Needle)bot).HPNumber].Needle = 1; HoshimiPoints[((Needle)bot).HPNumber].InPast = 1; if (bot.Stock == bot.ContainerCapacity) { HoshimiPoints[((Needle)bot).HPNumber].Full = 1; } } //BTargets if ((bot is Protector) && (((Protector)bot).Target.X != -1)) { for (i = 0; i < BTargets.Count; i++) { if (BTargets[i].Location == ((Protector)bot).Target) { bp = BTargets[i]; bp.Covered = 1; BTargets.RemoveAt(i); BTargets.Insert(i, bp); } } } //ATargets if ((bot is Atacker) && (((Atacker)bot).Target.X != -1)) { flag = 0; for (i = 0; i < ATargets.Count; i++) { if (ATargets[i].Location == ((Atacker)bot).Target) { ap = ATargets[i]; ap.Exist++; ATargets.RemoveAt(i); ATargets.Insert(i, ap); flag = 1; } //���� ��� ����� �� ����, �� ��� ����������, � � ���� ������ �� ������ if (ATargets[i].Location == ((Atacker)bot).Location) { ATargets.RemoveAt(i); } } //���� � ���� ���� ����, �� � ��� � ������, �� � ���� ��� ���� if (flag == 0) { ((Atacker)bot).Target.X = -1; ((Atacker)bot).Target.Y = -1; ((Atacker)bot).StopMoving(); } } //������� if (bot is ConvoyContainer) { if (((ConvoyContainer)bot).ConvoyNumber == -1) { ((ConvoyContainer)bot).SetConvoyNumber(this); } else { Convoys[((ConvoyContainer)bot).ConvoyNumber].Containers++; } } //� ��� ��� ������� if (bot is ConvoyDefender) { if (((ConvoyDefender)bot).ConvoyNumber == -1) { ((ConvoyDefender)bot).SetConvoyNumber(this); } else { Convoys[((ConvoyDefender)bot).ConvoyNumber].Defenders++; } } //������� if (bot is ConvoyCollector) { if (((ConvoyCollector)bot).ConvoyNumber == -1) { ((ConvoyCollector)bot).SetConvoyNumber(this); } else { CollConvoys[((ConvoyCollector)bot).ConvoyNumber].Containers++; } } //� ��� ��� ������� if (bot is ConvoyDefender2) { if (((ConvoyDefender2)bot).ConvoyNumber == -1) { ((ConvoyDefender2)bot).SetConvoyNumber(this); } else { CollConvoys[((ConvoyDefender2)bot).ConvoyNumber].Defenders++; } } //������� if (bot is BigConvoyContainer) { if (((BigConvoyContainer)bot).ConvoyNumber == -1) { ((BigConvoyContainer)bot).SetConvoyNumber(this); } else { BigConvoys[((BigConvoyContainer)bot).ConvoyNumber].Containers++; } } //� ��� ��� ������� if (bot is ConvoyDefender3) { if (((ConvoyDefender3)bot).ConvoyNumber == -1) { ((ConvoyDefender3)bot).SetConvoyNumber(this); } else { BigConvoys[((ConvoyDefender3)bot).ConvoyNumber].Defenders++; } } } }
void MyAI_ChooseInjectionPointEvent() { int HealConvoysWithContainers = 0; int BigHealConvoys = 0; int HealConvoysWithCollectors = 0; int count = 0; int tmp = 0; int tmp1 = 0; int FHPnum = -1; int FAPnum = -1; Point p = new Point(); NavigationPointInfo FirstNavPoint = new NavigationPointInfo(); ScoreInfo FirstScoreObj = new ScoreInfo(); BattlePointInfo bp = new BattlePointInfo(); AtackPointInfo ap = new AtackPointInfo(); Pathfinder = new AStar(this.Tissue); ePathfinder = new eAStar(this.Tissue, new Point(PierreTeamInjectionPoint.X - 12, PierreTeamInjectionPoint.Y - 12), 24); //��������� ������ ReadAllMissions(); //������� HP � AP ReadHPsAndAPs(); //���������� ����� ������ � ������� HP, �� ������� ������ ����� AnalizeMap(ref FHPnum, ref FAPnum); //������� ����� ������ � ����� ������� ScoreMission`� if (ScoreObjectives != null) { count = 0; tmp = 10000; tmp1 = 0; for (int i = 0; i < ScoreObjectives.Length; i++) { if (ScoreObjectives[i].Score > count) { count = ScoreObjectives[i].Score; } if (ScoreObjectives[i].Turn < tmp) { tmp = ScoreObjectives[i].Turn; tmp1 = i; } } FirstScoreObj = ScoreObjectives[tmp1]; MinHPsToTake = (int)(count / 220) + 1; } else { FirstScoreObj.Score = 0; FirstScoreObj.Turn = 2000; MinHPsToTake = 0; } //������� ����� ������ NavigationMission if (NavigationPoints != null) { count = 10000; tmp = -1; for (int i = 0; i < NavigationPoints.Length; i++) { if (NavigationPoints[i].EndTurn < count) { count = NavigationPoints[i].EndTurn; tmp = i; } } FirstNavPoint = NavigationPoints[tmp]; } else { FirstNavPoint.Location = HoshimiPoints[FHPnum].Location; } //�������� � ����� ������ �� Pierre`� this.InjectionPointWanted = FinallyChooseInjectionPoint(HoshimiPoints[FHPnum].Location, AZNPoints[FAPnum].Location, FirstNavPoint.Location); if (KillPierre) { ap.Location = PierreTeamInjectionPoint; ap.Need = 5; ap.Exist = 0; ATargets.Add(ap); } //���� �������� HP � AP /* if (BattleExpected) { //��� ���������� ������������ ����� HP ���������� ����� for (int i = 0; i < MinHPsToTake; i++) { p = HoshimiPoints[(int)MyHPs[i]].Location; bp.Location = p; bp.Covered = 0; BTargets.Add(bp); } //��� ������ AP ���������� ����� p = AZNPoints[FAPnum].Location; bp.Location = p; bp.Covered = 0; BTargets.Add(bp); } */ //���������, ������� � ����� ����� ��� ���� NBPROTECTORTOBUILD = BTargets.Count; OBSERVERSTOBUILD = 1; NBBODYGUARSTOBUILD = 4; BodyGuards = new BodyGuard[NBBODYGUARSTOBUILD]; for (int i = 0; i < BodyGuards.Length; i++) { BodyGuards[i] = null; } //if (KillPierre) //{ // NBNAVIGATORTOBUILD = NavigationPoints.Length * 2; // NBATACKERTOBUILD = 4; //} //else //{ NBATACKERTOBUILD = 0; if (NavigationPoints != null) { for (int i = 0; i < NavigationPoints.Length; i++) { if ((NavigationPoints[i].BotType == NanoBotType.NanoExplorer) || ((NavigationPoints[i].BotType == NanoBotType.Unknown) && (NavigationPoints[i].Stock <= 0))) { NBNAVIGATORTOBUILD++; } else if ((NavigationPoints[i].BotType == NanoBotType.NanoCollector) && (NavigationPoints[i].Stock <= 0)) { NBATACKERTOBUILD++; AtackPointInfo api = new AtackPointInfo(); api.Location = NavigationPoints[i].Location; api.Need = 1; api.Exist = 0; ATargets.Add(api); } else if (((NavigationPoints[i].BotType == NanoBotType.NanoCollector) || (NavigationPoints[i].BotType == NanoBotType.Unknown)) && (NavigationPoints[i].Stock > 0) && (NavigationPoints[i].Stock <= 10)) { NBDOCTORSTOBUILD++; } else if (((NavigationPoints[i].BotType == NanoBotType.NanoContainer) || ((NavigationPoints[i].BotType == NanoBotType.Unknown) && (NavigationPoints[i].Stock > 0))) && (NavigationPoints[i].Stock <= 50)) { HealConvoysWithContainers++; } else if ((NavigationPoints[i].BotType == NanoBotType.NanoContainer || (NavigationPoints[i].BotType == NanoBotType.Unknown)) && (NavigationPoints[i].Stock > 50)) { BigHealConvoys++; } else if ((NavigationPoints[i].BotType == NanoBotType.NanoCollector) && (NavigationPoints[i].Stock > 10)) { HealConvoysWithCollectors++; } } } else { NBNAVIGATORTOBUILD = 0; } //} if (HealConvoysWithCollectors > 0) { CollConvoys = new ConvoyWithCollector[HealConvoysWithCollectors]; for (int i = 0; i < CollConvoys.Length; i++) { CollConvoys[i] = new ConvoyWithCollector(); } } if (BigHealConvoys > 0) { BigConvoys = new ConvoyWithBigContainer[BigHealConvoys]; for (int i = 0; i < BigConvoys.Length; i++) { BigConvoys[i] = new ConvoyWithBigContainer(); } } //����� ������� - ������� �� ����, ������� �� � �������� ����� ��������� � ������� ��� �� ���� int NotAllocatedBots = Utils.NbrMaxBots - 2 - NBBODYGUARSTOBUILD - NBATACKERTOBUILD - NBPROTECTORTOBUILD - MyHPs.Count; int ConvoysNumber = Math.Min((NotAllocatedBots - (NotAllocatedBots % 3)) / 3, MyHPs.Count + HealConvoysWithContainers); ConvoysNumber = Math.Max(ConvoysNumber, 3); Convoys = new Convoy[ConvoysNumber]; for (int i = 0; i < Convoys.Length; i++) { Convoys[i] = new Convoy(false); } for (int i = 0; i < HealConvoysWithContainers; i++) { Convoys[i].IsNavigating = true; } }