Explorar el Código

st: 代码多余注释删除

master
SisMaker hace 4 años
padre
commit
4881967548
Se han modificado 47 ficheros con 68 adiciones y 270 borrados
  1. +1
    -1
      examples/action/action_add_rage.erl
  2. +1
    -1
      examples/action/action_become_attacking.erl
  3. +1
    -1
      examples/action/action_become_idle.erl
  4. +1
    -1
      examples/action/action_become_patrolling.erl
  5. +1
    -1
      examples/action/action_become_recovering.erl
  6. +1
    -1
      examples/action/action_collect_dest_path.erl
  7. +1
    -1
      examples/action/action_collect_path.erl
  8. +1
    -1
      examples/action/action_collect_patrol.erl
  9. +1
    -1
      examples/action/action_cost_power.erl
  10. +1
    -1
      examples/action/action_cost_rage.erl
  11. +1
    -1
      examples/action/action_del_dead_target.erl
  12. +1
    -1
      examples/action/action_died.erl
  13. +1
    -1
      examples/action/action_finish.erl
  14. +1
    -1
      examples/action/action_move_grid.erl
  15. +1
    -1
      examples/action/action_recover_power.erl
  16. +1
    -1
      examples/action/action_skill_attack.erl
  17. +1
    -1
      examples/condition/cond_is_attacking.erl
  18. +1
    -1
      examples/condition/cond_is_dest.erl
  19. +1
    -1
      examples/condition/cond_is_died.erl
  20. +1
    -1
      examples/condition/cond_is_idle.erl
  21. +1
    -1
      examples/condition/cond_is_patrolling.erl
  22. +1
    -1
      examples/condition/cond_is_power_full.erl
  23. +1
    -1
      examples/condition/cond_is_rage_full.erl
  24. +1
    -1
      examples/condition/cond_is_recovering.erl
  25. +1
    -1
      examples/condition/cond_is_target_died.erl
  26. +1
    -1
      examples/condition/cond_power_lt.erl
  27. +1
    -1
      examples/game_dict.erl
  28. +13
    -3
      include/eBhv3.hrl
  29. +1
    -1
      rebar.config
  30. +1
    -13
      src/action/error.erl
  31. +1
    -13
      src/action/failer.erl
  32. +1
    -13
      src/action/runner.erl
  33. +1
    -14
      src/action/succeeder.erl
  34. +1
    -11
      src/action/wait.erl
  35. +1
    -13
      src/composite/mem_priority.erl
  36. +1
    -13
      src/composite/mem_sequence.erl
  37. +1
    -13
      src/composite/priority.erl
  38. +1
    -13
      src/composite/sequence.erl
  39. +10
    -18
      src/core/base_node.erl
  40. +1
    -16
      src/core/behavior_tree.erl
  41. +1
    -7
      src/core/blackboard.erl
  42. +1
    -14
      src/decorator/inverter.erl
  43. +1
    -14
      src/decorator/limiter.erl
  44. +1
    -14
      src/decorator/max_time.erl
  45. +1
    -13
      src/decorator/repeat_until_failure.erl
  46. +1
    -14
      src/decorator/repeat_until_success.erl
  47. +1
    -13
      src/decorator/repeater.erl

+ 1
- 1
examples/action/action_add_rage.erl Ver fichero

@ -9,7 +9,7 @@
%%% Created : 07. 10 2020 15:13
%%%-------------------------------------------------------------------
-module(action_add_rage).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API

+ 1
- 1
examples/action/action_become_attacking.erl Ver fichero

@ -8,7 +8,7 @@
%%% Created : 07. 10 2020 15:13
%%%-------------------------------------------------------------------
-module(action_become_attacking).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API

+ 1
- 1
examples/action/action_become_idle.erl Ver fichero

@ -8,7 +8,7 @@
%%% Created : 07. 10 2020 15:13
%%%-------------------------------------------------------------------
-module(action_become_idle).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API

+ 1
- 1
examples/action/action_become_patrolling.erl Ver fichero

@ -8,7 +8,7 @@
%%% Created : 07. 10 2020 15:13
%%%-------------------------------------------------------------------
-module(action_become_patrolling).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API

