public IEnumerable <Vec> Order(HashSet <Vec> candidates, Vec bot)
        {
            var nears = bot.GetNears().ToHashSet();

            return(candidates
                   .GroupBy(cand => nears.Contains(cand))
                   .OrderByDescending(g => g.Key)
                   .SelectMany(g => g.OrderBy(p => keySelector(p, bot))));
        }
Пример #2
0
 public GotoVertex(DeluxeState state, Bot bot, Region region, Vec vertex)
     : base(state, bot, () => vertex
            .GetNears()
            .Where(v => v.IsInCuboid(state.R) &&
                   !v.IsInRegion(region) &&
                   !state.IsVolatile(bot, v))
            .OrderBy(v => state.Matrix[v])
            .ThenByDescending(v => v.Y)
            .ThenBy(v => v.MDistTo(bot.Position)))
 {
     this.vertex = vertex;
 }
 private IEnumerable <(Vec candidate, Vec nearPosition)> OrderCandidates(HashSet <Vec> candidates)
 {
     foreach (var candidate in candidatesOrdering.Order(candidates, bot.Position))
     {
         var nearPositions = candidate.GetNears().Where(n => n.IsInCuboid(state.Matrix.R));
         foreach (var nearPosition in nearPositions.OrderBy(p => p.MDistTo(bot.Position)))
         {
             if (oracle.CanFill(candidate, nearPosition))
             {
                 yield return(candidate, nearPosition);
             }
         }
     }
 }
        private IEnumerable <(Vec candidate, Vec nearPosition)> OrderCandidates(int index, HashSet <Vec> candidates)
        {
            var pos = bots[index].Position;

            foreach (var candidate in candidatesOrdering.Order(candidates, pos))
            {
                var nearPositions = candidate.GetNears().Where(n => n.IsInCuboid(R));
                foreach (var nearPosition in nearPositions.OrderBy(p => p.MDistTo(pos)))
                {
                    if (oracle.CanFill(candidate, nearPosition))
                    {
                        yield return(candidate, nearPosition);
                    }
                }
            }
        }
Пример #5
0
 private IEnumerable <(Vec candidate, Vec nearPosition)> OrderCandidates(int bot, HashSet <Vec> candidates)
 {
     foreach (var candidate in candidatesOrdering.Order(candidates, pos[bot]))
     {
         var nearPositions = candidate.GetNears().Where(n => n.IsInCuboid(R) && IsInBotRange(n, bot));
         foreach (var nearPosition in nearPositions.OrderBy(p => p.MDistTo(pos[bot])))
         {
             if (oracle.CanFill(candidate, nearPosition))
             {
                 A++;
                 yield return(candidate, nearPosition);
             }
             B++;
         }
     }
 }
Пример #6
0
        private IEnumerable <(Vec candidate, Vec nearPosition)> OrderCandidates()
        {
            var lowest   = candidates.Min(c => c.Y);
            var filtered = candidates.Where(c => c.Y == lowest).ToHashSet();

            foreach (var candidate in candidatesOrdering.Order(filtered, bot.Position).Where(c => !state.IsVolatile(bot, c)))
            {
                var nearPositions = candidate.GetNears().Where(n => n.IsInCuboid(state.Matrix.R) &&
                                                               (!state.IsVolatile(bot, n) || n == bot.Position) &&
                                                               n.Y >= lowest);
                foreach (var nearPosition in nearPositions.OrderBy(p => p.MDistTo(bot.Position)))
                {
                    yield return(candidate, nearPosition);
                }
            }
        }
Пример #7
0
        public IEnumerable <Vec> Order(HashSet <Vec> candidates, Vec bot)
        {
            var nears = bot.GetNears().ToHashSet();

            return(candidates.OrderBy(c => c.Y).ThenByDescending(c => nears.Contains(c)).ThenBy(c => c.MDistTo(bot)));
        }