Exemplo n.º 1
0
        public NextAction Next(Pac pac, CancellationToken cancellation)
        {
            NextAction nextAction = new NoAction(pac);

            var enemies = _gameGrid.VisibleEnemiesFrom(pac.Location).ToArray();

            if (enemies.Any())
            {
                nextAction = _enemyVisibleStrategy.Next(pac, cancellation, enemies);
                Console.Error.WriteLine($"Pac {pac.Id} has seen enemies. Next action {nextAction}");
            }

            if (!(nextAction is NoAction))
            {
                return(nextAction);
            }

            var pellets = _gameGrid.VisiblePelletsFrom(pac.Location);

            nextAction = _foodVisibleStrategy.Next(pac, cancellation, pellets.ToList());
            Console.Error.WriteLine($"Pac {pac.Id} food search. Next action {nextAction}. {(cancellation.IsCancellationRequested ? "CANCELLED" : string.Empty)}");
            return(nextAction);
        }
Exemplo n.º 2
0
        public NextAction Next(Pac pac, CancellationToken cancellation)
        {
            var pellets = _gameGrid.VisiblePelletsFrom(pac.Location);

            return(_pelletsSeenStrategy.Next(pac, cancellation, pellets.ToList()));
        }