geronimo-iia / async-btree Goto Github PK
View Code? Open in Web Editor NEWAsync behavior tree for python
Home Page: https://geronimo-iia.github.io/async-btree/
License: Other
Async behavior tree for python
Home Page: https://geronimo-iia.github.io/async-btree/
License: Other
Describe the bug
I am sure I missed something... I tried to extend the example and add a decision node together with the context. The data in the context is correct and the condition is evaluated - however, the success (or failiure) function is not executed.
Code to Reproduce
import curio
import async_btree as bt
import contextvars
def some_action():
print("continue here...")
async def say_hello(name: str):
print(f"Hello: {name}")
def is_name_set():
print("current name is " + name.get())
return name.get() != ""
name = contextvars.ContextVar('name',default="")
greet_with_name = bt.decision(is_name_set,
bt.always_success(child=bt.action(target=say_hello, name=name.get()))
)
b_tree = bt.sequence(
children=[
greet_with_name,
bt.always_success(child=bt.action(target=some_action)),
]
)
if __name__ == '__main__':
name = contextvars.ContextVar('name')
name.set("Hans")
curio.run(b_tree)
abstract_tree_tree_1 = bt.analyze(b_tree)
# output the tree:
print(bt.stringify_analyze(abstract_tree_tree_1))
Expected behavior
The decision node should evaluate the success_tree / failure_tree methods.
Thank you in advance.
Feature Request, documentation:
The documentation does not appear to have
a link to the source on github. It's convenient to be able to find the source. Thanks.
Study how we can use sync or async function in action and condition in order to simplify usage
todo:
This may be implemented or contrary to your design goals, so feel free to ignore it.
Behavior Tree is a well known Behavior Tree package. That project uses XML to define the tree. The source c++ relies on extending base classes. This allows easy re-use of the logic.
From the async-btree documentation is appears the python functions are decorated directly with the tree. If so, it may be practical to abstract them from each other.
I am running a bunch of decisions in a sequence. Each decision only checks a condition and executes a function if the condition is true. If the decision has no failure tree and the condition fails, the decision will be return failure and stop the execution of the sequence.
I solved this issue for me with this "hack". This way the decision will be successful if the condition fails.
some_decision = bt.decision(condition=i_fail,
success_tree=bt.always_success(some_action),
failure_tree=bt.always_success(lambda x: True)
)
The question is: Should a missing failure_tree result in a failing decision? Since there is no action that actually failed, the default could be also "success".
Describe the bug
Travis error on make install
Expected behavior
aim a successful travis make install
Additional context
Setting settings.virtualenvs.in-project does not exist
-> remove use of this config entry
import curio
import async_btree as bt
def div_zero():
1/0
result = curio.run(bt.action(div_zero))
assert result is not None
curio run normaly and return None, but I except it panic !
The code panic and report trackstack rather than normal running.
When appropriate, I suggest you could re-create the first tutorial on BehaviorTree using async-btree
. I am far too new to the package, but I have included my attempt here.
import async_btree as bt
print("Btreeeeeeee!!!")
async def approach_object():
"""
A basic node that seems to always accomplish what it sets out to do.
:return: async_btree.SUCCESS
"""
return bt.SUCCESS
#async def approach_tree(child_value, other=""):
async def approach_tree():
"""
Create the tree within Python using existing functions
:return: bt.sequence()
"""
status = approach_object()
await status
return bt.sequence(children=[approach_object()], succes_threshold=2)
if __name__=="__main__":
print("Attempting approach")
seq = approach_tree()
I know this is wrong and I will attempt to fix it. I do think a good example on the doc site would be useful.
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.