Merge branch 'master' into mathmerge
This commit is contained in:
@@ -13,18 +13,27 @@ namespace Content.Server.AI.Utility.Considerations
|
||||
private float GetAdjustedScore(Blackboard context)
|
||||
{
|
||||
var score = GetScore(context);
|
||||
/*
|
||||
* Now using the geometric mean
|
||||
* for n scores you take the n-th root of the scores multiplied
|
||||
* e.g. a, b, c scores you take Math.Pow(a * b * c, 1/3)
|
||||
* To get the ACTUAL geometric mean at any one stage you'd need to divide by the running consideration count
|
||||
* however, the downside to this is it will fluctuate up and down over time.
|
||||
* For our purposes if we go below the minimum threshold we want to cut it off, thus we take a
|
||||
* "running geometric mean" which can only ever go down (and by the final value will equal the actual geometric mean).
|
||||
*/
|
||||
|
||||
// Previously we used a makeupvalue method although the geometric mean is less punishing for more considerations
|
||||
var considerationsCount = context.GetState<ConsiderationState>().GetValue();
|
||||
var modificationFactor = 1.0f - 1.0f / considerationsCount;
|
||||
var makeUpValue = (1.0f - score) * modificationFactor;
|
||||
var adjustedScore = score + makeUpValue * score;
|
||||
return MathHelper.Clamp(adjustedScore, 0.0f, 1.0f);
|
||||
var adjustedScore = MathF.Pow(score, 1 / (float) considerationsCount);
|
||||
return FloatMath.Clamp(adjustedScore, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
[Pure]
|
||||
private static float BoolCurve(float x)
|
||||
{
|
||||
// ReSharper disable once CompareOfFloatsByEqualityOperator
|
||||
return x == 1.0f ? 1.0f : 0.0f;
|
||||
return x > 0.0f ? 1.0f : 0.0f;
|
||||
}
|
||||
|
||||
public Func<float> BoolCurve(Blackboard context)
|
||||
@@ -42,7 +51,7 @@ namespace Content.Server.AI.Utility.Considerations
|
||||
private static float InverseBoolCurve(float x)
|
||||
{
|
||||
// ReSharper disable once CompareOfFloatsByEqualityOperator
|
||||
return x == 1.0f ? 0.0f : 1.0f;
|
||||
return x == 0.0f ? 1.0f : 0.0f;
|
||||
}
|
||||
|
||||
public Func<float> InverseBoolCurve(Blackboard context)
|
||||
|
||||
Reference in New Issue
Block a user