Exemplo n.º 1
0
        private Direction AvoidGhost(LinkedCell currentLocation,
                                     Distances shortestDistances, Direction bestDirectionToNearestCoin, BotGhost?nearestGhost)
        {
            if (nearestGhost is object)
            {
                var distanceToGhost = shortestDistances.DistanceTo(nearestGhost.Location);
                if (distanceToGhost < 5)
                {
                    var directionToScaryGhost = shortestDistances.DirectionToTarget(nearestGhost.Location);
                    if (directionToScaryGhost == bestDirectionToNearestCoin)
                    {
                        bestDirectionToNearestCoin = PickDifferentDirection(currentLocation, directionToScaryGhost);
                    }
                }
            }

            return(bestDirectionToNearestCoin);
        }