Merge branch 'master' into mathmerge

This commit is contained in:
Pieter-Jan Briers
2020-08-20 20:33:43 +02:00
808 changed files with 18173 additions and 5666 deletions

View File

@@ -1,4 +1,4 @@
using Content.Server.AI.WorldState;
using Content.Server.AI.WorldState;
using Content.Server.AI.WorldState.States;
using Content.Server.GameObjects.Components.Damage;
using Content.Shared.GameObjects.Components.Damage;
@@ -11,13 +11,12 @@ namespace Content.Server.AI.Utility.Considerations.Combat
{
var target = context.GetState<TargetEntityState>().GetValue();
if (target == null || !target.TryGetComponent(out DamageableComponent damageableComponent))
if (target == null || !target.TryGetComponent(out IDamageableComponent damageableComponent))
{
return 0.0f;
}
// Just went with max health
return damageableComponent.CurrentDamage[DamageType.Total] / 300.0f;
return damageableComponent.TotalDamage / 300.0f;
}
}
}

View File

@@ -1,6 +1,6 @@
using Content.Server.AI.WorldState;
using Content.Server.AI.WorldState;
using Content.Server.AI.WorldState.States;
using Content.Server.GameObjects.Components.Mobs;
using Content.Shared.GameObjects.Components.Damage;
namespace Content.Server.AI.Utility.Considerations.Combat
{
@@ -10,12 +10,12 @@ namespace Content.Server.AI.Utility.Considerations.Combat
{
var target = context.GetState<TargetEntityState>().GetValue();
if (target == null || !target.TryGetComponent(out SpeciesComponent speciesComponent))
if (target == null || !target.TryGetComponent(out IDamageableComponent damageableComponent))
{
return 0.0f;
}
if (speciesComponent.CurrentDamageState is CriticalState)
if (damageableComponent.CurrentDamageState == DamageState.Critical)
{
return 1.0f;
}

View File

@@ -1,6 +1,6 @@
using Content.Server.AI.WorldState;
using Content.Server.AI.WorldState;
using Content.Server.AI.WorldState.States;
using Content.Server.GameObjects.Components.Mobs;
using Content.Shared.GameObjects.Components.Damage;
namespace Content.Server.AI.Utility.Considerations.Combat
{
@@ -10,12 +10,12 @@ namespace Content.Server.AI.Utility.Considerations.Combat
{
var target = context.GetState<TargetEntityState>().GetValue();
if (target == null || !target.TryGetComponent(out SpeciesComponent speciesComponent))
if (target == null || !target.TryGetComponent(out IDamageableComponent damageableComponent))
{
return 0.0f;
}
if (speciesComponent.CurrentDamageState is DeadState)
if (damageableComponent.CurrentDamageState == DamageState.Dead)
{
return 1.0f;
}

View File

@@ -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)