Skip to content

Commit 675186f

Browse files
committed
Initial commit.
0 parents  commit 675186f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2098
-0
lines changed

.gitignore

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
5+
# C extensions
6+
*.so
7+
8+
# Distribution / packaging
9+
.Python
10+
env/
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
*.egg-info/
23+
.installed.cfg
24+
*.egg
25+
26+
# PyInstaller
27+
# Usually these files are written by a python script from a template
28+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
29+
*.manifest
30+
*.spec
31+
32+
# Installer logs
33+
pip-log.txt
34+
pip-delete-this-directory.txt
35+
36+
# Unit test / coverage reports
37+
htmlcov/
38+
.tox/
39+
.coverage
40+
.coverage.*
41+
.cache
42+
nosetests.xml
43+
coverage.xml
44+
*,cover
45+
46+
# Translations
47+
*.mo
48+
*.pot
49+
50+
# Django stuff:
51+
*.log
52+
53+
# Sphinx documentation
54+
docs/_build/
55+
56+
# PyBuilder
57+
target/

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Renato de Pontes Pereira
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# BEHAVIOR3PY
2+
3+
This is the official python version of the Behavior3 library, originally written in Javascript.
4+
5+
- Info: http://behavior3.com
6+
7+
NOTE: this version still lacks specific documentation, but almost everything you need can be dig from the javascript-version.
8+
9+
10+
## Main features
11+
12+
- Based on the work of [(Marzinotto et al., 2014)](http://www.csc.kth.se/~miccol/Michele_Colledanchise/Publications_files/2013_ICRA_mcko.pdf), in which they propose a **formal**, **consistent** and **general** definition of Behavior Trees;
13+
14+
- **Optimized to control multiple agents**: you can use a single behavior tree instance to handle hundreds of agents;
15+
16+
- It was **designed to load and save trees in a JSON format**, in order to use, edit and test it in multiple environments, tools and languages;
17+
18+
- A **cool visual editor** which you can access online;
19+
20+
- Several **composite, decorator and action nodes** available within the library. You still can define your own nodes, including composites and decorators;
21+
22+
- **Completely free**, the core module and the visual editor are all published under the MIT License, which means that you can use them for your open source and commercial projects;
23+
24+
- **Lightweight**!

b3/__init__.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
VERSION = '0.1.0'
2+
3+
SUCCESS = 1
4+
FAILURE = 2
5+
RUNNING = 3
6+
ERROR = 4
7+
8+
COMPOSITE = 'composite'
9+
DECORATOR = 'decorator'
10+
ACTION = 'action'
11+
CONDITION = 'condition'
12+
13+
# CORE
14+
from b3.core.tick import Tick
15+
from b3.core.basenode import BaseNode
16+
from b3.core.blackboard import Blackboard
17+
from b3.core.behaviortree import BehaviorTree
18+
from b3.core.composite import Composite
19+
from b3.core.decorator import Decorator
20+
from b3.core.action import Action
21+
from b3.core.condition import Condition
22+
23+
# COMPOSITES
24+
from b3.composites.sequence import Sequence
25+
from b3.composites.priority import Priority
26+
from b3.composites.mempriority import MemPriority
27+
from b3.composites.memsequence import MemSequence
28+
29+
# ACTIONS
30+
from b3.actions.succeeder import Succeeder
31+
from b3.actions.failer import Failer
32+
from b3.actions.runner import Runner
33+
from b3.actions.error import Error
34+
from b3.actions.wait import Wait
35+
36+
# DECORATORS
37+
from b3.decorators.inverter import Inverter
38+
from b3.decorators.limiter import Limiter
39+
from b3.decorators.maxtime import MaxTime
40+
from b3.decorators.repeater import Repeater
41+
from b3.decorators.repeatuntilfailure import RepeatUntilFailure
42+
from b3.decorators.repeatuntilsuccess import RepeatUntilSuccess
43+

b3/actions/__init__.py

Whitespace-only changes.

b3/actions/error.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import b3
2+
3+
__all__ = ['Error']
4+
5+
class Error(b3.Action):
6+
def tick(self, tick):
7+
return b3.ERROR;

b3/actions/failer.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import b3
2+
3+
__all__ = ['Failer']
4+
5+
class Failer(b3.Action):
6+
def tick(self, tick):
7+
return b3.FAILURE;

b3/actions/runner.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import b3
2+
3+
__all__ = ['Runner']
4+
5+
class Runner(b3.Action):
6+
def tick(self, tick):
7+
return b3.RUNNING;

b3/actions/succeeder.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import b3
2+
3+
__all__ = ['Succeeder']
4+
5+
class Succeeder(b3.Action):
6+
def tick(self, tick):
7+
return b3.SUCCESS;

b3/actions/wait.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import b3
2+
import time
3+
4+
__all__ = ['Wait']
5+
6+
class Wait(b3.Action):
7+
def __init__(self, milliseconds=0):
8+
super(Wait, self).__init__()
9+
self.end_time = milliseconds/1000.
10+
11+
def open(self, tick):
12+
start_time = time.time()
13+
tick.blackboard.set('start_time', start_time, tick.tree.id, self.id)
14+
15+
def tick(self, tick):
16+
curr_time = time.time()
17+
start_time = tick.blackboard.get('start_time', tick.tree.id, self.id)
18+
19+
if (curr_time-start_time > self.end_time):
20+
return b3.SUCCESS
21+
22+
return b3.RUNNING

0 commit comments

Comments
 (0)