active-logic / activelogic-cs

Behavior Trees and Case Logic for C#7
GNU Affero General Public License v3.0
106 stars 7 forks source link

Reset-on-Exit/Reset-on-Crit #43

Closed eelstork closed 3 years ago

eelstork commented 3 years ago

Reset-on-Resume (RoR) is a relatively new feature in Active Logic. Experiments show that Reset-on-Resume is not dependable enough, since it may cause issues when repeating tasks seamlessly (see #37) Reset-on-Exit is safer, and may be implemented as follows:

roe DoSomething() => `cx() && Wait(0.5) && ... ;  

Or

roe DoSomething(){
    // some preliminary work
    return cx() && Once()?[ task ] ... ;   
}

Above syntax is primarily attractive because it does not require delimiters; other syntaxes are possible; this may come with a few desirable features:

eelstork commented 3 years ago

Draft fix for this. Syntax is conservative:

status Task => roe[ ... ];

Looks thread-safe; likely supports nesting also.

One possible alternative only requires a pseudo-type. Will put this on a branch later, if only for the hell of it.

eelstork commented 3 years ago

Looks like both RoR and RoE may be needed to ensure decorators reset when they are expected to.

eelstork commented 3 years ago

Dependable solution here is a reset-on-criterion (RoC) (and perhaps later, reset-on-condition) block. Reset-on-exit (RoE) is documented in BT literature, will work in many cases, but I am seeing edge cases where results are incorrect; keeping for now pending further testing/evaluation.