structured programming of automata with behavior trees

Lauren Pullen <[email protected]> Sun, 12 Jul 2026 09:37:20 -0600
Newsgroups gmane.comp.lang.smalltalk.squeak.general
Message-ID <[email protected]>
Greetings List,

I thought I'd follow the spirit of the upcoming Squeak release to work 
on improving some of my programs.  If you had previously looked at 
Cephei-BehaviorKernel and thought it looked like a neat, but 
impractical, toy, and weren't quite sure why, the answer was you 
couldn't create subroutines.

And now, as of lrnp.12, you can!  Wander over to BTSubtree's example1 
for a nostalgic demo.

For those of you just tuning in, a behavior tree uses an execution model 
completely unlike smalltalk's.  Smalltalk uses the normal successor, 
PC=PC+1, while a behavior tree uses a boolean successor, like Prolog. 
Control flow is based on the shape of the tree and whether you used an 
AND, OR, or NOT node to combine nodes.  Unlike smalltalk and prolog, 
behavior trees use 3-valued logic (success, failure, and incomplete).

If you disregard the "incomplete" value, you can represent boolean 
successor in regular smalltalk code.  It looks like this:

^self m1 and: [self m2 and: [self m3 or: [self m4]]].

Instead of writing statically-compiled methods, Cephei-BehaviorTree 
defines procedures dynamically using 1st-class objects and simulates a 
boolean successor machine.

My behavior tree implementation is designed to augment my dynamic Mealy 
finite-state automata implementation (in StarVariable).  Instead of 
implementing Harel statecharts or relying on backtracking to enforce 
interlocks you use behavior trees to guard against sending improper 
input to the FSM, and more.

This is a pretty low-level tool, but it's object-oriented.  Any instance 
can be a node if you define the methods from BTNode's instance side. 
The bare minimum is #tick:; the dynamic environment (a StarDictionary) 
is passed as the argument, and it must answer one of true, false, or nil.

(A BTShallowBinder only extends the dynamic environment.  It's a 
subnode's responsibility to put something useful in the slot.  Low level 
gives you flexibility.)
Squeak-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]