Example #1
0
 public ITurnAction GetTurnAction(
     IOwnBot ownBot,
     IReadOnlyCollection <IEnemy> enemies,
     IBattlefieldView battlefield)
 {
     return(TurnAction);
 }
Example #2
0
        public ITurnAction GetTurnAction(
            IOwnBot ownBot,
            IReadOnlyCollection <IEnemy> enemies,
            IBattlefieldView battlefield)
        {
            var enemy = enemies.FirstOrDefault();

            return(enemy != null?TurnAction.Attack(enemy) : TurnAction.Idle());
        }
Example #3
0
        private bool IsNotInCornerOrEdge(IBattlefieldView battlefield)
        {
            int ownBotPositionX = myOwnBot.Position.X;
            int ownBotPositionY = myOwnBot.Position.Y;

            return(battlefield.IsOutOfRange(ownBotPositionX + 1, ownBotPositionY) == false &&
                   battlefield.IsOutOfRange(ownBotPositionX - 1, ownBotPositionY) == false &&
                   battlefield.IsOutOfRange(ownBotPositionX, ownBotPositionY + 1) == false &&
                   battlefield.IsOutOfRange(ownBotPositionX, ownBotPositionY - 1) == false);
        }
Example #4
0
 public void TearDown()
 {
     myShield          = null;
     myHealth          = null;
     myEnergy          = null;
     myOwnBot          = null;
     myEnemyOne        = null;
     myBattleField     = null;
     enemiesCollection = null;
     sut = null;
 }
Example #5
0
 public void SetUp()
 {
     sut      = new MySuperHero();
     myShield = CreateAndSetupShield();
     SetShieldPercentageAndActualShieldPoints(100);
     myHealth   = CreateAndSetupHealth();
     myEnergy   = CreateAndSetupEnergy();
     myOwnBot   = CreateAndSetupOwnBot(OwnBotInitialPositionX, OwnBotInitialPositionY);
     myEnemyOne = CreateAndSetupEnemy(EnemyOneInitialPositionX, EnemyOneInitialPositionY);
     SetDistanceToEnemy(myEnemyOne);
     myBattleField     = new Mock <IBattlefieldView>().Object;
     enemiesCollection = new List <IEnemy> {
         myEnemyOne
     };
 }
Example #6
0
        public ITurnAction GetTurnAction(IOwnBot ownBot, IReadOnlyCollection <IEnemy> enemies, IBattlefieldView battlefield)
        {
            if (!enemies.Any())
            {
                return(TurnAction.Idle());
            }

            if (ownBot.Energy.Percent < 10)
            {
                return(TurnAction.Recharge.Battery());
            }

            var enemy = enemies.First();

            if (ownBot.Health.Percent < 50 && ownBot.Shield.Percent < 50)
            {
                if (ownBot.Energy.Actual > 110)
                {
                    return(TurnAction.Recharge.Shield(100));
                }
                return(TurnAction.Move.AwayFrom(enemy.Position));
            }

            if (ownBot.DistanceTo(enemy) < (double)Attack.MaxRange / 2)
            {
                return(TurnAction.Attack(enemy));
            }

            return(TurnAction.Move.Towards(enemy.Position));
        }
Example #7
0
 public ITurnAction GetTurnAction(
     IOwnBot ownBot, IReadOnlyCollection <IEnemy> enemies, IBattlefieldView battlefield)
 {
     throw new Exception();
 }
Example #8
0
 public ITurnAction GetTurnAction(IOwnBot ownBot, IReadOnlyCollection <IEnemy> enemies, IBattlefieldView battlefield)
 {
     Thread.Sleep(TimeSpan.FromSeconds(2));
     return(TurnAction.Idle());
 }
Example #9
0
        public ITurnAction GetTurnAction(IOwnBot ownBot, IReadOnlyCollection <IEnemy> enemies, IBattlefieldView battlefield)
        {
            if (myOwnBot == null)
            {
                myOwnBot = ownBot;
            }
            myClosestEnemy = FindClosestEnemy(enemies);
            ITurnAction turnAction;

            if (IsBatteryLow(BatteryLowPercentage) && NotUnderAttack())
            {
                UpdateCurrentShieldAndHealth();
                return(RechargeTheBattery());
            }
            if (IsInSafeDistanceFromEnemies(SafeDistanceFromEnemy))
            {
                if (BatteryNotFullEnough(BatteryNotFullPercentage))
                {
                    UpdateCurrentShieldAndHealth();
                    return(RechargeTheBattery());
                }
                if (ShieldNotFullEnough(ShieldNotFullPercentage))
                {
                    UpdateCurrentShieldAndHealth();
                    return(RechargeTheShieldToMaximumPossible(MinimumBatteryPercentage));
                }
            }
            if (IsShieldTooDamaged(ShieldDamagedPercentage) && HaveEnoughEnergyForFullShield(MinimumBatteryPercentage))
            {
                UpdateCurrentShieldAndHealth();
                return(RechargeTheShieldToMaximumPossible(MinimumBatteryPercentage));
            }
            if (IsUnderAttack() &&
                IsNotInCornerOrEdge(battlefield) &&
                (IsSeriouslyInjured(SeriouslyInjuredPercentage) || IsShieldSeriouslyDamaged()))
            {
                UpdateCurrentShieldAndHealth();
                return(RunAwayFromEnemy(myClosestEnemy));
            }
            if (IsCloseEnoughForAttackTheEnemy(myClosestEnemy))
            {
                turnAction = Attack(myClosestEnemy);
            }
            else
            {
                turnAction = MoveCloserToEnemy(myClosestEnemy);
            }
            UpdateCurrentShieldAndHealth();
            return(turnAction);
        }
Example #10
0
        public ITurnAction GetTurnAction(IOwnBot ownBot, IReadOnlyCollection <IEnemy> enemies, IBattlefieldView battlefield)
        {
            if (enemies.Any())
            {
                var enemy      = enemies.First();
                var ownPlace   = battlefield[ownBot];
                var enemyPlace = battlefield[enemy];
                return(ownPlace.DistanceTo(enemyPlace) > 3
                    ? TurnAction.Move.Towards(enemyPlace)
                    : TurnAction.Attack(enemy));
            }

            return(TurnAction.Idle());
        }