Vultrabot Behavior Tree Demo
This demo implements a far more complex behavior tree than the simple ones in the Pacman and Robot demos.
The Behavior Tree for this demo is essentially the entire tree defined in the Behavior Logic section.
Demo Output
Usage
# if vultron package is installed
# run the demo
$ vultrabot
# or
$ vultrabot --cvd
# print the tree and exit
$ vultrabot --cvd --print-tree
# if vultron package is not installed
$ python -m vultron.bt.base.demo.vultrabot
When the tree is run, it will look something like this:
msgs_received_this_tick q_rm q_em q_cs msgs_emitted_this_tick CVD_role
1 () START NONE vfdpxa () FINDER_REPORTER_VENDOR_DEPLOYER_COORDINATOR
2 (RS, RS, CV, CV, RK, CV, RK, CK, CK, CK) START NONE vfdpxa (RS, CV, CV, RK, CV, RK, CK, CK, CK, RV) FINDER_REPORTER_VENDOR_DEPLOYER_COORDINATOR
3 (RV, RK) VALID NONE Vfdpxa (RK, RA, EP) FINDER_REPORTER_VENDOR_DEPLOYER_COORDINATOR
4 (RA, EP, RK, EK) ACCEPTED PROPOSED Vfdpxa (RK, EK, ER) FINDER_REPORTER_VENDOR_DEPLOYER_COORDINATOR
5 (ER, EK) ACCEPTED NONE Vfdpxa (EK, EP) FINDER_REPORTER_VENDOR_DEPLOYER_COORDINATOR
6 (EP, EK) ACCEPTED PROPOSED Vfdpxa (EK, EA) FINDER_REPORTER_VENDOR_DEPLOYER_COORDINATOR
7 (EA, EK) ACCEPTED ACTIVE Vfdpxa (EK, EV) FINDER_REPORTER_VENDOR_DEPLOYER_COORDINATOR
8 (EV, EK) ACCEPTED REVISE Vfdpxa (EK, EA) FINDER_REPORTER_VENDOR_DEPLOYER_COORDINATOR
9 (EA, EK) ACCEPTED ACTIVE Vfdpxa (EK,) FINDER_REPORTER_VENDOR_DEPLOYER_COORDINATOR
10 (CA, ET, CK, EK) ACCEPTED ACTIVE Vfdpxa (ET, CK, EK) FINDER_REPORTER_VENDOR_DEPLOYER_COORDINATOR
11 () ACCEPTED EXITED VfdpxA () FINDER_REPORTER_VENDOR_DEPLOYER_COORDINATOR
12 (CP, CK) ACCEPTED EXITED VfdpxA (CK,) FINDER_REPORTER_VENDOR_DEPLOYER_COORDINATOR
13 () ACCEPTED EXITED VfdPxA (CF,) FINDER_REPORTER_VENDOR_DEPLOYER_COORDINATOR
14 (CF, CK) ACCEPTED EXITED VFdPxA (CK,) FINDER_REPORTER_VENDOR_DEPLOYER_COORDINATOR
15 () ACCEPTED EXITED VFdPxA () FINDER_REPORTER_VENDOR_DEPLOYER_COORDINATOR
18 () ACCEPTED EXITED VFdPxA (CD,) FINDER_REPORTER_VENDOR_DEPLOYER_COORDINATOR
19 (CD, CK) ACCEPTED EXITED VFDPxA (CK, RD) FINDER_REPORTER_VENDOR_DEPLOYER_COORDINATOR
20 (RD, CA, RK, CK) DEFERRED EXITED VFDPxA (RK, CK, RC) FINDER_REPORTER_VENDOR_DEPLOYER_COORDINATOR
21 (RD, CA, RK, CK) CLOSED EXITED VFDPxA (RK, CK, RC) FINDER_REPORTER_VENDOR_DEPLOYER_COORDINATOR
The full tree is too large to display here, but you can run the demo to see it.
Demo Code
vultron.demo.vultrabot
Provides a simulated Vultron behavior tree simulator bot.
main(args)
Instantiates a CvdProtocolBt
object and runs it until either it closes or 1000 ticks have passed.
This demo is basically simulating a CVD agent coordinating a CVD case with itself.
The agent's role is set to FINDER_REPORTER_VENDOR_DEPLOYER_COORDINATOR
, which means it will
perform all the roles in the CVD case.
Messages emitted in one tick might be received later in the same tick, or in a future tick.
Tip
This demo leverages the ability to use leaf nodes as stochastic process fuzzers. Using this feature, we can simulate the behavior of a CVD agent without having to implement any actual communication mechanisms or simulate any complex real-world processes.
One interesting effect of this design is that the places where the demo uses a fuzzer node are often indicative of places where an actual bot would either need to call out to either a data source or a human to decide what to do next. This is a good example of how the Vultron behavior tree can be used to model complex reactive processes in a way that is still easy to understand and reason about.
Note
There is no underlying communication mechanism in this demo, so messages are not actually sent anywhere. Instead, they are just added to the blackboard's incoming message queue. They also have no content, and are only represented as message types.
Warning
This demo is not intended to be a fully realistic simulation of a CVD case. It is only intended to demonstrate the behavior of the Vultron behavior tree.
Source code in vultron/demo/vultrabot.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|