So I am making my own Utility AI system based on the Dave Mark Infinite Axis Utility System:
However, some questions during my development come up:
First, let me introduce you to my basic structure:
Actions
All actions have a list of potential considerations
public abstract class BaseAction : ScriptableObject {
public List<BaseConsideration> InputAxises;
public EnumActionState ActionState;
public abstract void Act(BaseAiContext ctx);
public abstract float GetScore(BaseAiContext ctx);
public abstract void Update(BaseAiContext cts);
public abstract bool IsDone(BaseAiContext ctx);
}
Then it has a state that tells me when an action is done.
Then I have a simple AIContext
that has a list of potential actions my Agent can take. it then scores all actions and then selects the highest scored
Decisions
public abstract class BaseConsideration : ScriptableObject, IConsideration
{
(SerializeField)
public EnumEvaluator EvaluatorType;
public string NameId { get; }
public float Weight { get; set; }
public bool IsInverted { get; set; }
public string DataKey { get; set; }
public float Xa;
public float Xb;
public float Ya;
public float Yb;
public float K;
public abstract float Consider(BaseAiContext context);
public abstract float Consider(float x);
}
ofc the consider function uses an evaluator (Linear, sigmoid etc) to find the best match.
Now, this is where things begin to get a little bit fuzzy for me.
let’s say that I have a melee guy who has an action “Attack Enemy” then I have a sensor that tells the Context which targets he has available then I make the following structure:
(Action) Melee Attack
- (Decision) is there a target within melee distance
Then back in my action, I choose the closest target. and attack it
Is this how it is supposed to be? or should considerations be able to select targets for the AI context? Have I done something wrong in my architecture or?
Update boiled down
I think the main problem i have is what defines an action and how deep do they go?
Here are two examples of an actions:
- Select a target
- Melee Attack
The first (Select a target) would be to select from a list and then complete
While the second might do the following steps:
- Select a target
- Go to target if far away
- Attack with a sword
Also, what is the job of the consideration should the consideration be able to set values of the AI Context or should it only return a score based on the Graph model?