コード例 #1
0
        public override void DeploySoldiers()
        {
            //GetOwnSoldiers();
            //This is the basis of my strategy evaluation
            //If the score is rising, the strategy works and Soldiers score
            //If not, I switch to my backup strategy
            //Evaluation starts after 100 turns because I have to create towers myself

            //Every 14 turns, check for progress in the score department
            if (TurnCounter.turnCounter % 14 == 0)
            {
                if (EvaluateScore.efficientOne)
                {
                    EvaluateScore.efficientOne = EvaluateScore.Scoring(player);
                }
                else
                {
                    EvaluateScore.efficientTwo = EvaluateScore.Scoring(player);
                }
            }

            //Every 10 turns set the current score as previous score
            if (TurnCounter.turnCounter % 10 == 0)
            {
                //Console.WriteLine(EvaluateScore.previousScore);
                EvaluateScore.previousScore = player.Score;
            }

            //---Strategy A--- Strategy versus non-wall using enemies
            //If there are no towers on the map, or my soldier score and no walls detected
            //Spawn waves of soldiers every 14 gold
            hurtMap.GenerateHurtMap();
            if (!hurtMap.DetectWalls(hurtMap.enemyTowerPositions) && !EvaluateScore.backUpStrategy)
            {
                if (hurtMap.ReturnWholeHurtMapValue(hurtMap.enemyTowerHurtMap) == 0 || EvaluateScore.efficientOne || EvaluateScore.efficientTwo)
                {
                    if (player.Gold > 14)
                    {
                        for (int i = 0; i < PlayerLane.WIDTH; i++)
                        {
                            Soldier soldier = this.player.BuySoldier(attackLane, i);
                        }
                    }
                }
            }
            //---Strategy B--- Strategy against enemies that use a (double) wall to pool money and spam soldiers at turn >900
            //If my first strategy is not succesful and my score does not increase
            //Pool money until turn 750, then use that money to diminish all the saved money of the enemy, destroy his base and win the game
            else
            {
                EvaluateScore.backUpStrategy = true;
                if (TurnCounter.turnCounter > 750)
                {
                    for (int i = 0; i < PlayerLane.WIDTH; i++)
                    {
                        Soldier soldier = this.player.BuySoldier(attackLane, i);
                    }
                }
            }
        }
コード例 #2
0
        public override void DeployTowers()
        {
            //Start my own TurnCounter
            TurnCounter.IncrementTurn();

            //Only want the efficient bools to be set once
            if (!setUpBools)
            {
                setUpBools = true;
                EvaluateScore.SetBools();
            }
            //Check for breached units = behind my first towerlane
            List <Unit> breachedUnits = new List <Unit>();

            for (int i = 0; i < PlayerLane.WIDTH; i++)
            {
                for (int k = 2; k < PlayerLane.HEIGHT; k++)
                {
                    Cell cell = defendLane.GetCellAt(i, k);
                    if (cell.Unit != null && cell.Unit.GetType() == typeof(Soldier))
                    {
                        breachedUnits.Add(cell.Unit);
                    }
                }
            }

            // If more than two lanes full of soldiers get through my initial defense
            // Consider my defense as breached and fall back to second defense line
            if (breachedUnits.Count >= 14)
            {
                defenseBreached = true;
            }

            //Generate a heatmap for later use
            hurtMap = new TowerHurtMap(attackLane);
            hurtMap.enemyTowerHurtMap = hurtMap.GenerateHurtMap();

            //Personally I think this is the best tower placement: Counters f.e. pooling soldiers out of range of my towers and engaging then
            //Therefore this is rather static
            if (!defenseBreached)
            {
                for (int i = 0; i < 3; i++)
                {
                    Tower tower = player.BuyTower(defendLane, i, 2);
                }
                for (int i = 4; i < 7; i++)
                {
                    Tower newTower = player.BuyTower(defendLane, i, 2);
                }
                for (int i = 1; i < 7; i += 2)
                {
                    Tower newerTower = player.BuyTower(defendLane, i, 3);
                }
            }
            else
            {
                for (int j = PlayerLane.HEIGHT - 2; j <= PlayerLane.HEIGHT; j++)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        Tower tower = player.BuyTower(defendLane, i, j);
                    }
                    for (int i = 6; i > 2; i--)
                    {
                        Tower newTower = player.BuyTower(defendLane, i, j);
                    }
                }
            }
        }