behavior_tree 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CODE_OF_CONDUCT.md +1 -1
- data/Gemfile.lock +1 -1
- data/LICENSE.txt +1 -1
- data/README.md +11 -7
- data/lib/behavior_tree/concerns/tree_structure/printer.rb +10 -18
- data/lib/behavior_tree/decorator_nodes/force_failure.rb +4 -0
- data/lib/behavior_tree/decorator_nodes/force_success.rb +4 -0
- data/lib/behavior_tree/tasks/task_base.rb +4 -0
- data/lib/behavior_tree/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6eb178547f7b18faf513a60dc91f785a977e5fe7e2884d77ec8f365dd37e55da
|
4
|
+
data.tar.gz: 64e1f312b7028ec33749389e8ee13329c33712d35dc85afc9a0ebe84a5edf8a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f553d35fc13a331543cd1df25a169f20c1bbf0cf8fef526b081e5243411087cd7a0f0cdc797e59e78e83cb070a228c98cbf21fe32cd3206162f9dda1ab8b0c2
|
7
|
+
data.tar.gz: 43e2ec00bf7cc6f860dc35852853fbb7e6ae879267ca2848acd7c7c8428c7fefbf6e60ec18f4f79db53cc3bf3623528a413224324cba8f57b1b027397af471c5
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -59,7 +59,7 @@ representative at an online or offline event.
|
|
59
59
|
## Enforcement
|
60
60
|
|
61
61
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
62
|
-
reported to the community leaders responsible for enforcement at
|
62
|
+
reported to the community leaders responsible for enforcement at developer@chrisvilches.com.
|
63
63
|
All complaints will be reviewed and investigated promptly and fairly.
|
64
64
|
|
65
65
|
All community leaders are obligated to respect the privacy and security of the
|
data/Gemfile.lock
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -5,7 +5,11 @@
|
|
5
5
|
A robust and customizable Ruby gem for creating Behavior Trees, used in games, AI, robotics, and more.
|
6
6
|
|
7
7
|
<p align="center">
|
8
|
-
<img src="https://github.com/
|
8
|
+
<img src="https://github.com/ChrisVilches/ruby-behavior-tree/blob/main/assets/logo.png?raw=true" />
|
9
|
+
</p>
|
10
|
+
|
11
|
+
<p align="center">
|
12
|
+
<img src="https://github.com/ChrisVilches/ruby-behavior-tree/blob/main/assets/tree_animation.gif?raw=true" />
|
9
13
|
</p>
|
10
14
|
|
11
15
|
## Quick start
|
@@ -157,8 +161,8 @@ another_tree.print
|
|
157
161
|
* [Custom condition](#custom-condition)
|
158
162
|
- [Node API](#node-api)
|
159
163
|
* [Status](#status)
|
160
|
-
* [tick!](#tick
|
161
|
-
* [halt!](#halt
|
164
|
+
* [tick!](#tick)
|
165
|
+
* [halt!](#halt)
|
162
166
|
* [Status related callbacks and hooks](#status-related-callbacks-and-hooks)
|
163
167
|
- [Add custom nodes to the DSL](#add-custom-nodes-to-the-dsl)
|
164
168
|
- [Troubleshoot and debug your trees](#troubleshoot-and-debug-your-trees)
|
@@ -279,7 +283,7 @@ By default, there are two types of control nodes, and custom ones can be easily
|
|
279
283
|
d. If child returns `failure`, then continue with the next child.
|
280
284
|
e. If no node ever returned `success`, then return `failure`.
|
281
285
|
|
282
|
-
[Learn about "halting nodes" and what it means.](#halt
|
286
|
+
[Learn about "halting nodes" and what it means.](#halt)
|
283
287
|
|
284
288
|
When a control node is ticked, by default it traverses children and ticks them using this logic:
|
285
289
|
|
@@ -796,7 +800,7 @@ my_tree.print
|
|
796
800
|
The above code generates the following output:
|
797
801
|
|
798
802
|
<p align="center">
|
799
|
-
<img src="https://github.com/
|
803
|
+
<img src="https://github.com/ChrisVilches/ruby-behavior-tree/blob/main/assets/printed_tree.jpg?raw=true" width="400"/>
|
800
804
|
</p>
|
801
805
|
|
802
806
|
In the example above, you can see that the bottom nodes haven't been ticked at all. Node starvation might occur for various reasons, such as having a `force_failure` node as one of the children of a `sequence` (the nodes after the `force_failure` would all be prevented from executing).
|
@@ -836,7 +840,7 @@ Keep in mind this is only for development purposes, and the generated trees don'
|
|
836
840
|
|
837
841
|
## Contributing
|
838
842
|
|
839
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
843
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ChrisVilches/ruby-behavior-tree. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/ChrisVilches/ruby-behavior-tree/blob/main/CODE_OF_CONDUCT.md).
|
840
844
|
|
841
845
|
|
842
846
|
## License
|
@@ -845,4 +849,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
845
849
|
|
846
850
|
## Code of Conduct
|
847
851
|
|
848
|
-
Everyone interacting in the Behavior Tree project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
852
|
+
Everyone interacting in the Behavior Tree project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ChrisVilches/ruby-behavior-tree/blob/main/CODE_OF_CONDUCT.md).
|
@@ -7,6 +7,10 @@ module BehaviorTree
|
|
7
7
|
# Algorithm to print tree.
|
8
8
|
module Printer
|
9
9
|
def print
|
10
|
+
puts to_s
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_s
|
10
14
|
lines = []
|
11
15
|
lines << '∅' # Style for the root node.
|
12
16
|
lines += tree_lines
|
@@ -15,8 +19,7 @@ module BehaviorTree
|
|
15
19
|
lines << uniq_nodes_string
|
16
20
|
lines << size_string
|
17
21
|
lines << tree_tick_count_string
|
18
|
-
|
19
|
-
puts lines.join "\n"
|
22
|
+
lines.join "\n"
|
20
23
|
end
|
21
24
|
|
22
25
|
private
|
@@ -34,7 +37,7 @@ module BehaviorTree
|
|
34
37
|
space = (0...depth).map { |d| vertical_lines_continues.include?(d) ? '│ ' : ' ' }.join
|
35
38
|
connector = last_child ? '└─' : '├─'
|
36
39
|
|
37
|
-
"#{space}#{connector}#{
|
40
|
+
"#{space}#{connector}#{resolve_display_name(node)} #{status_string(node)} #{tick_count_string(node)}"
|
38
41
|
end
|
39
42
|
end
|
40
43
|
|
@@ -83,22 +86,11 @@ module BehaviorTree
|
|
83
86
|
.downcase
|
84
87
|
end
|
85
88
|
|
86
|
-
def
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
# Changes the name of some classes (maps it to a better name).
|
91
|
-
# Mapping is simply based on taste.
|
92
|
-
def pretty_name(name)
|
93
|
-
case name
|
94
|
-
when 'task_base'
|
95
|
-
'task'
|
96
|
-
when 'force_success'
|
97
|
-
'forcesuccess'
|
98
|
-
when 'force_failure'
|
99
|
-
'forcefailure'
|
89
|
+
def resolve_display_name(node)
|
90
|
+
if node.respond_to?(:display_name)
|
91
|
+
node.display_name
|
100
92
|
else
|
101
|
-
name
|
93
|
+
snake_case(node.class.name.split('::').last)
|
102
94
|
end
|
103
95
|
end
|
104
96
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: behavior_tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felo Vilches
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.8.1
|
27
|
-
description:
|
27
|
+
description:
|
28
28
|
email:
|
29
29
|
- felovilches@gmail.com
|
30
30
|
executables: []
|
@@ -82,7 +82,7 @@ homepage: https://github.com/FeloVilches/Ruby-Behavior-Tree
|
|
82
82
|
licenses:
|
83
83
|
- MIT
|
84
84
|
metadata: {}
|
85
|
-
post_install_message:
|
85
|
+
post_install_message:
|
86
86
|
rdoc_options: []
|
87
87
|
require_paths:
|
88
88
|
- lib
|
@@ -97,8 +97,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '0'
|
99
99
|
requirements: []
|
100
|
-
rubygems_version: 3.
|
101
|
-
signing_key:
|
100
|
+
rubygems_version: 3.3.7
|
101
|
+
signing_key:
|
102
102
|
specification_version: 4
|
103
103
|
summary: A robust and customizable Ruby gem for creating Behavior Trees.
|
104
104
|
test_files: []
|