private void AnalizeMap(ref int HPnum, ref int APnum) { eAStar PathFinder = new eAStar(this.Tissue); //used = new int[HoshimiPoints.Length]; //path = new Stack<int>(); //BestPath = new Stack<int>(); //int Num = 0; //int Time = 0; HPtoHPdistances = new int[HoshimiPoints.Length, HoshimiPoints.Length]; HPtoAPdistances = new int[HoshimiPoints.Length, AZNPoints.Length]; for (int i = 0; i < HoshimiPoints.Length; i++) { HPtoHPdistances[i, i] = 0; for (int j = 0; j < i; j++) { PathFinder.FindPath(HoshimiPoints[i].Location, HoshimiPoints[j].Location, ref HPtoHPdistances[i, j]); HPtoHPdistances[i, j] = (int)HPtoHPdistances[i, j] * (StepCost(HoshimiPoints[i].Location) + StepCost(HoshimiPoints[j].Location)) / 2; HPtoHPdistances[j, i] = HPtoHPdistances[i, j]; } for (int j = 0; j < AZNPoints.Length; j++) { //PathFinder.FindPath(HoshimiPoints[i].Location, AZNPoints[j].Location, ref HPtoAPdistances[i, j]); //HPtoAPdistances[i, j] = (int)HPtoAPdistances[i, j] * (StepCost(HoshimiPoints[i].Location) + StepCost(AZNPoints[j].Location)) / 2; HPtoAPdistances[i, j] = EstimateMovementTime(HoshimiPoints[i].Location, AZNPoints[j].Location); } } //ScanList(-1, 0, ref Num, ref Time); List<int>[] Path = new List<int>[HoshimiPoints.Length]; int[] HPN = new int[HoshimiPoints.Length]; int[] fafa = new int[HoshimiPoints.Length]; int[] value = new int[HoshimiPoints.Length]; int sum = 0; int last = 0; int tmp = 0; int tmpNum1 = 0; int tmpNum2 = 0; int tmpDist3 = 0; int tmpDist4 = 0; double alpha = 1; for (int i = 0; i < HoshimiPoints.Length; i++) { value[i] = 0; } //������� �������� ������������ ����� if (NavigationPoints != null) { for (int i = 0; i < HoshimiPoints.Length; i++) { for (int j = 0; j < NavigationPoints.Length; j++) { ePathfinder.FindPath(HoshimiPoints[i].Location, NavigationPoints[j].Location, ref tmp); if (tmp + 100 > NavigationPoints[j].EndTurn) { value[i] = -1; } } } } //��������� "��������" ����� ������ for (int i = 0; i < HoshimiPoints.Length; i++) { if (value[i] != -1) { //��������� ����� ����������� ������� Path[i] = new List<int>(); Path[i].Clear(); for (int j = 0; j < fafa.Length; j++) { fafa[j] = 0; } Path[i].Add(i); HPN[i] = 1; fafa[i] = 1; sum = 0; last = i; //���� ���� ���� (����� - ����-� �������� �������� � AZN while (sum < 1500 * (1 + alpha)) { //���� HP, ��������� � ������� HP tmp = 10000; tmpNum1 = -1; for (int j = 0; j < HoshimiPoints.Length; j++) { if ((HPtoHPdistances[last, j] < tmp) && (fafa[j] == 0)) { tmp = HPtoHPdistances[last, j]; tmpNum1 = j; } } tmpDist3 = tmp; //���� AP, ��������� � ������� HP tmp = 10000; tmpNum2 = -1; for (int j = 0; j < AZNPoints.Length; j++) { if (HPtoAPdistances[last, j] < tmp) { tmp = HPtoAPdistances[last, j]; tmpNum2 = j; } } tmpDist4 = tmp; //���� ���-�� �����������, �� ���� if ((tmpNum1 == -1) || (tmpNum2 == -1)) break; //��������� ����� � ������ sum = sum + tmpDist3 + (int)(tmpDist4 * alpha); if (sum < 1500 * (1 + alpha)) { fafa[tmpNum1] = 1; HPN[i]++; Path[i].Add(tmpNum1); last = tmpNum1; } } //���� AZN, ��������� � ������ tmpDist3 = 10000; for (int j = 0; j < AZNPoints.Length; j++) { if (HPtoAPdistances[i, j] < tmpDist3) { tmpDist3 = HPtoAPdistances[i, j]; } } //��������� "��������" value[i] = HPN[i] * 1000 - tmpDist3 * 10 + (int)(1500 * (1 + alpha) - sum); } } /* MyHPs.Add(0); MyHPs.Add(1); MyHPs.Add(2); HPnum = 0; APnum = 0; */ //������� ������ ����� ������ tmp = -1; tmpNum1 = -1; for (int i = 0; i < HoshimiPoints.Length; i++) { if (value[i] > tmp) { tmp = value[i]; tmpNum1 = i; } } HPnum = tmpNum1; //������� ��������� ����� � AZN tmpDist3 = 10000; tmpNum1 = -1; for (int j = 0; j < AZNPoints.Length; j++) { if (HPtoAPdistances[HPnum, j] < tmpDist3) { tmpDist3 = HPtoAPdistances[HPnum, j]; tmpNum1 = j; } } APnum = tmpNum1; /* for (int i = 0; i < Path[HPnum].Count; i++) { MyHPs.Add(Path[HPnum][i]); } */ //��������� ����� ����������� ������� for (int j = 0; j < fafa.Length; j++) { fafa[j] = 0; } MyHPs.Add(HPnum); fafa[HPnum] = 1; sum = 0; last = HPnum; //���� ���� ���� while (sum < 1500) { //���� HP, ��������� � ������� HP tmp = 10000; tmpNum1 = -1; for (int j = 0; j < HoshimiPoints.Length; j++) { if ((HPtoHPdistances[last, j] < tmp) && (fafa[j] == 0)) { tmp = HPtoHPdistances[last, j]; tmpNum1 = j; } } tmpDist3 = tmp; //���� ���-�� �����������, �� ���� if (tmpNum1 == -1) break; //��������� ����� � ������ sum = sum + tmpDist3; if (sum < 1500) { fafa[tmpNum1] = 1; MyHPs.Add(tmpNum1); last = OptimizePath(); } } }
private void AnalizeMap(ref int HPnum, ref int APnum) { eAStar PathFinder = new eAStar(this.Tissue); //used = new int[HoshimiPoints.Length]; //path = new Stack<int>(); //BestPath = new Stack<int>(); //int Num = 0; //int Time = 0; HPtoHPdistances = new int[HoshimiPoints.Length, HoshimiPoints.Length]; HPtoAPdistances = new int[HoshimiPoints.Length, AZNPoints.Length]; for (int i = 0; i < HoshimiPoints.Length; i++) { HPtoHPdistances[i, i] = 0; for (int j = 0; j < i; j++) { PathFinder.FindPath(HoshimiPoints[i].Location, HoshimiPoints[j].Location, ref HPtoHPdistances[i, j]); HPtoHPdistances[i, j] = (int)HPtoHPdistances[i, j] * (StepCost(HoshimiPoints[i].Location) + StepCost(HoshimiPoints[j].Location)) / 2; HPtoHPdistances[j, i] = HPtoHPdistances[i, j]; } for (int j = 0; j < AZNPoints.Length; j++) { //PathFinder.FindPath(HoshimiPoints[i].Location, AZNPoints[j].Location, ref HPtoAPdistances[i, j]); //HPtoAPdistances[i, j] = (int)HPtoAPdistances[i, j] * (StepCost(HoshimiPoints[i].Location) + StepCost(AZNPoints[j].Location)) / 2; HPtoAPdistances[i, j] = EstimateMovementTime(HoshimiPoints[i].Location, AZNPoints[j].Location); } } //ScanList(-1, 0, ref Num, ref Time); List<int>[] Path = new List<int>[HoshimiPoints.Length]; int[] HPN = new int[HoshimiPoints.Length]; int[] sumDist = new int[HoshimiPoints.Length]; int[] fafa = new int[HoshimiPoints.Length]; int[] value = new int[HoshimiPoints.Length]; int sum = 0; int last = 0; int tmp = 0; int tmpNum1 = 0; int tmpNum2 = 0; int tmpDist3 = 0; int tmpDist4 = 0; double alpha = 1; int zzz = 10000; for (int i = 0; i < HoshimiPoints.Length; i++) { value[i] = 0; } //������� �������� ������������ ����� if (NavigationPoints != null) { for (int i = 0; i < HoshimiPoints.Length; i++) { for (int j = 0; j < NavigationPoints.Length; j++) { if ((NavigationPoints[j].BotType == NanoBotType.NanoExplorer) || ((NavigationPoints[j].BotType == NanoBotType.Unknown) && (NavigationPoints[j].Stock <= 0))) { ePathfinder.FindPath(HoshimiPoints[i].Location, NavigationPoints[j].Location, ref tmp); } else { for (int k = 0; k < AZNPoints.Length; k++) { if (HPtoAPdistances[i, k] < zzz) { zzz = HPtoAPdistances[i, k]; last = k; } } Pathfinder.FindPath(AZNPoints[last].Location, NavigationPoints[j].Location, ref tmp); tmp += zzz; } if (tmp + 100 > NavigationPoints[j].EndTurn) { value[i] = -1; } } if (GeomDist(HoshimiPoints[i].Location, PierreTeamInjectionPoint) < 40) { value[i] = -1; } if (UniqueNavPoints != null) { if (!UNOpossible(i)) { value[i] = -1; } } } } //��������, ���� �� ���� ���� ���������� ����� bool MI = true; for (int i = 0; i < HoshimiPoints.Length; i++) { if (value[i] >= 0) MI = false; } if (MI) { for (int i = 0; i < HoshimiPoints.Length; i++) { value[i] = 0; } } //��������� "��������" ����� ������ for (int i = 0; i < HoshimiPoints.Length; i++) { if (value[i] != -1) { //��������� ����� ����������� ������� Path[i] = new List<int>(); Path[i].Clear(); for (int j = 0; j < fafa.Length; j++) { fafa[j] = 0; } Path[i].Add(i); HPN[i] = 1; fafa[i] = 1; sum = 0; last = i; //���� ���� ���� (����� - ����-� �������� �������� � AZN while (sum < 1500 * (1 + alpha)) { //���� HP, ��������� � ������� HP tmp = 10000; tmpNum1 = -1; sumDist[i] = 0; for (int j = 0; j < HoshimiPoints.Length; j++) { sumDist[i] += HPtoHPdistances[i, j]; if ((HPtoHPdistances[last, j] < tmp) && (fafa[j] == 0)) { tmp = HPtoHPdistances[last, j]; tmpNum1 = j; } } tmpDist3 = tmp; //���� AP, ��������� � ������� HP tmp = 10000; tmpNum2 = -1; for (int j = 0; j < AZNPoints.Length; j++) { if (HPtoAPdistances[last, j] < tmp) { tmp = HPtoAPdistances[last, j]; tmpNum2 = j; } } tmpDist4 = tmp; //���� ���-�� �����������, �� ���� if ((tmpNum1 == -1) || (tmpNum2 == -1)) break; //��������� ����� � ������ sum = sum + tmpDist3 + (int)(tmpDist4 * alpha); if (sum < 1500 * (1 + alpha)) { fafa[tmpNum1] = 1; HPN[i]++; Path[i].Add(tmpNum1); last = tmpNum1; } } //���� AZN, ��������� � ������ tmpDist3 = 10000; int fafaA = -1; for (int j = 0; j < AZNPoints.Length; j++) { if (HPtoAPdistances[i, j] < tmpDist3) { tmpDist3 = HPtoAPdistances[i, j]; fafaA = j; } } Pathfinder.FindPath(HoshimiPoints[i].Location, AZNPoints[fafaA].Location, ref tmpDist3); //��������� "��������" value[i] = HPN[i] * 1000 - tmpDist3 * 10 + (int)(1500 * (1 + alpha) - sum) + (int)(GROUP_VALUE*((double)HoshimiPoints.Length)/((double)sumDist[i]))/* - 10*(int)(((double)sumDist[i])/((double)HoshimiPoints.Length))*/; } } /* MyHPs.Add(0); MyHPs.Add(1); MyHPs.Add(2); HPnum = 0; APnum = 0; */ //������� ������ ����� ������ tmp = -1; tmpNum1 = -1; for (int i = 0; i < HoshimiPoints.Length; i++) { if (value[i] > tmp) { tmp = value[i]; tmpNum1 = i; } } HPnum = tmpNum1; //������� ��������� ����� � AZN tmpDist3 = 10000; tmpNum1 = -1; for (int j = 0; j < AZNPoints.Length; j++) { if (HPtoAPdistances[HPnum, j] < tmpDist3) { tmpDist3 = HPtoAPdistances[HPnum, j]; tmpNum1 = j; } } APnum = tmpNum1; if (UniqueNavPoints != null) { BuildUNOPath(HPnum); } /* for (int i = 0; i < Path[HPnum].Count; i++) { MyHPs.Add(Path[HPnum][i]); } */ BuildPath(HPnum); }