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); }
public int IScore(IScoringParameters parameters) { SP param = parameters as SP; if (param == null) { return(0); } return(ScoringLookup.AddStat(Name + param.ToString(), Score(param))); }
public int Score(string name) { IListedScoringMethod scoring = ScoringLookup.GetScoring(name); if (scoring == null) { return(0); } return(scoring.IScore(this)); }
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); }
public SimScoringList(string scoring) { mMethod = ScoringLookup.GetScoring(scoring); }
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)); }
public int AddScoring(string scoring, SimDescription sim, Common.DebugLevel minLevel) { return(AddScoring(scoring, ScoringLookup.GetScore(scoring, sim), minLevel)); }
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); }