eykd / owyl Goto Github PK
View Code? Open in Web Editor NEWA python behavior tree for implementing fast and flexible AI.
License: BSD 3-Clause "New" or "Revised" License
A python behavior tree for implementing fast and flexible AI.
License: BSD 3-Clause "New" or "Revised" License
================= Welcome to Owyl! ================= You have Pyglet. You've got Rabbyt. But who do your sprites go to for advice? Owyl, of course. Goals ===== The goal of Owyl: provide a fast and flexible Behavior Tree library implemented in python. Owyl trees use nested generators to iterate through your behaviors. The root of the tree always works just like a normal python iterator. If you know how to work with iterators, you know how to work with an Owyl tree. Because Owyl is small and behavior trees are easy to grasp, it's easy to control and extend your AI behaviors. Trees as Iterators ================== Trees as iterators give you total control over how a behavior tree integrates with your code: use a for loop, a list comprehension, a generator expression, or manual calls to tree.next(). Run the tree one step, five, or fifty with every frame. Extending ========= Writing new behaviors is simple and easy (and soon to be documented!). Any object that corresponds to python's iterator interface and a few simple rules for yielded values will work. Owyl's core behaviors are written as simple generator functions. More information ================ For more information on Behavior Trees, see [http://aigamedev.com/hierarchical-logic these articles]. Remember: AI isn't about math, it's about getting things done. Owyl has been tested on python 2.5. It will probably work on 2.6. It definitely WILL NOT work on 2.4 without adaptation. Please let me know if you have any trouble with it. David Eyk [email protected] Installation ============ See INSTALL. Documentation ============= API documentation can be found at <http://worlds.eykd.net/owyl/api/>. For more information about Owyl, please visit the project site at <http://code.google.com/p/owyl/>. Problems? Questions? ==================== If you run into trouble, or have a question, visit the discussion group at <http://groups.google.com/group/owyl-discuss/>.
Running an Owyl tree and something else concurrently in the same application is only possible with threading right now.
There is a safer and more modern alternative - asyncio, which is in the standard library. Lots of libraries are already compatible with it. This can also be a good time to upgrade Owyl to Python3.
It helps a lot that Asyncio's code patterns are very similar to Owyl's:
@owyl.parent_task
def sequence(*children, **kwargs):
final_value = True
for child in children:
result = yield child(**kwargs)
if not result and result is not None:
final_value = False
break
yield final_value
@asyncio.coroutine
def sequence(*children, **kwargs):
for coroutine in children:
result = yield from coroutine(**kwargs)
if not result:
return False
return True
This is not an issue, but an FYI.
The #2 PR appears to have dredged up a bunch of problems. In mucking around with parallel
I've realized that sequence
and selector
leak child return values:
tree = owyl.sequence(owyl.succeed(),
owyl.succeed(),
owyl.fail(),
owyl.succeed())
v = owyl.visit(tree)
results = [x for x in v if x is not None]
self.assertEqual(results, [True, True, False, False])
See how the succeed()
/succeed()
/fail()
leaks out to the results? The first three results are from the sequence
children, while the 4th result is the sequence
itself failing.
It's been a few years since I designed this library, but I can't think for the life of me why they would do that. Do any of you using owyl depend on this behavior?
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.