behavior3行为树
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

74 wiersze
1.6 KiB

  1. -ifndef(__eBhv3_H__).
  2. -define(__eBhv3_H__, 1).
  3. -export_type([
  4. bt_uid/0
  5. , bt_status/0
  6. , bt_node_id/0
  7. , bt_state/0
  8. , properties/0
  9. , uninit_bt_node/0
  10. , tree_nodes/0
  11. , btree/0
  12. , bt_node/0
  13. ]).
  14. -type bt_uid() :: reference().
  15. -define(BT_SUCCESS, 1).
  16. -define(BT_FAILURE, 2).
  17. -define(BT_RUNNING, 3).
  18. -define(BT_ERROR, 4).
  19. -type bt_status() :: ?BT_SUCCESS|?BT_FAILURE|?BT_RUNNING|?BT_ERROR.
  20. -type bt_node_id() :: string().
  21. -type bt_state() :: #{
  22. '$global_maps' => map(),
  23. '$local_maps' => map(),
  24. term() => term()
  25. }.
  26. -type properties() :: #{atom() => term()}.
  27. %% 未初始化的树节点
  28. -type uninit_bt_node() :: #{
  29. id => bt_node_id(),
  30. name => atom() | bt_node_id(),
  31. category => atom(),
  32. properties => properties(),
  33. children => [bt_node_id()]
  34. }.
  35. -type tree_nodes() :: #{bt_node_id() => uninit_bt_node()}.
  36. %% 行为树
  37. -type btree() :: #{
  38. id => bt_node_id(),
  39. root => bt_node_id(),
  40. properties => properties(),
  41. tree_nodes => tree_nodes()
  42. }.
  43. %% 行为树节点
  44. -type bt_node() :: #{
  45. id := bt_uid(),
  46. bt_node_id := bt_node_id(),
  47. parent_id := bt_uid(),
  48. name := atom(),
  49. category := atom(),
  50. properties := properties(),
  51. children := [bt_uid()]
  52. }.
  53. -define(BI_MOD_LIST, [
  54. error, failer, runner, succeeder, wait,
  55. mem_priority, mem_sequence, priority, sequence,
  56. inverter, limiter, max_time, repeat_until_failure, repeat_until_success, repeater
  57. ]).
  58. -define(BT_LOG(Format), io:format("~w:~w:~w [debug] ~p: " ++ Format ++ "~n", tuple_to_list(time()) ++ [?MODULE])).
  59. -define(BT_LOG(Format, Args), io:format("~w:~w:~w [debug] ~p: " ++ Format ++ "~n", tuple_to_list(time()) ++ [?MODULE | Args])).
  60. -endif.