Example #1
0
            /// <summary>
            /// Register a ticker service to use in BotHandlerService
            /// </summary>
            public Builder RegisterBotStrategy(IBotStrategy botStrategy)
            {
                Preconditions.CheckNotNull(botStrategy);

                _botHandlerService._botStrategies.Add(botStrategy);
                return(this);
            }
Example #2
0
        public void ExchangeRateObserver_Update_DoesNotUpdateBotCommandStrategy(string observerTestBotCommand)
        {
            // Arrange
            IBotStrategy expectedBotCommandStrategy = null;

            // Initialize test CommandStrategy for ExchangeRateObserver
            var testExchangeRateCommand = new ObserverTestCommand
            {
                CommandType = CommandType.ExchangeRate
            };

            IEnumerable <ICommand> commands = new List <ICommand>()
            {
                testExchangeRateCommand
            };
            var commandStrategy = new BotStrategy(commands);

            // Initialize the test bot
            var exchangeRateObserver = new ExchangeRateObserver(commandStrategy);
            var testBot = new ObserverTestBot(observerTestBotCommand, exchangeRateObserver);

            // Act
            testBot.Run();
            var actualBotCommandStrategy = testBot.Strategy;

            //Assert
            Assert.AreEqual(actualBotCommandStrategy, expectedBotCommandStrategy);
        }
Example #3
0
        public string SetStrategy(IBotStrategy strategy)
        {
            if (strategy == null)
            {
                throw new ArgumentNullException("Stratege can't be null");
            }

            _strategy = strategy;

            return($"{_strategyChangingMsg} {_strategy.Name}");
        }
        public BotController(Player player, ITaskEngine taskEngine, IBotStrategy strategy)
        {
            m_log = Dependencies.Logger;

            m_state = new State();

            m_strategy       = strategy;
            m_strategy.State = m_state;

            m_taskEngine = taskEngine;
            m_playerView = m_taskEngine.MatchEngine.GetPlayerView(player.Id);
        }
Example #5
0
        public Bot(teleAbility kind, autoAbility autoKind, Alliance side)
        {
            canShoot = kind.HasFlag(teleAbility.shoot);
            canClimb = kind.HasFlag(teleAbility.climb);
            canBreach = kind.HasFlag(teleAbility.breach);

            canAuto = autoKind;
            hasBall = true; //let each robot start with a ball
            mode = botMode.none;

            strategy = new BotStrategy(this);
            //strategy = new BotAllen(this);

            location.current = fieldLocation.places.neutral;
            destination = fieldLocation.places.not_set;
            distancetogo = 0;
            team = side;
            maxSpeed = 5.0; //default to 5 fps
        }
Example #6
0
 public ShowCurrListUAObserver(IBotStrategy commandStrategy)
 {
     _commandStrategy = commandStrategy;
     _commandName     = $"/{ nameof(CommandType.ShowCurrListUA).ToUpper() }";
 }
 public static IBotController CreateBotController(Player player, ITaskEngine taskEngine, IBotStrategy strategy)
 {
     return(new BotController(player, taskEngine, strategy));
 }
Example #8
0
 public Computer(IBotStrategy strategy, Figure figure) : base(figure)
 {
     PlayStrategy = strategy;
 }
 public ExchangeRateObserver(IBotStrategy commandStrategy)
 {
     _commandStrategy = commandStrategy;
     _commandName     = $"/{ nameof(CommandType.ExchangeRate).ToUpper() }";
 }
Example #10
0
 public NowObserver(IBotStrategy commandStrategy)
 {
     _commandStrategy = commandStrategy;
     _commandName     = $"/{ nameof(CommandType.Now).ToUpper() }";
 }
Example #11
0
 public StartObserver(IBotStrategy commandStrategy)
 {
     _commandStrategy = commandStrategy;
     _commandName     = $"/{ nameof(CommandType.Start).ToUpper() }";
 }
        private IBotStrategy ChooseStrategy()
        {
            bool wasDominating = IsDominating;

            foreach (var item in WishList.ToList())
            {
                if (item.Value < 1)
                {
                    WishList.Remove(item.Key);
                }
                else
                {
                    WishList[item.Key] = item.Value - 1;
                }
            }
            InitialTotalFleetSize     = TotalFleetCount;
            InitialFleetToPlanetRatio = (InitialTotalFleetSize - 200) / (double)(All.Planets.Count - 2);
            Difficulty = (InitialFleetToPlanetRatio - 30) / 5;

            EarlyOrLateStageBias = Math.Max(0, 4 - (Universe.TurnCount + 1) / 10.0);
            if (TurnCount > 20 && Me.Planets.Count > 4)
            {
                int    dominatorCounter    = 0;
                double totalShipPercentile = Me.TotalShipCount / (double)(Enemy.TotalShipCount + 1);
                if (totalShipPercentile > 1.5)
                {
                    dominatorCounter++;
                }

                double totalPlanetPercentile = Me.Planets.Count / (double)(Enemy.Planets.Count + 1);
                if (totalPlanetPercentile > 1.5)
                {
                    dominatorCounter++;
                }

                double totalShipGrowthPercentile = Me.ShipGrowth / (double)(Enemy.ShipGrowth + 1);
                if (totalShipGrowthPercentile > 1.25)
                {
                    dominatorCounter++;
                }
                if (totalShipGrowthPercentile > 2.0)
                {
                    dominatorCounter++;
                }

                double totalShipInBasePercentile = Me.ShipCountInBase / (double)(Enemy.ShipCountInBase + 1);
                if (totalShipInBasePercentile > 1.5)
                {
                    dominatorCounter++;
                }

                double totalAirSuperiority = Me.ShipCountInBase / (double)(Enemy.ShipCountInTransit + 1);
                if (totalAirSuperiority < 0.8)
                {
                    dominatorCounter--;
                }

                IsDominating = dominatorCounter > 2;
            }

            switch (Universe.TurnCount)
            {
            case 0: break;

            case 1: _Strategy = new Strategy_LastTry();
                break;

            case 2: _Strategy = new Strategy_LastTry();
                break;

            case 15:
                _Strategy = new Strategy_LastTry();
                break;

            default:
                if (!IsDominating && (IsDominating != wasDominating))
                {
                    _Strategy = new Strategy_LastTry();
                }
                if (IsDominating && (IsDominating != wasDominating))
                {
                    _Strategy = new Strategy_LastTry();
                }
                break;
            }
            return(_Strategy);
        }
Example #13
0
 public MatchService(IBotStrategy botStrategy)
 {
     strategy = botStrategy;
 }