Ejemplo n.º 1
0
        void UpdateCityWeights()
        {
            bool allFullHealth = true;

            for (int i = 0; i < area.CityCount; i++)
            {
                City cc = area.GetCity(i);

                if (cc.HPRate < 1 - 0.01f)
                {
                    allFullHealth = false;
                    break;
                }
            }

            for (int i = 0; i < area.CityCount; i++)
            {
                City        cc = area.GetCity(i);
                CityWeights weight;

                if (!cityWeights.TryGetValue(cc, out weight))
                {
                    weight = new CityWeights();
                    cityWeights.Add(cc, weight);
                }

                int dindex = GetCityDangerIndex(cc);
                weight.OilBallRequirements  = dindex * (1 + cc.Type == CityType.Neutral ? 1 : 0);
                weight.OilBallRequirements += weight.BaseBias;

                int isNotViolence = (cc.Type != CityType.Volience ? 1 : 0);
                weight.BulletRequirements  = (1 - (isNotViolence * cc.Level) / 10.0f) * (isNotViolence * 0.5f + 0.5f) / dindex;
                weight.BulletRequirements += weight.BaseBias;

                weight.VirusRequirements  = allFullHealth ? (cc.Type == CityType.Disease ? 1 : 0) : (1 - cc.HPRate);
                weight.VirusRequirements += weight.BaseBias;
            }
        }
Ejemplo n.º 2
0
        void UpdateCityWeights()
        {
            bool allFullHealth = true;
            for (int i = 0; i < area.CityCount; i++)
            {
                City cc = area.GetCity(i);

                if (cc.HPRate < 1 - 0.01f)
                {
                    allFullHealth = false;
                    break;
                }
            }

            for (int i = 0; i < area.CityCount; i++)
            {
                City cc = area.GetCity(i);
                CityWeights weight;

                if (!cityWeights.TryGetValue(cc, out weight))
                {
                    weight = new CityWeights();
                    cityWeights.Add(cc, weight);
                }

                int dindex = GetCityDangerIndex(cc);
                weight.OilBallRequirements = dindex * (1 + cc.Type == CityType.Neutral ? 1 : 0);
                weight.OilBallRequirements += weight.BaseBias;

                int isNotViolence = (cc.Type != CityType.Volience ? 1 : 0);
                weight.BulletRequirements = (1 - (isNotViolence * cc.Level) / 10.0f) * (isNotViolence * 0.5f + 0.5f) / dindex;
                weight.BulletRequirements += weight.BaseBias;

                weight.VirusRequirements = allFullHealth ? (cc.Type == CityType.Disease ? 1 : 0) : (1 - cc.HPRate);
                weight.VirusRequirements += weight.BaseBias;
            }
        }