+ 1
- 1
examples/action/action_become_recovering.erl Ver fichero

@ -8,7 +8,7 @@
%%% Created : 07. 10 2020 15:13
%%%-------------------------------------------------------------------
-module(action_become_recovering).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API

+ 1
- 1
examples/action/action_collect_dest_path.erl Ver fichero

@ -8,7 +8,7 @@
%%% Created : 07. 10 2020 15:13
%%%-------------------------------------------------------------------
-module(action_collect_dest_path).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API

+ 1
- 1
examples/action/action_collect_path.erl Ver fichero

@ -8,7 +8,7 @@
%%% Created : 07. 10 2020 15:13
%%%-------------------------------------------------------------------
-module(action_collect_path).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API

+ 1
- 1
examples/action/action_collect_patrol.erl Ver fichero

@ -9,7 +9,7 @@
%%% Created : 07. 10 2020 15:13
%%%-------------------------------------------------------------------
-module(action_collect_patrol).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API

+ 1
- 1
examples/action/action_cost_power.erl Ver fichero

@ -9,7 +9,7 @@
%%% Created : 07. 10 2020 15:13
%%%-------------------------------------------------------------------
-module(action_cost_power).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API

+ 1
- 1
examples/action/action_cost_rage.erl Ver fichero

@ -9,7 +9,7 @@
%%% Created : 07. 10 2020 15:13
%%%-------------------------------------------------------------------
-module(action_cost_rage).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API

+ 1
- 1
examples/action/action_del_dead_target.erl Ver fichero

@ -9,7 +9,7 @@
%%% Created : 07. 10 2020 15:13
%%%-------------------------------------------------------------------
-module(action_del_dead_target).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API

+ 1
- 1
examples/action/action_died.erl Ver fichero

@ -9,7 +9,7 @@
%%% Created : 07. 10 2020 15:13
%%%-------------------------------------------------------------------
-module(action_died).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API

+ 1
- 1
examples/action/action_finish.erl Ver fichero

@ -9,7 +9,7 @@
%%% Created : 07. 10 2020 15:13
%%%-------------------------------------------------------------------
-module(action_finish).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API

+ 1
- 1
examples/action/action_move_grid.erl Ver fichero

@ -8,7 +8,7 @@
%%% Created : 07. 10 2020 15:13
%%%-------------------------------------------------------------------
-module(action_move_grid).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API

+ 1
- 1
examples/action/action_recover_power.erl Ver fichero

@ -9,7 +9,7 @@
%%% Created : 07. 10 2020 15:13
%%%-------------------------------------------------------------------
-module(action_recover_power).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API

+ 1
- 1
examples/action/action_skill_attack.erl Ver fichero

@ -9,7 +9,7 @@
%%% Created : 07. 10 2020 15:13
%%%-------------------------------------------------------------------
-module(action_skill_attack).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API

+ 1
- 1
examples/condition/cond_is_attacking.erl Ver fichero

@ -9,7 +9,7 @@
%%% Created : 07. 10 2020 15:13
%%%-------------------------------------------------------------------
-module(cond_is_attacking).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API

+ 1
- 1
examples/condition/cond_is_dest.erl Ver fichero

@ -9,7 +9,7 @@
%%% Created : 07. 10 2020 15:18
%%%-------------------------------------------------------------------
-module(cond_is_dest).
-include("behavior3.hrl").
-include("eBhv3.hrl").
%% API
-export([tick/2]).

+ 1
- 1
examples/condition/cond_is_died.erl Ver fichero

@ -9,7 +9,7 @@
%%% Created : 07. 10 2020 15:26
%%%-------------------------------------------------------------------
-module(cond_is_died).
-include("behavior3.hrl").
-include("eBhv3.hrl").
%% API
-export([tick/2]).

+ 1
- 1
examples/condition/cond_is_idle.erl Ver fichero

@ -9,7 +9,7 @@
%%% Created : 07. 10 2020 15:13
%%%-------------------------------------------------------------------
-module(cond_is_idle).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API

+ 1
- 1
examples/condition/cond_is_patrolling.erl Ver fichero

