Starting and stopping evasion

NodeCanvas Forums General Discussion Starting and stopping evasion

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #13928
    centaurianmudpig
    Participant

    Hello,

    I’m trying to implement some evasion for my AI. Evasion starts when the distance < 200 to the target. Once evading, I want it to stop evasion when distance is > 500 to the target.

    The problem I’m having is that as soon as the distance is greater than or equal to 200 the evasion stops. I thought a guard may stop this, but the Parallel is probably returning success as soon as Flee Target (EndAction is true when it’s run once).

    I need Flee Target and the > 500 condition to run in parallel.

    Any help in solving this would be greatly appreciated.

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

    Hello,

    Considering I understood correctly, here is one (of the many ways) that this can be done:
    RepeatUntil

    Once the initial condition “Distance < 200" is true, then the rest of that branch will "Repeat Until Failure". Failure will be returned if the left condition of the sequencer there "Distance > 500″ , is false. You can also make the Sequencer “Dynamic” if you want to continously evaluate the Distance Check.

    Let me know if that works for your case.
    Thank you.

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

    Attachments:
    You must be logged in to view attached files.
    #13932
    centaurianmudpig
    Participant

    Hey, thanks for the reply.

    Trying your solution, it doesn’t behave any different. Watching the graph, when < 200 is true it will call the rest but will stop when appearing >= 200. I also don’t see any visible running state for the loop the graph just look like it doesn’t run while it actually is running (proven by Log).

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

    Hello,

    I just re-created your posted tree and it honestly works as you describe you want it to.
    Does any of your actions (Flee Target or Log) in the “Evade” Action node, returns Failure by any chance?
    The Debug Log action can return failure if you’ve set it’s “Finish Status” in the inspector to Failure for example.

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

    #13962
    centaurianmudpig
    Participant

    Neither return failure, I did check that. Flee Target will always return success. I created a gif to show what is happening, perhaps you can spot the problem? You will see the distance being logged below for clarity.

    https://www.dropbox.com/s/5suj49drnykedgi/201812%20Pilot%20Behaviour%20Running.gif?dl=0 (2.1 mb)

    #13966
    centaurianmudpig
    Participant

    I created your example with a new project, just to be sure what I expected would meet reality.

    In this example, we see the visual “running” state with the yellow lines.
    https://www.dropbox.com/s/mb3thk9xu5djq7m/NC%20Evade%20Examplar.gif?dl=0

    In my actual project I don’t get that visual “running” representation, it actually looks like nothing is happening (when the whole branch stops failing). Yet the relevant code within the Repeat block is actually being run (as indicated by the logging that takes place).

    What you say is true, it should work as proven in my example project. What I’m getting in my main project is something completely different. Very confusing.

    To clarify… I simplified my main project and just have the target sitting at a distance of 100. We should be witnessing the “running” state, but the tree just looks like it’s doing nothing. Notice the log file, it is doing the Log “Hello World” and I also have a conditional “Distance” log within the Distance < 500 check).
    https://www.dropbox.com/s/tqre3lzqo7t2sgx/NC%20Evade%20Running%20Not%20Running.gif?dl=0

    #13967
    centaurianmudpig
    Participant

    Turned out to be the Start node, which is a Parallel with the Policy to “First Success Or Failure”. Another branch to that always return True and prevented the looping action. Setting the Policy to “First Failure” allowed the loop action to perform as expected.

    #13980
    Gavalakis
    Keymaster

    Hello again,

    Thanks for the follow up and I am glad you’ve found the problem.
    For your convenience and to avoid possible confusion:
    – Setting the Parallel to “First Failure” like you did, will make the Parallel continue exeuction until the first “Failure” is returned from a child node, in which case, the Parallel will cease execution and return Failure as well.
    – Setting the Parallel to “First Success Or Failure”, will basically make the parallel cease execution *as soon* as ANY child node return either Success or Failure (which is the case most of the times).

    The most common policies to use are indeed “First Failure”, then “First Success” if you want the inverse.
    “First Failure Or Success” is only usefull if you want the Parallel to “bail out” and return as soon as any child is basically finished regardless of Success or Failure status.

    Thanks.

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

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.