Help with Submarine AI Design

NodeCanvas Forums General Discussion Help with Submarine AI Design

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #12147
    arachnidjacob
    Participant

    So I’m pretty new with Behaviourtrees for AI, (last time i gave up on RAIN AI and wrote my own)

    This time around i’m a lot more confident and i’ve gotten some simple behaviours working, but i’m struggling to make it scaleable and modular.

    I’m going about it with the design mindset I would have if i were hand-coding it.

    My basic flow is something along the lines of:

    Get Information from Sensors( Sonar, Ship hull status, etc) and commit to blackboard =>
    Make Decision based on information ( switch an Enum to different AI States, leading to its own subTree, further editing blackboard values) =>
    Execute Movement, Docking and Attacking based on decision.

    Current tree is attached in screenshot.

    The problem i have wrapping my head around is how the tree gets “stuck” in the branches while running, essentially stopping the sensors from gathering more information, and the decisions from being made.

    I could run every big branch constantly, but something tells me that is not how i should be designing these, and multi-running nodes should be kept as far out on the branches as possible for performance reasons?

    Which then leads me to think that some form of design pattern for re-evaluation of Sensors and Decisions when new information comes in?

    Its a very big topic, and i plan to keep this thread updated with my progress, but any design insight would be extremely helpful.

    Thanks

    Jacob

    Attachments:
    You must be logged in to view attached files.
    #12155
    Gavalakis
    Keymaster

    Hey,

    I think that you probably need to use a Parallel node so that your Sensors are always updated (thus up-to-date), instead of using a Dynamic Sequencer, and in return the rest of the nodes can work with the up to date sensor data.

    Another thing I personally always recommend, is to instead of getting sensor information and setting them to blackboard variables (2 steps), would be to make it all into one step by Property Binding the variables directly to a property that returns this information you need.

    I see that you’ve already used bound properties for what I see to be an AIMono type, but I suggest you try using bound properties for all variables / information that need to be up-to-date on demand.
    You could for example create a custom MonoBehaviour class only with properties you need and attach it on the gameobject in question, then create a bound variable for each of those properties you make in the class.

    The general design approach I suggest, is to avoid doing complicated things within a behaviour tree. Meaning, don’t try to use is as a visual scripting system to replace code by doing algorithmic things within it. Instead use BTs to directly “TELL” the agent what to do, with property bound variables as a backend of information.
    This is quite in theory of course 🙂

    Using a Switch Enum composite is also a good idea indeed, to make the BT select the branch to continue with. You can of course create a custom enum type variable to use for the Switch Enum composite.

    To return to your initial issue, I once again think that you need to use a Parallel node if you want things to happen simultaneously with other things, or move those sensors to be property bound variables and as such always up-to-date on demand, by having the property doing the math and return the information needed instead of fighting against setting a variable all the time.

    Please let me know if that helps at all, or if you want to elaborate on anything.
    Thanks!

    Join us on Discord: https://discord.gg/97q2Rjh

    #12240
    arachnidjacob
    Participant

    Thanks a lot! Ill just post my current system and some notes for reference to catalog what im doing.

    The AI Trunk, left side holds a series of event listeners that get instructions and updates from the ship’s monobehaviour and sets the enumerator for the action to execute, left side executes the enumerator until it returns true, where it resets the mission.
    AI-trunk

    A simple mission to pick a destination somehwere in the world with “city” tags, and constructs a route to pass into the “go to” function
    mission-example

    “Go to” tree, pathfinds along route while also handling local avoidance by offsetting the target vector and setting the throttle reactively.
    pathFindTo

    Let me know if you have questions or insights into how this is structured, and if i should be doing something else

    Attachments:
    You must be logged in to view attached files.
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.