@ -9,7 +9,7 @@
%%% Created : 07. 10 2020 15:13
%%%-------------------------------------------------------------------
-module(cond_is_patrolling).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API

+ 1
- 1
examples/condition/cond_is_power_full.erl Ver fichero

@ -9,7 +9,7 @@
%%% Created : 07. 10 2020 15:13
%%%-------------------------------------------------------------------
-module(cond_is_power_full).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API

+ 1
- 1
examples/condition/cond_is_rage_full.erl Ver fichero

@ -9,7 +9,7 @@
%%% Created : 07. 10 2020 15:18
%%%-------------------------------------------------------------------
-module(cond_is_rage_full).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API

+ 1
- 1
examples/condition/cond_is_recovering.erl Ver fichero

@ -9,7 +9,7 @@
%%% Created : 07. 10 2020 15:13
%%%-------------------------------------------------------------------
-module(cond_is_recovering).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API

+ 1
- 1
examples/condition/cond_is_target_died.erl Ver fichero

@ -9,7 +9,7 @@
%%% Created : 07. 10 2020 15:20
%%%-------------------------------------------------------------------
-module(cond_is_target_died).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API
-export([tick/2]).

+ 1
- 1
examples/condition/cond_power_lt.erl Ver fichero

@ -9,7 +9,7 @@
%%% Created : 07. 10 2020 15:20
%%%-------------------------------------------------------------------
-module(cond_power_lt).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API
-export([tick/2]).

+ 1
- 1
examples/game_dict.erl Ver fichero

@ -8,7 +8,7 @@
%%%-------------------------------------------------------------------
-module(game_dict).
-include("behavior3.hrl").
-include("eBhv3.hrl").
-include("example.hrl").
%% API

include/behavior3.hrl → include/eBhv3.hrl Ver fichero

@ -1,7 +1,17 @@
-ifndef(behavior3_h).
-define(behavior3_h, true).
-ifndef(__eBhv3_H__).
-define(__eBhv3_H__, 1).
-export_type([bt_uid/0, bt_status/0, bt_node_id/0, bt_state/0, properties/0, uninit_bt_node/0, tree_nodes/0, btree/0, bt_node/0]).
-export_type([
bt_uid/0
, bt_status/0
, bt_node_id/0
, bt_state/0
, properties/0
, uninit_bt_node/0
, tree_nodes/0
, btree/0
, bt_node/0
]).
-type bt_uid() :: reference().

+ 1
- 1
rebar.config Ver fichero

