示例#1
0
文件: ifNothing.cs 项目: znsoft/AiCup
 double GetTeamRadius(long removedTrooperId = -1, Point addedTrooper = null)
 {
     double radius = Inf;
     for (var i = 0; i < Width; i++)
     {
         for (var j = 0; j < Height; j++)
         {
             double maxV = addedTrooper == null ? -Inf : addedTrooper.GetDistanceTo(i, j);
             foreach (var trooper in Team)
                 if (removedTrooperId != trooper.Id)
                     maxV = Math.Max(maxV, trooper.GetDistanceTo(i, j));
             radius = Math.Min(radius, maxV);
         }
     }
     return radius;
 }
示例#2
0
文件: ifNothing.cs 项目: znsoft/AiCup
        Point GoToEncircling(Trooper center, Point goal)
        {
            var bestPoint = new Point(0, 0, Inf);
            double optDanger = self.Type == TrooperType.FieldMedic || self.Type == TrooperType.Sniper ? Inf : -Inf;
            for (var i = 0; i < Width; i++)
            {
                for (var j = 0; j < Height; j++)
                {
                    if (map[i, j] == 0 || i == self.X && j == self.Y)
                    {
                        if (self.GetDistanceTo(i, j) > 10) // немного ускорит
                            continue;
                        // Нужно чтобы хватило ходов
                        int steps = GetShoterPath(self, new Point(i, j), map, beginFree: true, endFree: true);
                        if (self.ActionPoints / GetMoveCost() >= steps)
                        {
                            // и чтобы не закрывали кратчайший путь:
                            int before = goal == null ? Inf : GetShoterPath(center, goal, map, beginFree:true, endFree: false);
                            map[self.X, self.Y] = 0;
                            map[i, j] = 1;
                            int after = goal == null ? Inf : GetShoterPath(center, goal, map, beginFree: true, endFree: false);
                            map[i, j] = 0;
                            map[self.X, self.Y] = 1;

                            if ((goal == null || after < Inf) && after <= before)
                            {
                                double sum = GetShoterPath(center, new Point(i, j), notFilledMap, beginFree: true, endFree: true);
                                double dang = danger[i, j] + (goal == null ? 0 : goal.GetDistanceTo(i, j) * 0.01);
                                if (sum < bestPoint.profit ||
                                    EqualF(sum, bestPoint.profit) &&
                                    (self.Type == TrooperType.FieldMedic || self.Type == TrooperType.Sniper ? (dang < optDanger) : (dang > optDanger))
                                   )
                                {
                                    bestPoint = new Point(i, j, sum);
                                    optDanger = dang;
                                }
                            }
                        }
                    }
                }
            }
            return bestPoint.profit >= Inf ? null : bestPoint;
        }
示例#3
0
 private void SetVisibleProfit(int x, int y)
 {
     var position = new Point(x, y);
     for(var i = 0; i < Width; i++)
         for (var j = 0; j < Height; j++)
             if (x != i || y != j)
                 circle_visible_profit[i, j] += 10.0/position.GetDistanceTo(i, j);
 }
示例#4
0
文件: IfBonus.cs 项目: znsoft/AiCup
        Point SkipPath(Trooper center, Point goal)
        {
            // В первую очередь минимизировать путь center до goal
            var bestPoint = new Point(0, 0, Inf);
            double minPenalty = Inf;
            for (var i = 0; i < Width; i++)
            {
                for (var j = 0; j < Height; j++)
                {
                    if (map[i, j] == 0 || i == self.X && j == self.Y)
                    {
                        if (self.GetDistanceTo(i, j) > 10) // немного ускорит
                            continue;
                        // Нужно чтобы хватило ходов
                        int steps = GetShoterPath(self, new Point(i, j), map, beginFree: true, endFree: true);
                        if (self.ActionPoints / GetMoveCost() >= steps)
                        {
                            // и чтобы не закрывали кратчайший путь:
                            map[self.X, self.Y] = 0;
                            map[i, j] = 1;
                            int after = GetShoterPath(center, goal, map, beginFree: true, endFree: false);
                            map[i, j] = 0;
                            map[self.X, self.Y] = 1;

                            double penalty = GetShoterPath(center, new Point(i, j), notFilledMap, beginFree: true, endFree: true);
                            penalty += 2*Math.Max(0, goal.GetDistanceTo(center) - goal.GetDistanceTo(i, j) + 1);

                            if (after < bestPoint.profit || EqualF(after, bestPoint.profit) && penalty < minPenalty)
                            {
                                bestPoint = new Point(i, j, after);
                                minPenalty = penalty;
                            }
                        }
                    }
                }
            }
            return bestPoint.profit >= Inf ? null : bestPoint;
        }