예제 #1
0
        private Pos TryCompleteCommand(GameState state)
        {
            Pos customerPosition = null;

            state.customers.Sort((Customer c1, Customer c2) => GetTilePosOnMap.DistanceBetweenPos(state.myHero.pos, GetTilePosOnMap.GetClosestTile(state.board, state.myHero.pos, new Tile[] { _customers[c1.id - 1] })).CompareTo(GetTilePosOnMap.DistanceBetweenPos(state.myHero.pos, GetTilePosOnMap.GetClosestTile(state.board, state.myHero.pos, new Tile[] { _customers[c2.id - 1] }))));

            for (int i = 0; i < state.customers.Count; ++i)
            {
                if (state.customers[i].burger <= state.myHero.burgerCount && state.customers[i].frenchFries <= state.myHero.frenchFriesCount)
                {
                    return(GetTilePosOnMap.GetClosestTile(state.board, state.myHero.pos, new Tile[] { _customers[state.customers[i].id - 1] }));
                }
            }
            return(customerPosition);
        }
예제 #2
0
        public override string Move(GameState state)
        {
            int burgerRequirements = 0;
            int fryRequirements    = 0;

            state.customers.ForEach(c => {
                burgerRequirements += c.burger;
                fryRequirements    += c.frenchFries;
            });

            if (burgerRequirements != 0 && fryRequirements == 0)
            {
                _tilesToSearch = _burgerTiles[state.myHero.id - 1];
            }
            else if (fryRequirements != 0 && burgerRequirements == 0)
            {
                _tilesToSearch = _fryTiles[state.myHero.id - 1];
            }
            else
            {
                _tilesToSearch = _allTiles[state.myHero.id - 1];
            }


            if (_target == null)
            {
                _target = GetTilePosOnMap.GetClosestTile(state.board, state.myHero.pos, _tilesToSearch);
            }
            else
            {
                Pos position = TryCompleteCommand(state);
                if (position != null)
                {
                    _target = position;
                }
                else
                {
                    _target = GetTilePosOnMap.GetClosestTile(state.board, state.myHero.pos, _tilesToSearch);
                }
            }

            _lastBurgerCount = state.myHero.burgerCount;
            _lastFriesCount  = state.myHero.frenchFriesCount;

            LastDir = api.GetDirection(state.myHero.pos, _target);
            return(LastDir);
        }