示例#1
0
        /// <summary>
        /// Use in decisioning about capturing hexa
        /// </summary>
        /// <param name="attacker">Player with fort (me)</param>
        /// <param name="hexa">Target hexa</param>
        /// <returns></returns>
        public static float GetFitness(IPlayer attacker, IHexa hexa)
        {
            if (map.GetPlayerOthers().Count == 0)
                return 0.0f;

            if (hexa.GetCapturedIPlayer() == attacker)
                return 0.0f;

            int enemySum = 0;
            int attackerSum = hexa.GetNormalProductivity(attacker);

            foreach (IPlayer player in map.GetPlayerOthers())
            {
                if (player == attacker)
                {
                    enemySum += hexa.GetNormalProductivity(map.GetPlayerMe());
                } else
                    enemySum += hexa.GetNormalProductivity(player);
            }

            if(hexa.GetCaptured() && hexa.GetCapturedIPlayer() != attacker)
            {
                return (enemySum + attackerSum) / 144.0f;
            }

            return (enemySum) / 144.0f;
        }
示例#2
0
        public double GetDesirablity(IPlayer attacker, IHexa hexa)
        {
            if (map.GetPlayerOthers().Count == 0)
                return 0.0f;

            if (hexa.GetCapturedIPlayer() == attacker)
                return 0.0f;

            int enemySum = 0;
            int attackerSum = hexa.GetNormalProductivity(attacker);

            foreach (IPlayer player in map.GetPlayerOthers())
            {
                if (player == attacker)
                {
                    enemySum += hexa.GetNormalProductivity(map.GetPlayerMe());
                }
                else
                    enemySum += hexa.GetNormalProductivity(player);
            }

            if (hexa.GetKind() == HexaKind.Mountains || hexa.GetKind() == HexaKind.Stone)
                enemySum = (int)(enemySum * 1.05);
            else if (hexa.GetKind() == HexaKind.Forest)
                enemySum = (int)(enemySum * 0.8);
            else if (hexa.GetKind() == HexaKind.Desert)
                return 0.0;

            if (hexa.GetCaptured() && hexa.GetCapturedIPlayer() != attacker)
            {
                return (enemySum + attackerSum) / 144.0f;
            }

            return (enemySum) / 144.0f;
        }