コード例 #1
0
ファイル: MyBot.cs プロジェクト: simonduf/AntsExperiments
        public void Attack(GameState state, int[,] EnemyDist, Ant ant)
        {
            var best = Ants.Aim.Keys.Select(dir => new { dir, loc = state.GetDestination(ant, dir) })
                       .Where(x => !state.OccupiedNextRound.At(x.loc))
                       .Where(x => state.GetIsPassable(x.loc))
                       .OrderByDescending(x => EnemyDist.At(x.loc))
                       //.ThenBy(state.GetBestDirection(x.loc, loc) //Prioritize by direction, need to have a goal...
                       .LastOrDefault();

            if (best == null)
            {
                return;//TODO wals around obstacle here??
            }
            if (EnemyDist.At(best.loc) <= EnemyDist.At(ant))
            {
                Bot.IssueOrder(state, ant, best.dir, "Attack" + battleId);
            }


            //foreach (Direction direction in Ants.Aim.Keys)
            //{
            //    Location newLoc = state.GetDestination(ant, direction);
            //   //Todo sort best result;
            //    if (state.GetIsPassable(newLoc) && !state.OccupiedNextRound.At(newLoc) && EnemyDist.At(newLoc) > EnemyDist.At(ant))
            //    {
            //        Bot.IssueOrder(state, ant, direction);
            //        break;
            //    }
            //}
        }
コード例 #2
0
ファイル: MyBot.cs プロジェクト: simonduf/AntsExperiments
        public void Retreat(GameState state, int[,] EnemyDist, Ant ant)
        {
            var best = Ants.Aim.Keys.Select(dir => new { dir, loc = state.GetDestination(ant, dir) })
                       .Where(x => !state.OccupiedNextRound.At(x.loc))
                       .Where(x => state.GetIsPassable(x.loc))
                       .OrderBy(x => EnemyDist.At(x.loc))
                       .LastOrDefault();

            if (best == null)
            {
                return;
            }

            if (EnemyDist.At(best.loc) >= EnemyDist.At(ant))
            {
                Bot.IssueOrder(state, ant, best.dir, "Retreat" + battleId);
            }


            //foreach (Direction direction in Ants.Aim.Keys)
            //{
            //    Location newLoc = state.GetDestination(ant, direction);
            //   //Todo sort best result;
            //    if (state.GetIsPassable(newLoc) && !state.OccupiedNextRound.At(newLoc) && EnemyDist.At(newLoc) > EnemyDist.At(ant))
            //    {
            //        Bot.IssueOrder(state, ant, direction);
            //        break;
            //    }
            //}
        }