[TestCase(0.05f, 0.06f, 0.08f, 0.1f, 0.05f, 0.1f)]    // 4 near-failures
        public void GetRatingForId_ImplementsInversePowerReduction(
            float one, float two, float three, float four,    // condition ratings
            float minBound, float maxBound)                   // expected boundaries
        {
            const int dataId = 3;
            var       rwo    = m_GameObject.AddComponent <Proxy>();

            m_GameObject.AddTestFloatCondition();
            m_GameObject.AddTestFloatCondition();
            m_GameObject.AddTestVector2Condition();
            m_GameObject.AddSemanticTagCondition();

            var conditions = ProxyConditions.FromGenericIMRObject(rwo);
            var proposal   = new ConditionRatingsData(conditions);

            proposal[typeof(float)][0].Add(dataId, one);
            proposal[typeof(float)][1].Add(dataId, two);
            proposal[typeof(Vector2)][0].Add(dataId, three);
            proposal[typeof(bool)][0].Add(dataId, four);
            AssertBetween(proposal.RatingForId(dataId), minBound, maxBound);
        }
Esempio n. 2
0
        internal static void Execute(ConditionRatingsData rawRatings,
                                     HashSet <int> matchSet, Dictionary <int, float> flatRatings)
        {
            s_Counter = 0;
            foreach (var dataId in matchSet)
            {
                s_RatingPairBuffer[s_Counter] = new KeyValuePair <int, float>(dataId, rawRatings.RatingForId(dataId));
                s_Counter++;
            }

            // later stages will assume that the dictionary of ratings is sorted by value, so we sort here.
            // this call will only sort the members of the array up to s_Counter, because we're only using those.
            Array.Sort(s_RatingPairBuffer, 0, s_Counter, k_Comparer);

            flatRatings.Clear();
            for (var i = 0; i < s_Counter; i++)
            {
                var kvp = s_RatingPairBuffer[i];
                flatRatings.Add(kvp.Key, kvp.Value);
            }
        }