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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97c05c7c3c6b0316fe40d4bd20acd66189b3dc34265b45061ac87e7daabd1f15
4
- data.tar.gz: 6a5ef7dfca3096d744a005aa9e6a60c9c932b69c77c05e63d18be882d010ee44
3
+ metadata.gz: 6eb178547f7b18faf513a60dc91f785a977e5fe7e2884d77ec8f365dd37e55da
4
+ data.tar.gz: 64e1f312b7028ec33749389e8ee13329c33712d35dc85afc9a0ebe84a5edf8a2
5
5
  SHA512:
6
- metadata.gz: d1367b71529a3257493aa12ed119bb05901c5094b24042e9ee86a9ff8a1d422cd97649a7c226e6b88ad32efce17fd1d348864bd328907f0f7ecdb44279da30c8
7
- data.tar.gz: 5cdc8673bb4927e399ac6a79938114cc26bd178e7fcef71d2b04bd4986728be735c5d3f08f5e5b97557ffd85ae02e24270612e754d61e652ef573cac7e917b82
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 felovilches@gmail.com.
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- behavior_tree (1.0.0)
4
+ behavior_tree (1.1.0)
5
5
  colorize (~> 0.8.1)
6
6
 
7
7
  GEM
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 Felo Vilches
3
+ Copyright (c) 2021 Chris Vilches
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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/FeloVilches/ruby-behavior-tree/blob/main/assets/logo.png?raw=true" />
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/FeloVilches/ruby-behavior-tree/blob/main/assets/printed_tree.jpg?raw=true" width="400"/>
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/FeloVilches/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/FeloVilches/ruby-behavior-tree/blob/main/CODE_OF_CONDUCT.md).
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/FeloVilches/ruby-behavior-tree/blob/main/CODE_OF_CONDUCT.md).
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}#{class_simple_name(node)} #{status_string(node)} #{tick_count_string(node)}"
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 class_simple_name(node)
87
- pretty_name snake_case(node.class.name.split('::').last)
88
- end
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
@@ -4,6 +4,10 @@ module BehaviorTree
4
4
  module Decorators
5
5
  # Returns always failure when the child is not running.
6
6
  class ForceFailure < DecoratorBase
7
+ def display_name
8
+ 'forcefailure'
9
+ end
10
+
7
11
  protected
8
12
 
9
13
  def status_map
@@ -4,6 +4,10 @@ module BehaviorTree
4
4
  module Decorators
5
5
  # Returns always success when the child is not running.
6
6
  class ForceSuccess < DecoratorBase
7
+ def display_name
8
+ 'forcesuccess'
9
+ end
10
+
7
11
  protected
8
12
 
9
13
  def status_map
@@ -25,6 +25,10 @@ module BehaviorTree
25
25
  end
26
26
  end
27
27
 
28
+ def display_name
29
+ 'task'
30
+ end
31
+
28
32
  private
29
33
 
30
34
  attr_reader :context
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BehaviorTree
4
- VERSION = '1.0.0'
4
+ VERSION = '1.1.0'
5
5
  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.0.0
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: 2021-07-18 00:00:00.000000000 Z
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.2.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: []