AI preset curves and expandable optimisation (#1346)
* AI preset curves and expandable optimisation Added preset curves for considerations to use just to avoid repeating the same variables all over the shop. Moved common considerations for expanded actions onto the expandable action e.g. you need a free hand to be able to PickUpGloves so we'll just check it the once rather than for each action. * FIX PRAGMA Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
@@ -3,11 +3,9 @@ using System.Collections.Generic;
|
||||
using Content.Server.AI.Operators;
|
||||
using Content.Server.AI.Operators.Inventory;
|
||||
using Content.Server.AI.Utility.Considerations;
|
||||
using Content.Server.AI.Utility.Considerations.Clothing;
|
||||
using Content.Server.AI.Utility.Considerations.Inventory;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Shared.GameObjects.Components.Inventory;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
@@ -44,9 +42,7 @@ namespace Content.Server.AI.Utility.Actions.Clothing.Gloves
|
||||
|
||||
return new[]
|
||||
{
|
||||
considerationsManager.Get<ClothingInSlotCon>().Slot(EquipmentSlotDefines.Slots.GLOVES, context)
|
||||
.InverseBoolCurve(context),
|
||||
considerationsManager.Get<CanPutTargetInHandsCon>()
|
||||
considerationsManager.Get<CanPutTargetInInventoryCon>()
|
||||
.BoolCurve(context),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using Content.Server.AI.Utility.Considerations;
|
||||
using Content.Server.AI.Utility.Considerations.Clothing;
|
||||
using Content.Server.AI.Utility.Considerations.Containers;
|
||||
using Content.Server.AI.Utility.Considerations.Inventory;
|
||||
using Content.Server.AI.Utility.Considerations.Movement;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Shared.GameObjects.Components.Inventory;
|
||||
@@ -40,13 +41,11 @@ namespace Content.Server.AI.Utility.Actions.Clothing.Gloves
|
||||
|
||||
return new[]
|
||||
{
|
||||
considerationsManager.Get<ClothingInSlotCon>().Slot(EquipmentSlotDefines.Slots.GLOVES, context)
|
||||
.InverseBoolCurve(context),
|
||||
considerationsManager.Get<CanPutTargetInHandsCon>()
|
||||
considerationsManager.Get<CanPutTargetInInventoryCon>()
|
||||
.BoolCurve(context),
|
||||
considerationsManager.Get<ClothingInInventoryCon>().Slot(EquipmentSlotDefines.SlotFlags.GLOVES, context)
|
||||
.InverseBoolCurve(context),
|
||||
considerationsManager.Get<TargetAccessibleCon>()
|
||||
considerationsManager.Get<TargetDistanceCon>()
|
||||
.PresetCurve(context, PresetCurve.Distance),
|
||||
considerationsManager.Get<TargetAccessibleCon>()
|
||||
.BoolCurve(context),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -44,9 +44,7 @@ namespace Content.Server.AI.Utility.Actions.Clothing.Head
|
||||
|
||||
return new[]
|
||||
{
|
||||
considerationsManager.Get<ClothingInSlotCon>().Slot(EquipmentSlotDefines.Slots.HEAD, context)
|
||||
.InverseBoolCurve(context),
|
||||
considerationsManager.Get<CanPutTargetInHandsCon>()
|
||||
considerationsManager.Get<CanPutTargetInInventoryCon>()
|
||||
.BoolCurve(context),
|
||||
};
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using Content.Server.AI.Utility.Considerations;
|
||||
using Content.Server.AI.Utility.Considerations.Clothing;
|
||||
using Content.Server.AI.Utility.Considerations.Containers;
|
||||
using Content.Server.AI.Utility.Considerations.Inventory;
|
||||
using Content.Server.AI.Utility.Considerations.Movement;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Shared.GameObjects.Components.Inventory;
|
||||
@@ -40,13 +41,11 @@ namespace Content.Server.AI.Utility.Actions.Clothing.Head
|
||||
|
||||
return new[]
|
||||
{
|
||||
considerationsManager.Get<ClothingInSlotCon>().Slot(EquipmentSlotDefines.Slots.HEAD, context)
|
||||
.InverseBoolCurve(context),
|
||||
considerationsManager.Get<CanPutTargetInHandsCon>()
|
||||
considerationsManager.Get<CanPutTargetInInventoryCon>()
|
||||
.BoolCurve(context),
|
||||
considerationsManager.Get<ClothingInInventoryCon>().Slot(EquipmentSlotDefines.SlotFlags.HEAD, context)
|
||||
.InverseBoolCurve(context),
|
||||
considerationsManager.Get<TargetAccessibleCon>()
|
||||
considerationsManager.Get<TargetDistanceCon>()
|
||||
.PresetCurve(context, PresetCurve.Distance),
|
||||
considerationsManager.Get<TargetAccessibleCon>()
|
||||
.BoolCurve(context),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -44,9 +44,7 @@ namespace Content.Server.AI.Utility.Actions.Clothing.OuterClothing
|
||||
|
||||
return new[]
|
||||
{
|
||||
considerationsManager.Get<ClothingInSlotCon>().Slot(EquipmentSlotDefines.Slots.OUTERCLOTHING, context)
|
||||
.InverseBoolCurve(context),
|
||||
considerationsManager.Get<CanPutTargetInHandsCon>()
|
||||
considerationsManager.Get<CanPutTargetInInventoryCon>()
|
||||
.BoolCurve(context),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using Content.Server.AI.Utility.Considerations;
|
||||
using Content.Server.AI.Utility.Considerations.Clothing;
|
||||
using Content.Server.AI.Utility.Considerations.Containers;
|
||||
using Content.Server.AI.Utility.Considerations.Inventory;
|
||||
using Content.Server.AI.Utility.Considerations.Movement;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Shared.GameObjects.Components.Inventory;
|
||||
@@ -40,12 +41,10 @@ namespace Content.Server.AI.Utility.Actions.Clothing.OuterClothing
|
||||
|
||||
return new[]
|
||||
{
|
||||
considerationsManager.Get<ClothingInSlotCon>().Slot(EquipmentSlotDefines.Slots.OUTERCLOTHING, context)
|
||||
.InverseBoolCurve(context),
|
||||
considerationsManager.Get<CanPutTargetInHandsCon>()
|
||||
considerationsManager.Get<CanPutTargetInInventoryCon>()
|
||||
.BoolCurve(context),
|
||||
considerationsManager.Get<ClothingInInventoryCon>().Slot(EquipmentSlotDefines.SlotFlags.OUTERCLOTHING, context)
|
||||
.InverseBoolCurve(context),
|
||||
considerationsManager.Get<TargetDistanceCon>()
|
||||
.PresetCurve(context, PresetCurve.Distance),
|
||||
considerationsManager.Get<TargetAccessibleCon>()
|
||||
.BoolCurve(context),
|
||||
};
|
||||
|
||||
@@ -44,9 +44,7 @@ namespace Content.Server.AI.Utility.Actions.Clothing.Shoes
|
||||
|
||||
return new[]
|
||||
{
|
||||
considerationsManager.Get<ClothingInSlotCon>().Slot(EquipmentSlotDefines.Slots.SHOES, context)
|
||||
.InverseBoolCurve(context),
|
||||
considerationsManager.Get<CanPutTargetInHandsCon>()
|
||||
considerationsManager.Get<CanPutTargetInInventoryCon>()
|
||||
.BoolCurve(context),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using Content.Server.AI.Utility.Considerations;
|
||||
using Content.Server.AI.Utility.Considerations.Clothing;
|
||||
using Content.Server.AI.Utility.Considerations.Containers;
|
||||
using Content.Server.AI.Utility.Considerations.Inventory;
|
||||
using Content.Server.AI.Utility.Considerations.Movement;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
using Content.Shared.GameObjects.Components.Inventory;
|
||||
@@ -40,12 +41,10 @@ namespace Content.Server.AI.Utility.Actions.Clothing.Shoes
|
||||
|
||||
return new[]
|
||||
{
|
||||
considerationsManager.Get<ClothingInSlotCon>().Slot(EquipmentSlotDefines.Slots.SHOES, context)
|
||||
.InverseBoolCurve(context),
|
||||
considerationsManager.Get<CanPutTargetInHandsCon>()
|
||||
considerationsManager.Get<CanPutTargetInInventoryCon>()
|
||||
.BoolCurve(context),
|
||||
considerationsManager.Get<ClothingInInventoryCon>().Slot(EquipmentSlotDefines.SlotFlags.SHOES, context)
|
||||
.InverseBoolCurve(context),
|
||||
considerationsManager.Get<TargetDistanceCon>()
|
||||
.PresetCurve(context, PresetCurve.Distance),
|
||||
considerationsManager.Get<TargetAccessibleCon>()
|
||||
.BoolCurve(context),
|
||||
};
|
||||
|
||||
@@ -44,9 +44,7 @@ namespace Content.Server.AI.Utility.Actions.Combat.Melee
|
||||
|
||||
return new[]
|
||||
{
|
||||
considerationsManager.Get<MeleeWeaponEquippedCon>()
|
||||
.InverseBoolCurve(context),
|
||||
considerationsManager.Get<CanPutTargetInHandsCon>()
|
||||
considerationsManager.Get<CanPutTargetInInventoryCon>()
|
||||
.BoolCurve(context),
|
||||
considerationsManager.Get<MeleeWeaponSpeedCon>()
|
||||
.QuadraticCurve(context, 1.0f, 0.5f, 0.0f, 0.0f),
|
||||
|
||||
@@ -66,16 +66,14 @@ namespace Content.Server.AI.Utility.Actions.Combat.Melee
|
||||
|
||||
return new[]
|
||||
{
|
||||
considerationsManager.Get<MeleeWeaponEquippedCon>()
|
||||
.BoolCurve(context),
|
||||
considerationsManager.Get<TargetIsDeadCon>()
|
||||
.InverseBoolCurve(context),
|
||||
considerationsManager.Get<TargetIsCritCon>()
|
||||
.QuadraticCurve(context, -0.8f, 1.0f, 1.0f, 0.0f),
|
||||
considerationsManager.Get<DistanceCon>()
|
||||
.QuadraticCurve(context, 1.0f, 1.0f, 0.02f, 0.0f),
|
||||
considerationsManager.Get<TargetDistanceCon>()
|
||||
.PresetCurve(context, PresetCurve.Distance),
|
||||
considerationsManager.Get<TargetHealthCon>()
|
||||
.QuadraticCurve(context, 1.0f, 0.4f, 0.0f, -0.02f),
|
||||
.PresetCurve(context, PresetCurve.TargetHealth),
|
||||
considerationsManager.Get<MeleeWeaponSpeedCon>()
|
||||
.QuadraticCurve(context, 1.0f, 0.5f, 0.0f, 0.0f),
|
||||
considerationsManager.Get<MeleeWeaponDamageCon>()
|
||||
|
||||
@@ -42,12 +42,8 @@ namespace Content.Server.AI.Utility.Actions.Combat.Melee
|
||||
|
||||
return new[]
|
||||
{
|
||||
considerationsManager.Get<FreeHandCon>()
|
||||
.BoolCurve(context),
|
||||
considerationsManager.Get<HasMeleeWeaponCon>()
|
||||
.InverseBoolCurve(context),
|
||||
considerationsManager.Get<DistanceCon>()
|
||||
.QuadraticCurve(context, 1.0f, 1.0f, 0.02f, 0.0f),
|
||||
considerationsManager.Get<TargetDistanceCon>()
|
||||
.PresetCurve(context, PresetCurve.Distance),
|
||||
considerationsManager.Get<MeleeWeaponDamageCon>()
|
||||
.QuadraticCurve(context, 1.0f, 0.25f, 0.0f, 0.0f),
|
||||
considerationsManager.Get<MeleeWeaponSpeedCon>()
|
||||
|
||||
@@ -64,16 +64,14 @@ namespace Content.Server.AI.Utility.Actions.Combat.Melee
|
||||
|
||||
return new[]
|
||||
{
|
||||
considerationsManager.Get<CanUnarmedCombatCon>()
|
||||
.BoolCurve(context),
|
||||
considerationsManager.Get<TargetIsDeadCon>()
|
||||
.InverseBoolCurve(context),
|
||||
considerationsManager.Get<TargetIsCritCon>()
|
||||
.QuadraticCurve(context, -0.8f, 1.0f, 1.0f, 0.0f),
|
||||
considerationsManager.Get<DistanceCon>()
|
||||
.QuadraticCurve(context, -1.0f, 1.0f, 1.02f, 0.0f),
|
||||
considerationsManager.Get<TargetDistanceCon>()
|
||||
.PresetCurve(context, PresetCurve.Distance),
|
||||
considerationsManager.Get<TargetHealthCon>()
|
||||
.QuadraticCurve(context, 1.0f, 0.4f, 0.0f, -0.02f),
|
||||
.PresetCurve(context, PresetCurve.TargetHealth),
|
||||
considerationsManager.Get<TargetAccessibleCon>()
|
||||
.BoolCurve(context),
|
||||
// TODO: Consider our Speed and Damage to compare this to using a weapon
|
||||
@@ -81,4 +79,4 @@ namespace Content.Server.AI.Utility.Actions.Combat.Melee
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Content.Server.AI.Utility.Actions.Idle
|
||||
/// </summary>
|
||||
public sealed class CloseLastEntityStorage : UtilityAction
|
||||
{
|
||||
public override float Bonus => 1.5f;
|
||||
public override float Bonus => IdleBonus + 0.01f;
|
||||
|
||||
public CloseLastEntityStorage(IEntity owner) : base(owner) {}
|
||||
|
||||
@@ -50,12 +50,12 @@ namespace Content.Server.AI.Utility.Actions.Idle
|
||||
{
|
||||
considerationsManager.Get<StoredStateEntityIsNullCon>().Set(typeof(LastOpenedStorageState), context)
|
||||
.InverseBoolCurve(context),
|
||||
considerationsManager.Get<DistanceCon>()
|
||||
.QuadraticCurve(context, 1.0f, 1.0f, 0.02f, 0.0f),
|
||||
considerationsManager.Get<TargetAccessibleCon>()
|
||||
considerationsManager.Get<TargetDistanceCon>()
|
||||
.PresetCurve(context, PresetCurve.Distance),
|
||||
considerationsManager.Get<TargetAccessibleCon>()
|
||||
.BoolCurve(context),
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,9 +43,9 @@ namespace Content.Server.AI.Utility.Actions.Nutrition.Drink
|
||||
considerationsManager.Get<FreeHandCon>()
|
||||
.BoolCurve(context),
|
||||
considerationsManager.Get<ThirstCon>()
|
||||
.LogisticCurve(context, 1000f, 1.3f, -1.0f, 0.5f),
|
||||
considerationsManager.Get<DistanceCon>()
|
||||
.QuadraticCurve(context, 1.0f, 1.0f, 0.02f, 0.0f),
|
||||
.PresetCurve(context, PresetCurve.Nutrition),
|
||||
considerationsManager.Get<TargetDistanceCon>()
|
||||
.PresetCurve(context, PresetCurve.Distance),
|
||||
considerationsManager.Get<DrinkValueCon>()
|
||||
.QuadraticCurve(context, 1.0f, 0.4f, 0.0f, 0.0f),
|
||||
considerationsManager.Get<TargetAccessibleCon>()
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using Content.Server.AI.Operators;
|
||||
using Content.Server.AI.Operators.Inventory;
|
||||
using Content.Server.AI.Utility.Considerations;
|
||||
using Content.Server.AI.Utility.Considerations.Hands;
|
||||
using Content.Server.AI.Utility.Considerations.Inventory;
|
||||
using Content.Server.AI.Utility.Considerations.Nutrition.Drink;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
@@ -43,10 +43,8 @@ namespace Content.Server.AI.Utility.Actions.Nutrition.Drink
|
||||
|
||||
return new[]
|
||||
{
|
||||
considerationsManager.Get<TargetInOurHandsCon>()
|
||||
considerationsManager.Get<TargetInOurInventoryCon>()
|
||||
.BoolCurve(context),
|
||||
considerationsManager.Get<ThirstCon>()
|
||||
.LogisticCurve(context, 1000f, 1.3f, -0.3f, 0.5f),
|
||||
considerationsManager.Get<DrinkValueCon>()
|
||||
.QuadraticCurve(context, 1.0f, 0.4f, 0.0f, 0.0f),
|
||||
};
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using Content.Server.AI.Operators.Sequences;
|
||||
using Content.Server.AI.Utility.Considerations;
|
||||
using Content.Server.AI.Utility.Considerations.Containers;
|
||||
using Content.Server.AI.Utility.Considerations.Hands;
|
||||
using Content.Server.AI.Utility.Considerations.Movement;
|
||||
using Content.Server.AI.Utility.Considerations.Nutrition.Food;
|
||||
using Content.Server.AI.WorldState;
|
||||
@@ -40,12 +39,8 @@ namespace Content.Server.AI.Utility.Actions.Nutrition.Food
|
||||
|
||||
return new[]
|
||||
{
|
||||
considerationsManager.Get<FreeHandCon>()
|
||||
.BoolCurve(context),
|
||||
considerationsManager.Get<HungerCon>()
|
||||
.LogisticCurve(context, 1000f, 1.3f, -1.0f, 0.5f),
|
||||
considerationsManager.Get<DistanceCon>()
|
||||
.QuadraticCurve(context, 1.0f, 1.0f, 0.02f, 0.0f),
|
||||
considerationsManager.Get<TargetDistanceCon>()
|
||||
.PresetCurve(context, PresetCurve.Distance),
|
||||
considerationsManager.Get<FoodValueCon>()
|
||||
.QuadraticCurve(context, 1.0f, 0.4f, 0.0f, 0.0f),
|
||||
considerationsManager.Get<TargetAccessibleCon>()
|
||||
|
||||
@@ -3,8 +3,7 @@ using System.Collections.Generic;
|
||||
using Content.Server.AI.Operators;
|
||||
using Content.Server.AI.Operators.Inventory;
|
||||
using Content.Server.AI.Utility.Considerations;
|
||||
using Content.Server.AI.Utility.Considerations.Containers;
|
||||
using Content.Server.AI.Utility.Considerations.Hands;
|
||||
using Content.Server.AI.Utility.Considerations.Inventory;
|
||||
using Content.Server.AI.Utility.Considerations.Nutrition.Food;
|
||||
using Content.Server.AI.WorldState;
|
||||
using Content.Server.AI.WorldState.States;
|
||||
@@ -44,13 +43,10 @@ namespace Content.Server.AI.Utility.Actions.Nutrition.Food
|
||||
|
||||
return new[]
|
||||
{
|
||||
considerationsManager.Get<TargetInOurHandsCon>()
|
||||
considerationsManager.Get<TargetInOurInventoryCon>()
|
||||
.BoolCurve(context),
|
||||
considerationsManager.Get<HungerCon>()
|
||||
.LogisticCurve(context, 1000f, 1.3f, -0.3f, 0.5f),
|
||||
considerationsManager.Get<FoodValueCon>()
|
||||
.QuadraticCurve(context, 1.0f, 0.4f, 0.0f, 0.0f),
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,6 @@ namespace Content.Server.AI.Utility.Actions
|
||||
/// This is where the magic happens
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="bonus"></param>
|
||||
/// <param name="min"></param>
|
||||
/// <returns></returns>
|
||||
public float GetScore(Blackboard context, float min)
|
||||
|
||||
Reference in New Issue
Block a user