public float GetContactWeight(PolityContact contact)
    {
        if (contact.Polity is Tribe)
        {
            return(_sourceTribe.CalculateContactStrength(contact));
        }

        return(0);
    }
예제 #2
0
    public float CalculateChanceOfRejectingOffer()
    {
        float administrativeLoad = _targetTribe.CalculateAdministrativeLoad();

        if (float.IsPositiveInfinity(administrativeLoad))
        {
            return(1);
        }

        float numFactors = 0;

        float contactStrength = _targetTribe.CalculateContactStrength(_sourceTribe) * ContactStrengthFactor;

        numFactors++;

        float isolationPreferenceValue = _targetTribe.GetPreferenceValue(CulturalPreference.IsolationPreferenceId);

        numFactors++;

        float cohesionPreferenceValue = _targetTribe.GetPreferenceValue(CulturalPreference.CohesionPreferenceId);

        numFactors++;

        float relationshipValue = _targetTribe.GetRelationshipValue(_sourceTribe);

        numFactors++;

        float modIsolationPreferencValue = isolationPreferenceValue * 2;
        float modCohesionPreferenceValue = (cohesionPreferenceValue - 0.5f) * 2;
        float modRelationshipValue       = (relationshipValue - 0.5f) * 2;

        /// NOTE: Move administrative load stuff to a separate general function

        float authorityPreferenceValue = _targetTribe.GetPreferenceValue(CulturalPreference.AuthorityPreferenceId);

        float cohesionPrefFactor = 2 * cohesionPreferenceValue;

        cohesionPrefFactor = Mathf.Pow(cohesionPrefFactor, 4);

        float authorityPrefFactor = 2 * authorityPreferenceValue;

        authorityPrefFactor = Mathf.Pow(authorityPrefFactor, 4);

        Agent targetTribeLeader = _targetTribe.CurrentLeader;

        float modMinAdministrativeLoad = MinAdministrativeLoad * cohesionPrefFactor;
        float modMaxAdministrativeLoad = modMinAdministrativeLoad +
                                         (DeltaAdministrativeLoad * targetTribeLeader.Wisdom * targetTribeLeader.Charisma * authorityPrefFactor * MaxAdministrativeLoadChanceFactor);

        float administrativeLoadFactor = (administrativeLoad - modMinAdministrativeLoad) / (modMaxAdministrativeLoad - modMinAdministrativeLoad);

        numFactors++;

        /// End of NOTE relevant code

        float chance = 1 - ((1 - modIsolationPreferencValue) + modCohesionPreferenceValue + modRelationshipValue + contactStrength + (1 - administrativeLoadFactor)) / numFactors;

        return(Mathf.Clamp01(chance));
    }
    public float CalculateChanceOfRejectingOffer()
    {
        float numFactors = 0;

        float contactStrength = _targetTribe.CalculateContactStrength(_sourceTribe) * ContactStrengthFactor;

        numFactors++;

        float isolationPreferenceValue = _targetTribe.GetPreferenceValue(CulturalPreference.IsolationPreferenceId);

        numFactors++;

        float relationshipValue = _targetTribe.GetRelationshipValue(_sourceTribe);

        numFactors++;

        // average factors
        float chance = 1 - ((1 - isolationPreferenceValue) + (1 - relationshipValue) + contactStrength) / numFactors;

        return(Mathf.Clamp01(chance));
    }