Esempio n. 1
0
        protected static float Eps(IVRiscuitObject a, IVRiscuitObject b, IVRiscuitObject x, IVRiscuitObject y, ScoreCoefficient ef)
        {
            var ab = Norm(a, b);
            var xy = Norm(x, y);

            if (ab == 0)
            {
                return(0);
            }
            var result = (float)(1 - Math.Exp(-ef.EpsWeight1 / Math.Pow(ab /*+ xy*/ + ef.EpsWeight2, 2)));

#if UNITY_EDITOR
            // Debug.Log(String.Format("Eps({0}, {1}, {2}, {3}) = {4}", a.Type, b.Type, x.Type, y.Type, result));
#endif
            return(result);
        }
Esempio n. 2
0
        protected static float[] CalcTwoObjectSimilarityparameters(IVRiscuitObject a, IVRiscuitObject b, IVRiscuitObject x, IVRiscuitObject y, ScoreCoefficient ef)
        {
            var eps   = Eps(a, b, x, y, ef);
            var max   = ef.NormWeight + eps * (ef.RdirWeight1 + ef.RdirWeight2) + ef.AngleWeight;
            var score = new float[] {
                ef.NormWeight *Delta(Norm(a, b), Norm(x, y), ef.NormLeveling),
                ef.RdirWeight1 *eps *Delta(Rdir(a, b), Rdir(x, y), ef.RdirLeveling1),
                ef.RdirWeight2 *eps *Delta(Rdir(b, a), Rdir(y, x), ef.RdirLeveling2),
                ef.AngleWeight *Delta3(Angle(a, b), Angle(x, y), ef.AngleLeveling),
                max
            };

            return(score);
        }
Esempio n. 3
0
        /// <summary>
        /// Rule上のオブジェクトとフィールドのオブジェクトがどれだけ近い関係にあるかを計算
        /// </summary>
        /// <param name="ruleObjectSet"></param>
        /// <param name="fieldObjectSet"></param>
        /// <param name="ef"></param>
        /// <returns></returns>
        public static float[] CalcScore(IVRiscuitObjectSet ruleObjectSet, IVRiscuitObjectSet fieldObjectSet, ScoreCoefficient ef)
        {
            var score           = 0.0f;
            var max             = 0.0f;
            var ruleObjectList  = ruleObjectSet.ObjectArray;
            var fieldObjectList = fieldObjectSet.ObjectArray;
            var len             = fieldObjectList.Length;

            if (len == 1)
            {
                return(new float[] { 10, 10 });
            }
            for (int i = 0; i < len - 1; i++)
            {
                for (int j = i + 1; j < len; j++)
                {
                    var fs = CalcTwoObjectSimilarity(ruleObjectList[i], ruleObjectList[j],
                                                     fieldObjectList[i], fieldObjectList[j], ef);
                    score += fs[0];
                    max   += fs[1];
                }
            }
            return(new float[] { score, max });
        }
Esempio n. 4
0
        /// <summary>
        /// a,bは必ずルール内のオブジェクトなので、ルール中は不変
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="ef"></param>
        /// <returns></returns>
        public static float[] CalcTwoObjectSimilarity(IVRiscuitObject a, IVRiscuitObject b, IVRiscuitObject x, IVRiscuitObject y, ScoreCoefficient ef)
        {
            var fs    = CalcTwoObjectSimilarityparameters(a, b, x, y, ef);
            var score = fs[0] + fs[1] + fs[2] + fs[3];

            return(new float[2] {
                score, fs[4]
            });
        }
Esempio n. 5
0
        public static float[] CalcAppliedFieldScore(IVRiscuitObjectSet currentField, IVRiscuitObjectSet beforeField, IVRiscuitObjectSet afterRuleSet, IVRiscuitObjectSet beforeRuleSet, ScoreCoefficient ef)
        {
            var score = 0.0f;
            var max   = 0.0f;
            var beforeRuleSetArray = beforeRuleSet.ObjectArray;
            var afterRuleSetArray  = afterRuleSet.ObjectArray;
            var beforeFieldArray   = beforeField.ObjectArray;
            var currentFieldArray  = currentField.ObjectArray;
            var currentSize        = currentField.Size;
            var beforeSize         = beforeField.Size;

            for (int a = 0; a < currentSize; a++)
            {
                for (int b = 0; b < beforeSize; b++)
                {
                    var f = CalcTwoObjectSimilarity(beforeRuleSetArray[b], afterRuleSetArray[a], beforeFieldArray[b], currentFieldArray[a], ef);
                    score += f[0];
                    max   += f[1];
                }
            }
            var cc = CalcScore(afterRuleSet, currentField, ef);

            score += cc[0];
            max   += cc[1];
            return(new float[] { score, max });
        }