Esempio n. 1
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)
        {
            _pathFinder.UpdateBoard(state.board);
            UpdateMines(state);

            var nearestBar       = FindNearestBar(state);
            var nearestOtherMine = FindNearestOtherMine(state);
            var nearestHero      = FindNearestHero(state);

            if (IsMyLifeAtRisk(state, nearestOtherMine, nearestBar) && state.myHero.gold >= COST_OF_BEER)
            {
                return(_pathFinder.NavigateTowards(state.myHero.pos, nearestBar));
            }

            if (IsBarInMyRange(state) && state.myHero.life < (MAX_LIFE - 10) && state.myHero.gold >= COST_OF_BEER)
            {
                return(_pathFinder.NavigateTowards(state.myHero.pos, nearestBar));
            }

            if (nearestHero.mineCount >= 3 && nearestHero.life + DEFENSE_LIFE_COST < state.myHero.life)
            {
                return(_pathFinder.NavigateTowards(state.myHero.pos, nearestHero.pos));
            }

            if (_otherMines.Count == 0)
            {
                return(_pathFinder.NavigateTowards(state.myHero.pos, nearestBar));
            }

            return(_pathFinder.NavigateTowards(state.myHero.pos, nearestOtherMine));
        }
Esempio 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);
        }