JarkkoPar / Utility_AI_GDExtension

This repository contains the binaries and example project for the Utility AI GDExtension.
MIT License
75 stars 2 forks source link

How nested can you make behaviours (and actions, considerations etc while we're at it) #15

Closed Franz-Inc closed 9 months ago

Franz-Inc commented 9 months ago

Some additional useful information would be how nested you can make nodes - you mentioned at one point that you can have only 1 layer of Group Nodes (Behaviour, Action or whatever), but can you layer Action Nodes? What if I want to make a behaviour that is 3 nodes deep (Group Behaviour, Behaviour, Sub-behaviour)? The example I am thinking of is related to your Cover example: An AI would have a Behaviour group of Combat State, then Behaviour of In-Cover, and Sub-Behaviour of Leaving Cover, Shooting, Reloaded blah blah.... Right now I'm just doing many Behaviours without the subgrouping, but I'm curious on your thoughts.

Cheers

Franz-Inc commented 9 months ago

I thought of another usecase, but for actions:

ActionPickNewPosition ActionGroupMove = Action BreakCover + ActionMoveToDesiredPosition

Of course I could do this as: ActionPickNewPosition Action BreakCover ActionMoveToDesiredPosition

But I see an organizational value in grouping the latter two as they will almost always go hand-in-hand (when ever the AI moves, the assumption is that they need to break cover to do so)

JarkkoPar commented 9 months ago

You can nest the ActionGroups, SensorGroups and ConsiderationGroups as much as you want and need. Currently only the BehaviourGroup and Behaviour has the nesting limitation.

My thinking was that the BehaviourGroups are used to activate/deactive or add/remove groups of behaviours. However, thanks to your and @madeleineostoja suggestions to add more signals to the nodes, it makes a lot of sense to support deeper nesting for the Behaviours as well. This would allow hierarchical behaviours, where the agent would try and find the best scoring behaviour within the tree and then emit the signals for the tree somewhat similarly to how the State Tree works.

I'll look in to adding this as well for the next release or the one after that.

Franz-Inc commented 9 months ago

Hi JarrkoPar,

I'm not sure, but I may have run into a bug around this nesting of ConsideationGroups.

See the nested Considerations: image

AmIHealthy is linked to a health sensor, basically giving back %health. image While testing, as you can see, its designed to score a value of 1 if he's near 100% health. However, despite the enemy actually having 100% health, the Score is listed as 0. I then duplicated the exact node AmIHealthy? (same sensor, same graph etc) and put it in the first Coniseration Group (see AmIHealthy?2)

image

And this one gets the correct score of 1.

Perhaps the nested groups in groups don't work as intended? Or did I misunderstand something here? Thanks!

JarkkoPar commented 9 months ago

I did a test scene and nested 10 consideration groups and considerations, and pointed them to a sensor. All of them seemed to work just fine. I looked through the code as well and couldn't find what could cause this issue. Is the MyPowerLevel group active?

JarkkoPar commented 9 months ago

I could not replicate this issue and I cannot find an error in the code, so I close this issue for now. Please do ping me if you need more support with this @Franz-Inc .