예제 #1
0
        protected override int GetCachedScore(DualSimScoringParameters parameters, ICollection <Scoring.IScoring <SimDescription, DualSimScoringParameters> > scoring)
        {
            Dictionary <ulong, Dictionary <ulong, int> > scores = null;

            if (Cachable)
            {
                if (parameters.IsAbsolute)
                {
                    scores = mAbsoluteScores;
                }
                else
                {
                    scores = mFactorScores;
                }
            }
            else
            {
                ScoringLookup.IncStat(ToString() + " Not Cachable");
            }

            Dictionary <ulong, int> targets = null;

            // Intentionally allow null Actors to bounce the scoring, so we can track the error
            if ((scores != null) /*&& (parameters.Actor != null)*/)
            {
                if (!scores.TryGetValue(parameters.Actor.SimDescriptionId, out targets))
                {
                    targets = new Dictionary <ulong, int>();
                    scores.Add(parameters.Actor.SimDescriptionId, targets);
                }
            }

            ulong other = 0;

            if (parameters.Other != null)
            {
                other = parameters.Other.SimDescriptionId;
            }

            int score;

            if (targets != null)
            {
                if (targets.TryGetValue(other, out score))
                {
                    return(score);
                }
            }

            score = base.GetCachedScore(parameters, scoring);

            if (targets != null)
            {
                targets[other] = score;
            }

            return(score);
        }
예제 #2
0
        public int IScore(IScoringParameters parameters)
        {
            SP param = parameters as SP;

            if (param == null)
            {
                return(0);
            }

            return(ScoringLookup.AddStat(Name + param.ToString(), Score(param)));
        }
예제 #3
0
        public int Score(string name)
        {
            IListedScoringMethod scoring = ScoringLookup.GetScoring(name);

            if (scoring == null)
            {
                return(0);
            }

            return(scoring.IScore(this));
        }
예제 #4
0
        protected int PrivateScore(SP parameters, ICollection <IScoring <T, SubSP> > scoringList, string suffix)
        {
            Common.IStatGenerator manager = ScoringLookup.Stats;

            bool lowDebugging = false;

            if (manager != null)
            {
                lowDebugging = (manager.DebuggingLevel > Common.DebugLevel.Stats);
            }

            int totalScore = 0;

            foreach (IScoring <T, SubSP> scoring in scoringList)
            {
                string scoringName = null, fullScoringName = null;

                if (lowDebugging)
                {
                    scoringName = scoring.ToString() + suffix;

                    fullScoringName = "Duration " + Name + " " + scoringName;

                    scoringName = "Duration " + scoringName;
                }

                using (Common.TestSpan scoringTime2 = new Common.TestSpan(manager, scoringName))
                {
                    using (Common.TestSpan scoringTime = new Common.TestSpan(manager, fullScoringName, Common.DebugLevel.High))
                    {
                        int score = scoring.Score(parameters);

                        ScoringLookup.AddStat(scoring.ToString() + suffix, score);

                        if (score <= -1000)
                        {
                            return(score);
                        }

                        totalScore += score;
                    }
                }
            }

            return(totalScore);
        }
예제 #5
0
 public SimScoringList(string scoring)
 {
     mMethod = ScoringLookup.GetScoring(scoring);
 }
예제 #6
0
 public int AddScoring(string scoring, int option, ScoringLookup.OptionType type, SimDescription sim, SimDescription other, Common.DebugLevel minLevel)
 {
     return(AddScoring(scoring, ScoringLookup.GetScore(scoring, option, type, sim, other), minLevel));
 }
예제 #7
0
 public int AddScoring(string scoring, SimDescription sim, Common.DebugLevel minLevel)
 {
     return(AddScoring(scoring, ScoringLookup.GetScore(scoring, sim), minLevel));
 }
예제 #8
0
        public override int Score(SP parameters)
        {
            //return ScoreTask.Wait(this, parameters);

            mHelper.Prime();

            int totalScore = 0;

            int score = GetCachedScore(parameters, mHelper.CachableScoring);

            if (score <= -1000)
            {
                return(score);
            }

            totalScore += score;

            score = PrivateScore(parameters, mHelper.NonCachableScoring, " NotCached");
            if (score <= -1000)
            {
                return(score);
            }

            totalScore += score;

            if (!parameters.IsAbsolute)
            {
                totalScore /= mDivisor;

                if (totalScore > mUpperBound)
                {
                    totalScore = mUpperBound;
                }
                else if (totalScore < mLowerBound)
                {
                    totalScore = mLowerBound;
                }
            }

            if (parameters.IsAbsolute)
            {
                ScoringLookup.AddStat("Final Absolute " + Name, totalScore);
            }
            else
            {
                ScoringLookup.AddStat("Raw " + Name, totalScore);
            }

            if ((!parameters.IsAbsolute) && (mPercentChance))
            {
                float randomValue = GetRandomValue(parameters);

                if (totalScore <= randomValue)
                {
                    totalScore = 0;
                }

                ScoringLookup.AddStat("Random " + Name, randomValue);
                ScoringLookup.AddStat("Final " + Name, totalScore);
            }

            return(totalScore);
        }