private float GetSpeedUpScore(VirtualSpeedUp futureSpeedUp)
        {
            //i will place comment near each line which will specify what condition I believe it checks for:
            //check me if i am wrong

            //- Our elf will get with in at most 5 steps to attack range.
            List <ManaFountain> manaFountainsInRange = Constants.GameCaching.GetEnemyManaFountainsInArea(new Circle(futureSpeedUp.location, Constants.Game.ElfMaxSpeed * 5 - Constants.Game.ElfAttackRange - Constants.Game.ManaFountainSize));

            //- There is only one mana fountain (otherwise we should probably find a way to send a tornado)
            if (manaFountainsInRange.Count > 1)
            {
                return(0);
            }

            //first we iterate over every manaFountain in range

            foreach (ManaFountain manaFountain in manaFountainsInRange)
            {
                //- The elf for sure will not get hit before it reach to the mana fountain.
                //- There are no existing ice trolls that will reach him when he will get to the mana fountain.
                if (CanForSureSafelyReachManaFountain((Elf)futureSpeedUp.realGameObject, manaFountain))
                {
                    //- The enemy elf will not get to our elf before it destroy the mana fountain (like Nahalal 4 does, you should also notice if the enemy elf is currently summoning).
                    if (!WillEnemyElfKillUsBeforeWeDestroy((Elf)futureSpeedUp.realGameObject, manaFountain))
                    {
                        return(50); //this, times the weight we would give the heuristic, is a 'very high score'
                    }
                }
            }

            return(0);
        }
Esempio n. 2
0
 private float GetElfScore(VirtualGame virtualGame, VirtualSpeedUp virtualSpeedUp)
 {
     return(Constants.GameCaching.GetEnemyIceTrollsInArea(new Circle(virtualSpeedUp.location, Constants.Game.IceTrollAttackRange)).Count);
 }
Esempio n. 3
0
        private float GetVirtualSpeedUpScore(VirtualSpeedUp virtualSpeed)
        {
            Elf        myElf      = (Elf)virtualSpeed.creator;
            List <Elf> enemyElves = Constants.GameCaching.GetEnemyElvesInArea(new Circle(myElf.GetLocation(), radius));

            if (enemyElves.Count == 0)
            {
                return(0);                       //if there are no enemy elves, return 0
            }
            Dictionary <int, GameObject> myElves = new Dictionary <int, GameObject>();

            float enemyCombinedHealth = 0;

            foreach (Elf enemyElf in enemyElves)
            {
                if (enemyElf.InAttackRange(myElf))
                {
                    return(0);
                }
                else
                {
                    enemyCombinedHealth += enemyElf.CurrentHealth;

                    foreach (Elf elf in Constants.GameCaching.GetMyElvesInArea(new Circle(enemyElf.GetLocation(), radius)))
                    {
                        myElves[elf.UniqueId] = elf;
                    }
                }
            }

            float ourCombinedHealth = myElf.CurrentHealth;

            //add all combined health of our elves
            foreach (KeyValuePair <int, GameObject> pair in myElves)
            {
                if (myElf.UniqueId == pair.Key)
                {
                    continue;
                }
                ourCombinedHealth += pair.Value.CurrentHealth;
            }

            //if we are weaker than the enemy
            if (ourCombinedHealth < enemyCombinedHealth)
            {
                return(0);
            }
            //if we are equal in power to the enemy
            else if (ourCombinedHealth == enemyCombinedHealth)
            {
                //go through each enemy elf
                foreach (GameObject enemyElf in enemyElves)
                {
                    //if the enemy elf is on our castle side
                    if (enemyElf.OnSameSideAsCastle()) //if enemy elf is our side of the map
                    {
                        return(1);
                    }
                }

                //if we didn't find any elves on our castle side, return 0
                return(0);
            }

            return(ourCombinedHealth / enemyCombinedHealth);
        }