Exemplo n.º 1
0
        private Pos FindNearestBar(GameState state)
        {
            //Trouver le bar le plus proche
            Pos nearestBar = new Pos(0, 0);
            int nbMoves    = 1000000000;

            foreach (var bar in _bars)
            {
                var pathToBar = _pathFinder.ShortestPath(state.myHero.pos, bar);
                int pathCost  = PathCost(state, pathToBar);
                if (pathCost < nbMoves)
                {
                    nbMoves    = pathCost;
                    nearestBar = bar;
                }
            }

            return(nearestBar);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This will be run on each turns. It must return a direction fot the bot to follow
        /// </summary>
        /// <param name="state">The game state</param>
        /// <returns></returns>
        public string Move(GameState state)
        {
            var pathfinder = new Pathfinder(state.board);
            var mines      = new List <Pos> ();

            for (int x = 0; x < state.board.Length; x++)
            {
                for (int y = 0; y < state.board [x].Length; y++)
                {
                    if (state.board [x] [y] == Tile.GOLD_MINE_NEUTRAL)
                    {
                        mines.Add(new Pos(x, y));
                    }
                }
            }
            var closest = mines.OrderBy(mine => pathfinder.ShortestPath(state.myHero.pos, mine).Count).First();

            string direction = pathfinder.NavigateTowards(state.myHero.pos, closest);

            Console.WriteLine("Completed turn {0}, going {1}", state.currentTurn, direction);
            return(direction);
        }