private Point GetInjectionPoint() { HPNodeMinHeap hpHeap = new HPNodeMinHeap(this.Tissue.GetEntitiesByType(EntityEnum.HoshimiPoint).Count); int radius = 200; foreach (Entity e in this.Tissue.GetEntitiesByType(EntityEnum.HoshimiPoint)) { HPNode hp = new HPNode(0, new Point(e.X, e.Y)); // buat HPNode baru // hitung area cost if (this.Tissue[hp.Loc.X, hp.Loc.Y].AreaType == AreaEnum.LowDensity) { hp.cost -= 5; } else if (this.Tissue[hp.Loc.X, hp.Loc.Y].AreaType == AreaEnum.MediumDensity) { hp.cost -= 1; } else if (this.Tissue[hp.Loc.X, hp.Loc.Y].AreaType == AreaEnum.HighDensity) { hp.cost += 3; } /* * // perhitungkan PierreIP * foreach (InjectionPointInfo ipInfo in OtherInjectionPointsInfo) * { * if (ipInfo.PlayerID == 0) * if (MyAI.squareDist(ipInfo.Location, hp.Loc) <= radius) * hp.cost += 500; * }*/ // cek sekitar hp ini Point p; int numAzn = 0; int numHp = 0; foreach (Entity entity in this.Tissue.GetEntitiesByType(EntityEnum.AZN)) { p = new Point(entity.X, entity.Y); if (MyAI.squareDist(hp.Loc, p) <= radius) //if (Global.GetPathLength(hp.Loc, p) <= radius) { numAzn++; if (numAzn == 1) { hp.cost -= 8; } else { hp.cost -= 1; } } p = Point.Empty; } foreach (Entity entity in this.Tissue.GetEntitiesByType(EntityEnum.HoshimiPoint)) { if (e.X == hp.Loc.X && e.Y == hp.Loc.Y) { continue; // skip if it is here } p = new Point(entity.X, entity.Y); if (MyAI.squareDist(hp.Loc, p) <= radius) //if (Global.GetPathLength(hp.Loc, p) <= radius) { numHp++; if (numHp == 1) { hp.cost -= 1; } else if ((numHp <= 4) && (numHp > 1)) { hp.cost -= 3; } else { hp.cost -= 5; } } p = Point.Empty; } foreach (BaseObjective baseObj in Mission.Objectives) { if (baseObj is UniqueNavigationObjective) { /*foreach (NavPoint navp in ((UniqueNavigationObjective)baseObj).NavPoints) * { * //if (MyAI.squareDist(hp.Loc, navp.Location) <= (radius * 3)) * if (navp.EndTurn <= 500) * { * if (Global.GetPathLength(hp.Loc, navp.Location) < 100) * hp.cost -= 5; * else * hp.cost += 10; * } * }*/ if (Global.GetPathLength(hp.Loc, ((UniqueNavigationObjective)baseObj).NavPoints[0].Location) < 100) { if (((UniqueNavigationObjective)baseObj).NavPoints[0].EndTurn <= 500) { hp.cost -= 5; } } else { hp.cost += 10; } } else if (baseObj is NavigationObjective) { foreach (NavPoint navp in ((NavigationObjective)baseObj).NavPoints) { //if (MyAI.squareDist(hp.Loc, navp.Location) <= (radius * 3)) if (navp.EndTurn <= 500) { if (Global.GetPathLength(hp.Loc, navp.Location) < 100) { hp.cost -= 5; } else { hp.cost += 10; } } } } } //hp.cost += (int)(hp.cost * 0.001f); hpHeap.Put(hp); // masukkan ke heap } return(hpHeap.GetMin().Loc); // ambil minimum element }
private Point GetInjectionPoint() { HPNodeMinHeap hpHeap = new HPNodeMinHeap(this.Tissue.GetEntitiesByType(EntityEnum.HoshimiPoint).Count); int radius = 200; foreach (Entity e in this.Tissue.GetEntitiesByType(EntityEnum.HoshimiPoint)) { HPNode hp = new HPNode(0, new Point(e.X, e.Y)); // buat HPNode baru // hitung area cost if (this.Tissue[hp.Loc.X, hp.Loc.Y].AreaType == AreaEnum.LowDensity) hp.cost -= 5; else if (this.Tissue[hp.Loc.X, hp.Loc.Y].AreaType == AreaEnum.MediumDensity) hp.cost -= 1; else if (this.Tissue[hp.Loc.X, hp.Loc.Y].AreaType == AreaEnum.HighDensity) hp.cost += 3; /* // perhitungkan PierreIP foreach (InjectionPointInfo ipInfo in OtherInjectionPointsInfo) { if (ipInfo.PlayerID == 0) if (MyAI.squareDist(ipInfo.Location, hp.Loc) <= radius) hp.cost += 500; }*/ // cek sekitar hp ini Point p; int numAzn = 0; int numHp = 0; foreach (Entity entity in this.Tissue.GetEntitiesByType(EntityEnum.AZN)) { p = new Point(entity.X, entity.Y); if (MyAI.squareDist(hp.Loc, p) <= radius) //if (Global.GetPathLength(hp.Loc, p) <= radius) { numAzn++; if (numAzn == 1) hp.cost -= 8; else hp.cost -= 1; } p = Point.Empty; } foreach (Entity entity in this.Tissue.GetEntitiesByType(EntityEnum.HoshimiPoint)) { if (e.X == hp.Loc.X && e.Y == hp.Loc.Y) continue; // skip if it is here p = new Point(entity.X, entity.Y); if (MyAI.squareDist(hp.Loc, p) <= radius) //if (Global.GetPathLength(hp.Loc, p) <= radius) { numHp++; if (numHp == 1) hp.cost -= 1; else if ((numHp <= 4) && (numHp > 1)) hp.cost -= 3; else hp.cost -= 5; } p = Point.Empty; } foreach (BaseObjective baseObj in Mission.Objectives) { if (baseObj is UniqueNavigationObjective) { /*foreach (NavPoint navp in ((UniqueNavigationObjective)baseObj).NavPoints) { //if (MyAI.squareDist(hp.Loc, navp.Location) <= (radius * 3)) if (navp.EndTurn <= 500) { if (Global.GetPathLength(hp.Loc, navp.Location) < 100) hp.cost -= 5; else hp.cost += 10; } }*/ if (Global.GetPathLength(hp.Loc, ((UniqueNavigationObjective)baseObj).NavPoints[0].Location) < 100) { if (((UniqueNavigationObjective)baseObj).NavPoints[0].EndTurn <= 500) hp.cost -= 5; } else { hp.cost += 10; } } else if (baseObj is NavigationObjective) { foreach (NavPoint navp in ((NavigationObjective)baseObj).NavPoints) { //if (MyAI.squareDist(hp.Loc, navp.Location) <= (radius * 3)) if (navp.EndTurn <= 500) { if (Global.GetPathLength(hp.Loc, navp.Location) < 100) hp.cost -= 5; else hp.cost += 10; } } } } //hp.cost += (int)(hp.cost * 0.001f); hpHeap.Put(hp); // masukkan ke heap } return hpHeap.GetMin().Loc; // ambil minimum element }