Esempio n. 1
0
        public Maybe <Direction> Decide(Level level)
        {
            var direction = _another.Decide(level);

            if (direction.Any())
            {
                return(direction);
            }

            return(level.MyLength > 40 ? Maybe.Empty <Direction>() : MoveToCenter(level));
        }
Esempio n. 2
0
        public Maybe <Direction> Decide(Level level)
        {
            _level = level;

            var direction = _another.Decide(level);

            if (direction.Any())
            {
                return(IsTie(MyPointAfterMove(direction.Single())) ? SafeMove() : direction);
            }

            return(SafeMove());
        }
Esempio n. 3
0
        public Maybe <Direction> Decide(Level level)
        {
            var direction = _another.Decide(level);

            if (direction.Any())
            {
                return(direction);
            }

            if (!level.MyShortestPath.Any() || (!level.MyShortestPath.Any() && !level.EnemyShortestPath.Any()))
            {
                return(Maybe.Empty <Direction>());
            }

            if (level.MyLength < 40)
            {
                return(level.EnemyShortestPath.Count < level.MyShortestPath.Count ? Maybe.Empty <Direction>() : DecideDirection(level.MyHead, level.MyShortestPath.First()));
            }

            return(DecideDirection(level.MyHead, level.MyShortestPath.First()));
        }
Esempio n. 4
0
        private void DecideMove()
        {
            if (!_hasPositions)
            {
                return;
            }

            Timekeep.Start();

            if (_hasApple)
            {
                FindPaths();
            }

            var direction = _decider.Decide(_level);

            if (direction.Any())
            {
                _communicator.Send(new ControlMessage(direction.Single()));
            }

            Timekeep.Stop(10);
        }