@ -3,7 +3,7 @@
]}.
{deps, [
jsx
{jsx, {git, "https://github.com/happyshiyu/jsx.git"}}
]}.
{xref_checks, [

+ 1
- 13
src/action/error.erl Ver fichero

@ -1,22 +1,10 @@
-module(error).
%%--------------------------------------------------------------------
%% include
%%--------------------------------------------------------------------
-include("behavior3.hrl").
-include("eBhv3.hrl").
%%--------------------------------------------------------------------
%% export API
%%--------------------------------------------------------------------
-export([tick/2]).
%%--------------------------------------------------------------------
%% API functions
%%--------------------------------------------------------------------
-spec tick(bt_node(), bt_state()) -> {bt_status(), bt_state()}.
tick(_BTNode, BTState) ->
{?BT_ERROR, BTState}.
%%--------------------------------------------------------------------
%% Internal functions
%%--------------------------------------------------------------------

+ 1
- 13
src/action/failer.erl Ver fichero

@ -1,22 +1,10 @@
-module(failer).
%%--------------------------------------------------------------------
%% include
%%--------------------------------------------------------------------
-include("behavior3.hrl").
-include("eBhv3.hrl").
%%--------------------------------------------------------------------
%% export API
%%--------------------------------------------------------------------
-export([tick/2]).
%%--------------------------------------------------------------------
%% API functions
%%--------------------------------------------------------------------
-spec tick(bt_node(), bt_state()) -> {bt_status(), bt_state()}.
tick(_BTNode, BTState) ->
{?BT_FAILURE, BTState}.
%%--------------------------------------------------------------------
%% Internal functions
%%--------------------------------------------------------------------

+ 1
- 13
src/action/runner.erl Ver fichero

@ -1,22 +1,10 @@
-module(runner).
%%--------------------------------------------------------------------
%% include
%%--------------------------------------------------------------------
-include("behavior3.hrl").
-include("eBhv3.hrl").
%%--------------------------------------------------------------------
%% export API
%%--------------------------------------------------------------------
-export([tick/2]).
%%--------------------------------------------------------------------
%% API functions
%%--------------------------------------------------------------------
-spec tick(bt_node(), bt_state()) -> {bt_status(), bt_state()}.
tick(_BTNode, BTState) ->
{?BT_RUNNING, BTState}.
%%--------------------------------------------------------------------
%% Internal functions
%%--------------------------------------------------------------------

+ 1
- 14
src/action/succeeder.erl Ver fichero

@ -1,22 +1,9 @@
-module(succeeder).
%%--------------------------------------------------------------------
%% include
%%--------------------------------------------------------------------
-include("behavior3.hrl").
-include("eBhv3.hrl").
%%--------------------------------------------------------------------
%% export API
%%--------------------------------------------------------------------
-export([tick/2]).
%%--------------------------------------------------------------------
%% API functions
%%--------------------------------------------------------------------
-spec tick(bt_node(), bt_state()) -> {bt_status(), bt_state()}.
tick(_BTNode, BTState) ->
{?BT_SUCCESS, BTState}.
%%--------------------------------------------------------------------
%% Internal functions
%%--------------------------------------------------------------------

+ 1
- 11
src/action/wait.erl Ver fichero

@ -1,13 +1,7 @@
-module(wait).
%%--------------------------------------------------------------------
%% include
%%--------------------------------------------------------------------
-include("behavior3.hrl").
-include("eBhv3.hrl").
%%--------------------------------------------------------------------
%% export API
%%--------------------------------------------------------------------
-export([open/2, tick/2, close/2]).
%%--------------------------------------------------------------------
@ -30,7 +24,3 @@ tick(#{id := ID, properties := #{milliseconds := EndTime}} = _BTNode, BTState) -
-spec close(bt_node(), bt_state()) -> bt_state().
close(#{id := ID} = _BTNode, BTState) ->
blackboard:remove(start_time, ID, BTState).
%%--------------------------------------------------------------------
%% Internal functions
%%--------------------------------------------------------------------

+ 1
- 13
src/composite/mem_priority.erl Ver fichero

@ -1,18 +1,9 @@
-module(mem_priority).
%%--------------------------------------------------------------------
%% include
%%--------------------------------------------------------------------
-include("behavior3.hrl").
-include("eBhv3.hrl").
%%--------------------------------------------------------------------
%% export API
%%--------------------------------------------------------------------
-export([open/2, tick/2, close/2]).
%%--------------------------------------------------------------------
%% API functions
%%--------------------------------------------------------------------
-spec open(bt_node(), bt_state()) -> bt_state().
open(#{id := ID, children := Children} = _BTNode, BTState) ->
blackboard:set(running_children, Children, ID, BTState).
@ -26,9 +17,6 @@ tick(#{id := ID} = _BTNode, BTState) ->
close(#{id := ID} = _BTNode, State) ->
blackboard:remove(running_children, ID, State).
%%--------------------------------------------------------------------
%% Internal functions
%%--------------------------------------------------------------------
tick_1([ChildID | T] = Children, ID, BTState) ->
case base_node:execute(ChildID, BTState) of
{?BT_FAILURE, BTState1} ->

+ 1
- 13
src/composite/mem_sequence.erl Ver fichero

@ -1,18 +1,9 @@
-module(mem_sequence).
%%--------------------------------------------------------------------
%% include
%%--------------------------------------------------------------------
-include("behavior3.hrl").
-include("eBhv3.hrl").
%%--------------------------------------------------------------------
%% export API
%%--------------------------------------------------------------------
-export([open/2, tick/2, close/2]).
%%--------------------------------------------------------------------
%% API functions
%%--------------------------------------------------------------------
-spec open(bt_node(), bt_state()) -> bt_state().
open(#{id := ID, children := Children} = _BTNode, BTState) ->
blackboard:set(running_children, Children, ID, BTState).
@ -26,9 +17,6 @@ tick(#{id := ID} = _BTNode, BTState) ->
close(#{id := ID} = _BTNode, BTState) ->
blackboard:remove(running_children, ID, BTState).
%%--------------------------------------------------------------------
%% Internal functions
%%--------------------------------------------------------------------
tick_1([ChildID | T] = Children, ID, BTState) ->
case base_node:execute(ChildID, BTState) of
{?BT_SUCCESS, BTState1} ->

+ 1
- 13
src/composite/priority.erl Ver fichero

@ -1,25 +1,13 @@
-module(priority).
%%--------------------------------------------------------------------
%% include
%%--------------------------------------------------------------------
-include("behavior3.hrl").
-include("eBhv3.hrl").
%%--------------------------------------------------------------------
%% export API
%%--------------------------------------------------------------------
-export([tick/2]).
%%--------------------------------------------------------------------
%% API functions
%%--------------------------------------------------------------------
-spec tick(bt_node(), bt_state()) -> {bt_status(), bt_state()}.
tick(#{children := Children} = _BTNode, BTState) ->
tick_1(Children, BTState).
%%--------------------------------------------------------------------
%% Internal functions
%%--------------------------------------------------------------------
tick_1([ChildID | T], BTState) ->
case base_node:execute(ChildID, BTState) of
{?BT_FAILURE, BTState1} ->

+ 1
- 13
src/composite/sequence.erl Ver fichero

@ -1,25 +1,13 @@
-module(sequence).
%%--------------------------------------------------------------------
%% include
%%--------------------------------------------------------------------
-include("behavior3.hrl").
-include("eBhv3.hrl").
%%--------------------------------------------------------------------
%% export API
%%--------------------------------------------------------------------
-export([tick/2]).
%%--------------------------------------------------------------------
%% API functions
%%--------------------------------------------------------------------
-spec tick(bt_node(), bt_state()) -> {bt_status(), bt_state()}.
tick(#{children := Children} = _BTNode, BTState) ->
tick_1(Children, BTState).
%%--------------------------------------------------------------------
%% Internal functions
%%--------------------------------------------------------------------
tick_1([ChildID | T], BTState) ->
case base_node:execute(ChildID, BTState) of
{?BT_SUCCESS, BTState1} ->

+ 10
- 18
src/core/base_node.erl Ver fichero

@ -1,19 +1,17 @@
-module(base_node).
-compile([inline, {inline_size, 100}]).
-include("eBhv3.hrl").
%%--------------------------------------------------------------------
%% include
%%--------------------------------------------------------------------
-include("behavior3.hrl").
-export([
execute/2
]).
%%--------------------------------------------------------------------
%% export API
%%--------------------------------------------------------------------
-export([execute/2]).
%% Internal API
-export([do_init/4, do_open/2, do_tick/2, do_close/2]).
-export([
do_init/4
, do_open/2
, do_tick/2
, do_close/2
]).
%%
-callback(init(bt_node()) -> bt_node()).
@ -29,9 +27,6 @@
-optional_callbacks([init/1, open/2, close/2]).
%%--------------------------------------------------------------------
%% API functions
%%--------------------------------------------------------------------
%% @doc
-spec execute(bt_uid(), bt_state()) -> {bt_status(), bt_state()}.
execute(NodeID, BTState) ->
@ -46,9 +41,6 @@ execute(NodeID, BTState) ->
{BTStatus, BTState3}
end.
%%--------------------------------------------------------------------
%% Internal functions
%%--------------------------------------------------------------------
%%
-spec do_init(bt_uid()|undefined, bt_node_id(), #{bt_node_id() => btree()}, tree_nodes()) -> {ok, bt_uid()}|{error, term()}.
do_init(ParentNodeID, BTNodeID, TreeMaps, TreeNodeMaps) ->

+ 1
- 16
src/core/behavior_tree.erl Ver fichero

@ -1,27 +1,15 @@
-module(behavior_tree).
-compile([inline, {inline_size, 100}]).
-include("eBhv3.hrl").
%%--------------------------------------------------------------------
%% include
%%--------------------------------------------------------------------
-include("behavior3.hrl").
%%--------------------------------------------------------------------
%% export API
%%--------------------------------------------------------------------
-export([
load_tree_file/1,
init_btree_by_title/4, init_btree/3,
execute/2, execute_child/2, close_btree_node/2, unload_btree/1
]).
%% Internal API
-export([get_btree_id_by_title/2, get_btree/2, get_btree_node/2]).
%%--------------------------------------------------------------------
%% API functions
%%--------------------------------------------------------------------
%% @doc
%%
-spec load_tree_file(file:name_all()) -> {#{string() => bt_node_id()}, #{bt_node_id() => btree()}, tree_nodes()}|{error, term()}.
@ -115,9 +103,6 @@ close_btree_node(NodeID, BTState) ->
unload_btree(NodeID) ->
do_unload_btree_node(NodeID).
%%--------------------------------------------------------------------
%% Internal functions
%%--------------------------------------------------------------------
%%
-spec parse_btree(map()) -> {#{string() => bt_node_id()}, #{bt_node_id() => btree()}, tree_nodes()}.
parse_btree(#{<<"trees">> := Trees}) ->

+ 1
- 7
src/core/blackboard.erl Ver fichero

@ -1,13 +1,7 @@
-module(blackboard).
%%--------------------------------------------------------------------
%% include
%%--------------------------------------------------------------------
-include("behavior3.hrl").
-include("eBhv3.hrl").
%%--------------------------------------------------------------------
%% export API
%%--------------------------------------------------------------------
-export([
get_btree_node/1, set_btree_node/1, erase_btree_node/1,
set_global/3, set/4,

+ 1
- 14
src/decorator/inverter.erl Ver fichero

@ -1,18 +1,9 @@
-module(inverter).
%%--------------------------------------------------------------------
%% include
%%--------------------------------------------------------------------
-include("behavior3.hrl").
-include("eBhv3.hrl").
%%--------------------------------------------------------------------
%% export API
%%--------------------------------------------------------------------
-export([tick/2]).
%%--------------------------------------------------------------------
%% API functions
%%--------------------------------------------------------------------
-spec tick(bt_node(), bt_state()) -> {bt_status(), bt_state()}.
tick(#{children := [ChildID]} = _BTNode, BTState) ->
case base_node:execute(ChildID, BTState) of
@ -25,7 +16,3 @@ tick(#{children := [ChildID]} = _BTNode, BTState) ->
end;
tick(_BTNode, BTState) ->
{?BT_ERROR, BTState}.
%%--------------------------------------------------------------------
%% Internal functions
%%--------------------------------------------------------------------

+ 1
- 14
src/decorator/limiter.erl Ver fichero

@ -1,18 +1,9 @@
-module(limiter).
%%--------------------------------------------------------------------
%% include
%%--------------------------------------------------------------------
-include("behavior3.hrl").
-include("eBhv3.hrl").
%%--------------------------------------------------------------------
%% export API
%%--------------------------------------------------------------------
-export([open/2, tick/2, close/2]).
%%--------------------------------------------------------------------
%% API functions
%%--------------------------------------------------------------------
-spec open(bt_node(), bt_state()) -> bt_state().
open(#{id := ID} = _BTNode, BTState) ->
blackboard:set(i, 0, ID, BTState).
@ -37,7 +28,3 @@ tick(_BTNode, BTState) ->
-spec close(bt_node(), bt_state()) -> bt_state().
close(#{id := ID} = _BTNode, BTState) ->
blackboard:remove(i, ID, BTState).
%%--------------------------------------------------------------------
%% Internal functions
%%--------------------------------------------------------------------

+ 1
- 14
src/decorator/max_time.erl Ver fichero

@ -1,18 +1,9 @@
-module(max_time).
%%--------------------------------------------------------------------
%% include
%%--------------------------------------------------------------------
-include("behavior3.hrl").
-include("eBhv3.hrl").
%%--------------------------------------------------------------------
%% export API
%%--------------------------------------------------------------------
-export([open/2, tick/2, close/2]).
%%--------------------------------------------------------------------
%% API functions
%%--------------------------------------------------------------------
-spec open(bt_node(), bt_state()) -> bt_state().
open(#{id := ID} = _BTNode, BTState) ->
blackboard:set(start_time, erlang:system_time(millisecond), ID, BTState).
@ -33,7 +24,3 @@ tick(_BTNode, BTState) ->
-spec close(bt_node(), bt_state()) -> bt_state().
close(#{id := ID} = _BTNode, BTState) ->
blackboard:remove(start_time, ID, BTState).
%%--------------------------------------------------------------------
%% Internal functions
%%--------------------------------------------------------------------

+ 1
- 13
src/decorator/repeat_until_failure.erl Ver fichero

@ -1,18 +1,9 @@
-module(repeat_until_failure).
%%--------------------------------------------------------------------
%% include
%%--------------------------------------------------------------------
-include("behavior3.hrl").
-include("eBhv3.hrl").
%%--------------------------------------------------------------------
%% export API
%%--------------------------------------------------------------------
-export([open/2, tick/2, close/2]).
%%--------------------------------------------------------------------
%% API functions
%%--------------------------------------------------------------------
-spec open(bt_node(), bt_state()) -> bt_state().
open(#{id := ID} = _BTNode, BTState) ->
blackboard:set(i, 0, ID, BTState).
@ -30,9 +21,6 @@ tick(_BTNode, BTState) ->
close(#{id := ID} = _BTNode, BTState) ->
blackboard:remove(i, ID, BTState).
%%--------------------------------------------------------------------
%% Internal functions
%%--------------------------------------------------------------------
tick_1(MaxLoop, I, ChildID, _BTStatus, BTState) when MaxLoop < 0 orelse I < MaxLoop ->
case base_node:execute(ChildID, BTState) of
{?BT_SUCCESS, BTState1} ->

+ 1
- 14
src/decorator/repeat_until_success.erl Ver fichero

@ -1,19 +1,9 @@
-module(repeat_until_success).
-include("eBhv3.hrl").
%%--------------------------------------------------------------------
%% include
%%--------------------------------------------------------------------
-include("behavior3.hrl").
%%--------------------------------------------------------------------
%% export API
%%--------------------------------------------------------------------
-export([open/2, tick/2, close/2]).
%%--------------------------------------------------------------------
%% API functions
%%--------------------------------------------------------------------
-spec open(bt_node(), bt_state()) -> bt_state().
open(#{id := ID} = _BTNode, BTState) ->
blackboard:set(i, 0, ID, BTState).
@ -31,9 +21,6 @@ tick(_BTNode, BTState) ->
close(#{id := ID} = _BTNode, BTState) ->
blackboard:remove(i, ID, BTState).
%%--------------------------------------------------------------------
%% Internal functions
%%--------------------------------------------------------------------
tick_1(MaxLoop, I, ChildID, _BTStatus, BTState) when MaxLoop < 0 orelse I < MaxLoop ->
case base_node:execute(ChildID, BTState) of
{?BT_FAILURE, BTBTState1} ->

+ 1
- 13
src/decorator/repeater.erl Ver fichero

@ -1,18 +1,9 @@
-module(repeater).
%%--------------------------------------------------------------------
%% include
%%--------------------------------------------------------------------
-include("behavior3.hrl").
-include("eBhv3.hrl").
%%--------------------------------------------------------------------
%% export API
%%--------------------------------------------------------------------
-export([open/2, tick/2, close/2]).
%%--------------------------------------------------------------------
%% API functions
%%--------------------------------------------------------------------
-spec open(bt_node(), bt_state()) -> bt_state().
open(#{id := ID} = _BTNode, BTState) ->
blackboard:set(i, 0, ID, BTState).
@ -30,9 +21,6 @@ tick(_BTNode, BTState) ->
close(#{id := ID} = _BTNode, BTState) ->
blackboard:remove(i, ID, BTState).
%%--------------------------------------------------------------------
%% Internal functions
%%--------------------------------------------------------------------
tick_1(MaxLoop, I, ChildID, _BTStatus, BTState) when MaxLoop < 0 orelse I < MaxLoop ->
case base_node:execute(ChildID, BTState) of
{BTStatus, BTState1} when BTStatus =:= ?BT_SUCCESS; BTStatus =:= ?BT_FAILURE ->

Cargando…
Cancelar
Guardar