예제 #1
0
    public float CalculateChanceOfMakingAttempt()
    {
        float administrativeLoad = _sourceTribe.CalculateAdministrativeLoad();

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

        float numFactors = 0;

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

        numFactors++;

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

        numFactors++;

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

        numFactors++;

        float relationshipValue = _sourceTribe.GetRelationshipValue(_targetTribe);

        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 sourceTribeLeader = _sourceTribe.CurrentLeader;

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

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

        numFactors++;

        /// End of NOTE relevant code

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

        return(Mathf.Clamp01(chance));
    }
예제 #2
0
    public static long CalculateTriggerDate(Tribe tribe)
    {
        float randomFactor = tribe.GetNextLocalRandomFloat(RngOffsets.MERGE_TRIBES_EVENT_CALCULATE_TRIGGER_DATE);

        randomFactor = Mathf.Pow(randomFactor, 2);

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

        float isolationPrefFactor = 2 * isolationPreferenceValue;

        isolationPrefFactor = Mathf.Pow(isolationPrefFactor, 4);

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

        float cohesionPrefFactor = 2 * (1 - cohesionPreferenceValue);

        cohesionPrefFactor = Mathf.Pow(cohesionPrefFactor, 4);

        float dateSpan = (1 - randomFactor) * DateSpanFactorConstant * isolationPrefFactor * cohesionPrefFactor;

        long triggerDateSpan = (long)dateSpan + CellGroup.GenerationSpan;

        if (triggerDateSpan < 0)
        {
            Debug.LogWarning("updateSpan less than 0: " + triggerDateSpan);

            triggerDateSpan = CellGroup.MaxUpdateSpan;
        }

        long triggerDate = tribe.World.CurrentDate + triggerDateSpan;

        if (triggerDate > World.MaxSupportedDate)
        {
            // nextDate is invalid, generate report
            Debug.LogWarning(
                "MergeTribesDecisionEvent.CalculateTriggerDate - triggerDate (" + triggerDate +
                ") greater than MaxSupportedDate (" + World.MaxSupportedDate +
                "). triggerDateSpan: " + triggerDateSpan + ", randomFactor: " + randomFactor +
                ", cohesionPrefFactor: " + cohesionPrefFactor);

            triggerDate = int.MinValue;
        }

        return(triggerDate);
    }
    public float CalculateChanceOfSplittingForTribe()
    {
        float administrativeLoad = _dominantClan.CalculateAdministrativeLoad();

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

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

        if (cohesionPreferenceValue <= 0)
        {
            return(1);
        }

        float cohesionPrefFactor = 2 * cohesionPreferenceValue;

        cohesionPrefFactor = Mathf.Pow(cohesionPrefFactor, 4);

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

        if (authorityPreferenceValue <= 0)
        {
            return(1);
        }

        float authorityPrefFactor = 2 * authorityPreferenceValue;

        authorityPrefFactor = Mathf.Pow(authorityPrefFactor, 4);

        float relationshipFactor = 2 * _dominantClan.GetRelationshipValue(_splitClan);

        relationshipFactor = Mathf.Pow(relationshipFactor, 4);

        float diffLimitsAdministrativeLoad = TribeMaxAdministrativeLoad - TribeMinAdministrativeLoad;

        float modMinAdministrativeLoad = TribeMinAdministrativeLoad * cohesionPrefFactor * relationshipFactor;
        float modMaxAdministrativeLoad = modMinAdministrativeLoad +
                                         (diffLimitsAdministrativeLoad * _dominantClan.CurrentLeader.Wisdom * _dominantClan.CurrentLeader.Charisma * authorityPrefFactor * MaxAdministrativeLoadChanceFactor);

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

        return(Mathf.Clamp01(chance));
    }
예제 #4
0
    public float CalculateChanceOfMakingAttempt()
    {
        float numFactors = 0;

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

        numFactors++;

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

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

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

        numFactors++;

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

        numFactors++;

        float relationshipValue = _sourceTribe.GetRelationshipValue(_targetTribe);

        numFactors++;

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

        return(Mathf.Clamp01(chance));
    }