private float GetElfScore(VirtualGame virtualGame, FutureLocation elfFutureLocation)
        {
            IceTroll[] enemyIceTrolls = Constants.GameCaching.GetEnemyIceTrolls();

            float score = 0;

            foreach (IceTroll enemyIceTroll in enemyIceTrolls)
            {
                if (enemyIceTroll.CurrentHealth == 1)
                {
                    continue;
                }

                float distance             = elfFutureLocation.GetFutureLocation().DistanceF(enemyIceTroll);
                float avoidRadiusFromTroll = avoidRadius;
                if (elfFutureLocation.GetElf().CurrentHealth < whatIsNotMuchHealth)
                {
                    avoidRadiusFromTroll += addMoreElfMaxStepsToAvoidRadiusWhenElfHasNotMuchHealth;
                }

                avoidRadiusFromTroll = Mathf.Min(avoidRadiusFromTroll, enemyIceTroll.CurrentHealth * enemyIceTroll.MaxSpeed + enemyIceTroll.AttackRange);

                if (distance < avoidRadiusFromTroll)
                {
                    score -= avoidRadiusFromTroll - distance;
                }
            }

            return(score);
        }
Beispiel #2
0
        private float GetScore(Dictionary <int, FutureLocation> myFutureElfLocations, Dictionary <int, GameObject> enemyGameObjects)
        {
            float score = 0;

            while (myFutureElfLocations.Count > 0 && enemyGameObjects.Count > 0)
            {
                float bestScore = 0;
                bool  iterated  = false;

                int myElfUniqueId           = -1;
                int enemyGameObjectUniqueId = -1;

                foreach (KeyValuePair <int, FutureLocation> myFutureElfLocation in myFutureElfLocations)
                {
                    FutureLocation elfFutureLocation = myFutureElfLocation.Value;
                    foreach (KeyValuePair <int, GameObject> enemyGameObjectPair in enemyGameObjects)
                    {
                        float tempScore = GetPairScore(enemyGameObjectPair, elfFutureLocation.GetFutureLocation());
                        foreach (Spell spell in elfFutureLocation.GetElf().CurrentSpells)
                        {
                            if (spell is SpeedUp)
                            {
                                tempScore = tempScore * GetSpeedUpMultiplier();
                                break;
                            }
                        }
                        if (!iterated || tempScore > bestScore)
                        {
                            iterated  = true;
                            bestScore = tempScore;

                            myElfUniqueId           = myFutureElfLocation.Key;
                            enemyGameObjectUniqueId = enemyGameObjectPair.Key;
                        }
                    }
                }

                myFutureElfLocations.Remove(myElfUniqueId);
                enemyGameObjects.Remove(enemyGameObjectUniqueId);

                score += bestScore;
            }

            return(score);
        }
        private float GetElfScore(FutureLocation elfFutureLocation)
        {
            Location curLocation    = elfFutureLocation.GetElf().GetLocation();
            Location futureLocation = elfFutureLocation.GetFutureLocation();

            if (curLocation.Row == futureLocation.Row && curLocation.Col == futureLocation.Col)
            {
                return(0);
            }
            if (!Constants.Game.CanBuildPortalAt(curLocation))
            {
                return(0);
            }
            if (Constants.GameCaching.GetMyManaFountainsInArea(new Circle(curLocation, maxDistFromMyManaFountain)).Count == 0)
            {
                return(0);
            }

            return(-1);
        }