{"id":14026,"date":"2015-06-26T12:40:58","date_gmt":"2015-06-26T03:40:58","guid":{"rendered":"http:\/\/labs.gree.jp\/blog\/?p=14026"},"modified":"2015-06-26T12:42:02","modified_gmt":"2015-06-26T03:42:02","slug":"%e3%82%b7%e3%83%b3%e3%83%97%e3%83%ab%e3%81%aabehaviour-tree%e3%82%92%e5%ae%9f%e8%a3%85%e3%81%97%e3%81%a6%e3%81%bf%e3%82%8b","status":"publish","type":"post","link":"https:\/\/labs.gree.jp\/blog\/2015\/06\/14026\/","title":{"rendered":"\u30b7\u30f3\u30d7\u30eb\u306aBehaviour Tree\u3092\u5b9f\u88c5\u3057\u3066\u307f\u308b"},"content":{"rendered":"<p>\u307f\u306a\u3055\u307e\u3053\u3093\u3070\u3093\u306f\u3002\u3061\u3087\u3073\u3048\u3067\u3059\u3002<br \/>\n\u4eca\u65e5\u306f\u3061\u3087\u3063\u3068\u8da3\u5411\u3092\u5909\u3048\u3066\u30b2\u30fc\u30e0\u306eAI\u306e\u52c9\u5f37\u3001\u306a\u304b\u3067\u3082Behaviour Tree\u306b\u3064\u3044\u3066\u3059\u3053\u3057\u52c9\u5f37\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<h1>\u30b2\u30fc\u30e0\u306e\u4e16\u754c\u306eAI\u3063\u3066\u306a\u3093\u3060\u3063\u3051\uff1f<\/h1>\n<p>\u30b2\u30fc\u30e0\u306e\u4e16\u754c\u306eAI\u3068\u3044\u3048\u3070\u3088\u304f\u3042\u308b\u7d4c\u8def\u63a2\u7d22\u3084\u3001\u7279\u5b9a\u72b6\u6cc1\u4e0b\u306b\u304a\u3051\u308bNPC\u7b49\u306e\u3075\u308b\u307e\u3044\u3092\u3088\u3057\u306a\u306b\u3084\u3063\u3066\u304f\u308c\u308b\u3088\u3046\u306a\u3082\u306e\u3067\u3059\u3002AI\u3063\u3066\u3044\u308f\u308c\u3066\u3057\u307e\u3046\u3068\u306a\u3093\u3060\u304b\u96e3\u3057\u3044\u3088\u3046\u306b\u611f\u3058\u3066\u3057\u307e\u3044\u307e\u3059\u304c\u3001\u30b2\u30fc\u30e0\u3068\u3044\u3046\u67a0\u7d44\u307f\u306e\u4e2d\u3067\u306f\u6642\u9593\u7d4c\u904e\u3084\u74b0\u5883\u306e\u5909\u5316\u3092\u81ea\u7acb\u3057\u3066\u5224\u65ad\u3057\u305f\u308a\u30fb\u5224\u65ad\u3057\u3066\u308b\u3088\u3046\u306b\u307f\u305b\u304b\u3051\u3066\u697d\u3057\u3081\u308b\u3088\u3046\u306a\u4ed5\u7d44\u307f\u3068\u306a\u3063\u3066\u3044\u308c\u3070\u826f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h1>Behaviour Tree\u306b\u30c1\u30e3\u30ec\u30f3\u30b8\u3057\u3066\u307f\u308b<\/h1>\n<p>\u7d30\u304b\u3044\u8aac\u660e\u306f\u30b0\u30b0\u3063\u3066\u3044\u305f\u3060\u304f\u3068\u8272\u3005\u3068\u8a18\u8f09\u3042\u308b\u306e\u3067\u306a\u3093\u3068\u306a\u304f\u30d3\u30d8\u30a4\u30d3\u30a2\u30c4\u30ea\u30fc\u3063\u3066\u308f\u304b\u308b\u3088\u3046\u306a\u3001\u3046\u30fc\u3093\u30fb\u30fb\u30fb\u6587\u7ae0\u3067\u66f8\u304b\u308c\u3066\u3082\u3088\u304f\u308f\u304b\u3089\u306a\u3044\u3067\u3059\u306d\uff01\u3068\u3044\u3046\u3053\u3068\u3067\u304a\u6c7a\u307e\u308a\u306e\u901a\u308a\u30b3\u30fc\u30c9\u3067\u66f8\u3044\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u3044\u304d\u306a\u308a\u30b3\u30fc\u30c9\u66f8\u3044\u3066\u3082\u307e\u3063\u305f\u304f\u308f\u304b\u3089\u306a\u3044\u306e\u3067\u3056\u3063\u304f\u308a\u306a\u8aac\u660e\u3092\u3057\u307e\u3059\u3068\u3001Behaviour Tree\u306f\u6728\u69cb\u9020\u3067\u30ce\u30fc\u30c9\u3068\u30ea\u30fc\u30d5\u3067\u30eb\u30fc\u30eb\u3068\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u8a55\u4fa1\u30fb\u5b9f\u884c\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u30ce\u30fc\u30c9\u306e\u7a2e\u985e\u3068\u3057\u3066\u306f\u5927\u304d\u304f\u5206\u3051\u3066Selector\u3068Sequencer\u3068\u3044\u30462\u3064\u306e\u7a2e\u985e\u304c\u3042\u308b\u3088\u3046\u3067\u3059\u3002\u304a\u304a\u307e\u304b\u306b\u8aac\u660e\u3059\u308b\u3068<\/p>\n<ul>\n<li>Selector\u306f\u30ea\u30fc\u30d5\u304c\u6210\u529f\u3059\u308b\u307e\u3067\u4e0b\u4f4d\u30ce\u30fc\u30c9\u3092\u5b9f\u884c\u3057\u7d9a\u3051\u308b\u3002<\/li>\n<li>Sequencer\u306f\u30ea\u30fc\u30d5\u304c\u6210\u529f\u3057\u7d9a\u3051\u308b\u304b\u7d42\u7aef\u306b\u884c\u304f\u307e\u3067\u4e0b\u4f4d\u30ce\u30fc\u30c9\u3092\u5b9f\u884c\u3057\u7d9a\u3051\u308b\u3002<\/li>\n<\/ul>\n<p>\u3068\u3001\u3044\u3046\u3053\u3068\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u3068\u308a\u3042\u3048\u305a\u5b9f\u88c5\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u304b\u3002<\/p>\n<h2>\u307e\u305a\u306f\u6700\u5c0f\u3067\u5b9f\u88c5\u3057\u3066\u307f\u3088\u3046<\/h2>\n<p>\u9069\u5f53\u306a\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u3068\u304d\u306b\u306f\u3084\u3063\u3071\u308aPHP\u4fbf\u5229\u306a\u306e\u3067PHP\u3067\u304b\u3044\u3066\u307f\u307e\u3059\u3002<br \/>\nTree\u307e\u3067\u8003\u3048\u308b\u3068\u5c11\u3057\u9577\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u306e\u3067\u3001\u307e\u305a\u306f\u5404\u30ce\u30fc\u30c9\u306e\u3075\u308b\u307e\u3044\u3092\u306a\u3093\u3068\u306a\u304f\u66f8\u3044\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u30ce\u30fc\u30c9\u306e\u7d50\u679c\u304ctrue\u3067\u3042\u308c\u3070\u6210\u529f\u3001false\u3067\u3042\u308c\u3070\u5931\u6557\u3068\u3044\u3046\u3053\u3068\u306b\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<h3>\u5358\u7d14\u306aSelector<\/h3>\n<p>Selector\u306f\u81ea\u8eab\u304c\u6301\u3063\u3066\u3044\u308b\u30ce\u30fc\u30c9\u3092\u6210\u529f\u3057\u7d9a\u3051\u308b\u307e\u3067\u8a55\u4fa1\u3057\u3066\u3044\u304f\u30ce\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<pre class=\"lang:php decode:true \" >&lt;?php\n\n$selector = array();\n$selector[] = function() {echo \"Hello\"; return false;};\n$selector[] = function() {echo \"World\"; return true;};\n\nforeach ($selector as $node) {\n  if ($node()) {\n     echo PHP_EOL;\n     exit;\n  }\n  echo \" \";\n}<\/pre>\n<p>Hello\u306b\u5931\u6557\u3057\u3066\u3057\u307e\u3063\u3066\u3044\u308b\u306e\u3067\u3001World\u304c\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<\/p>\n<h3>\u5358\u7d14\u306aSequencer<\/h3>\n<p>Sequencer\u306f\u81ea\u8eab\u304c\u6301\u3063\u3066\u3044\u308b\u30ce\u30fc\u30c9\u3092\u5931\u6557\u3059\u308b\u307e\u3067\u8a55\u4fa1\u3057\u3066\u3044\u304f\u30ce\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<pre class=\"lang:php decode:true \" >&lt;?php\n\n$sequencer= array();\n$sequencer[] = function() {echo \"Hello\"; return true;};\n$sequencer[] = function() {echo \"World\"; return false;};\n$sequencer[] = function() {echo \"Chobie\"; return true;};\n\nforeach ($sequenceras $node) {\n  if (!$node()) {\n     echo PHP_EOL;\n     exit;\n  }\n  echo \" \";\n}<\/pre>\n<p>\u4e0a\u8a18\u306e\u4f8b\u3067\u306fWorld\u3067\u5931\u6557\u3057\u3066\u3044\u308b\u306e\u3067Chobie\u307e\u3067\u5b9f\u884c\u3055\u308c\u3066\u3044\u306a\u3044\u306e\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n<h2>\u7d44\u307f\u5408\u308f\u305b<\/h2>\n<p>\u4eca\u306e\u5b9f\u88c5\u3060\u3068\u6728\u69cb\u9020\u304c\u4f5c\u308c\u306a\u3044\u306e\u3067\u3068\u3066\u3082\u5358\u7d14\u306a\u30bf\u30b9\u30af\u3057\u304b\u3067\u304d\u307e\u305b\u3093\u3002<br \/>\n\u3068\u308a\u3042\u3048\u305a\u306eTree\u69cb\u9020\u304c\u53d6\u308c\u308b\u3088\u3046\u306b\u3001\u5b9f\u88c5\u306e\u697d\u3055\u512a\u5148\u3067\u66f8\u3044\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u3068\u308a\u3042\u3048\u305a\u5404\u30ea\u30fc\u30d5\u3067Hello,World,I,am,chobie\u3068\u3044\u3046\u5358\u8a9e\u3060\u3051\u3092\u51fa\u529b\u3067\u304d\u308b\u3088\u3046\u306b\u66f8\u3044\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre class=\"lang:php decode:true \" >&lt;?php\nclass Action {\n     public $cb;\n     function __construct($cb) {$this-&gt;cb = $cb;}\n     function __invoke() {$cb = $this-&gt;cb;return $cb();}\n}\nclass Base {\n     public $array = array();\n     static function Create() {return new Selector();}\n     function Add($node) {$this-&gt;array[] = $node;return $this;}    \n}\nclass Selector extends Base {\n     function __invoke() {\n          foreach ($this-&gt;array as $node) {\n               if ($node()) {\n                    echo PHP_EOL;\n                    return true;\n               }\n               echo \" \";\n          }\n          return false;\n     }\n}\nclass Sequencer extends Base {\n     function __invoke() {\n          foreach ($this-&gt;array as $node) {\n               if (!$node()) {\n                    echo PHP_EOL;\n                    return false;\n               }\n               echo \" \";\n          }\n          return true;\n     }\n}\n\n$selector = new Selector();\n$selector-&gt;Add(Selector::Create()\n     -&gt;Add(new Action(function() {echo \"Hello\"; return false;}))\n     -&gt;Add(new Action(function() {echo \"World\"; return false;}))\n);\n$selector-&gt;Add(Selector::Create()\n     -&gt;Add(new Action(function() {echo \"I\"; return false;}))\n     -&gt;Add(new Action(function() {echo \"am\"; return false;}))\n     -&gt;Add(new Action(function() {echo \"chobie\"; return true;})) \/\/ \u3053\u3053\u307e\u3067\u3067\u304a\u308f\u308d\u3046\uff01\n     -&gt;Add(new Action(function() {echo \"san\"; return false;}))\n);\n$selector-&gt;Add(Selector::Create()\n     -&gt;Add(new Action(function() {echo \"Nyaaan\"; return false;})) \/\/ \u3053\u308c\u306f\u5b9f\u884c\u3055\u308c\u306a\u3044\n);\n$selector();<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3057\u3066\u307f\u308b\u3068<\/p>\n<pre><code>Hello World  I am chobie\n<\/code><\/pre>\n<p>\u671f\u5f85\u901a\u308a\u5b9f\u884c\u51fa\u6765\u307e\u3057\u305f\u306d\uff01\u56f3\u3067\u66f8\u3044\u3066\u307f\u308b\u3068\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2015\/06\/behaviour_tree_chobie2-600x194.jpg\" alt=\"behaviour_tree_chobie2\" width=\"600\" height=\"194\" class=\"alignnone size-medium wp-image-14035\" srcset=\"https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2015\/06\/behaviour_tree_chobie2-600x194.jpg 600w, https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2015\/06\/behaviour_tree_chobie2-276x89.jpg 276w, https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2015\/06\/behaviour_tree_chobie2.jpg 741w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>\u6570\u5b57\u306f\u8a55\u4fa1\u9806\u3002\u8d64\u3044\u67a0\u306ftrue\u3092\u8fd4\u3057\u3066\u3044\u308b\uff08\u6210\u529f\u3057\u3066\u3044\u308b\uff09\u3001\u7070\u8272\u306f\u5b9f\u884c\u3055\u308c\u3066\u3044\u306a\u3044\u3001\u9ed2\u8272\u306f\u5931\u6557\u3092\u8868\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u4eca\u56de\u306fSelector\u3060\u3051\u3067\u7d44\u3093\u3067\u3044\u308b\u306e\u3067\u3001\u5931\u6557\u3057\u3066\u307b\u3057\u3044\u30ce\u30fc\u30c9\u3092\u5148\u306b\u6301\u3063\u3066\u304d\u3066\u304a\u3044\u3066\u8abf\u7bc0\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4e0a\u8a18\u4f8b\u3067\u306f\u5b9f\u884c\u6761\u4ef6\u30c1\u30a7\u30c3\u30af\u304c\u306a\u304f\u3001\u5b9f\u969b\u306e\u884c\u52d5\u3068\u3054\u3063\u3061\u3083\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u304c\u4f8b\u3048\u3070\u3053\u3093\u306a\u98a8\u306b\u66f8\u3044\u3066\u30ce\u30fc\u30c9\u306b\u3064\u3063\u3053\u3093\u3067\u304a\u3051\u3070\u3068\u308a\u3042\u3048\u305a\u8272\u3005\u306a\u30eb\u30fc\u30eb\u304c\u66f8\u3051\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<pre><code>new Action(function() {\n  if (!\u304a\u663c\u30e1\u30a4\u30c4\u304c\u3044\u308b) {\n    return false;\n  }\n  \u4e00\u7dd2\u306b\u30e9\u30f3\u30c1\u3092\u98df\u3079\u308b();\n  return true;\n})\n\nnew Action(function() {\n  if (!\u304a\u5c0f\u9063\u3044\u304c\u5343\u5186\u3042\u308b) {\n    return false;\n  }\n  \u30e9\u30fc\u30e1\u30f3\u3092\u98df\u3079\u306b\u884c\u304f();\n  return true;\n})\n\nnew Action(function() {\n  if (!\u304a\u5c0f\u9063\u3044\u304c500\u5186\u3042\u308b) {\n    return false;\n  }\n  \u304a\u5f01\u5f53\u3092\u8cb7\u3044\u306b\u884c\u304f();\n  return true;\n})\nnew Action(function() {\n  \u6c34\u3092\u98f2\u3080();\n  return true;\n})\n<\/code><\/pre>\n<p>\u3053\u3046\u3044\u3046\u4e8b\u524d\u6761\u4ef6\u30c1\u30a7\u30c3\u30af\u306e\u5927\u534a\u306f\u4ed6\u3067\u3084\u308b\u3079\u304d\u3053\u3068\u306a\u306e\u3067\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5b9f\u884c\u3068\u4e00\u7dd2\u306b\u3057\u3066\u3057\u307e\u3046\u3068\u4f7f\u3044\u56de\u3057\u9762\u5012\u306a\u3093\u3067\u3059\u3051\u3069\u30cd\u3002<\/p>\n<h2>\u304a\u308f\u308a\u306b<\/h2>\n<p>Behaviour Tree\u306e\u30d5\u30a1\u30fc\u30b9\u30c8\u30b9\u30c6\u30c3\u30d7\u3068\u3057\u3066\u306f\u3053\u308c\u3050\u3089\u3044\u3067\u3044\u3044\u3093\u3058\u3083\u306a\u3044\u3067\u3057\u3087\u3046\u304b?<\/p>\n<p>Decorator\u3084\u5b9f\u884c\u72b6\u614b\u7ba1\u7406\u7b49\u304c\u306a\u304f\u3001\u3053\u306e\u307e\u307e\u5de8\u5927\u306a\u30eb\u30fc\u30eb\u3092\u69cb\u7bc9\u3059\u308b\u3068\u3072\u305f\u3059\u3089\u3064\u3089\u3044\u3060\u3051\u3067\u3059\u304c\u3001\u3068\u308a\u3042\u3048\u305a\u904a\u3093\u3067\u307f\u308b\u306e\u306b\u306f\u5341\u5206\u306a\u5b9f\u88c5\u3060\u3068\u304a\u3082\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3050\u3089\u3044\u306e\u5358\u7d14\u306a\u4f8b\u3060\u3068if\u5206\u3067\u7d20\u76f4\u306b\u66f8\u3051\u3070\u3044\u3044\u3058\u3083\u306a\u3044\u3068\u304b\u8272\u3005\u3042\u308b\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u3053\u3093\u306a\u3075\u3046\u306a\u30eb\u30fc\u30eb\u3092\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u7b49\u304b\u3089\u7d44\u3081\u308b\u3088\u3046\u306b\u3057\u3066\u304a\u3051\u3070\u8272\u3005\u306a\u30d1\u30bf\u30fc\u30f3\u3092\u30b3\u30fc\u30c9\u66f8\u304b\u305a\u306b\u8a66\u305b\u308b\u306e\u3067\u304a\u3082\u3057\u308d\u3044\u306e\u3067\u3059\u3088\u3002\u3068\u3044\u3046\u3053\u3068\u3067\u4eca\u65e5\u3082\u697d\u3057\u3093\u3067\u3044\u304d\u307e\u3057\u3087\u3046<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u307f\u306a\u3055\u307e\u3053\u3093\u3070\u3093\u306f\u3002\u3061\u3087\u3073\u3048\u3067\u3059\u3002 \u4eca\u65e5\u306f\u3061\u3087\u3063\u3068\u8da3\u5411\u3092\u5909\u3048\u3066\u30b2\u30fc\u30e0\u306eAI\u306e\u52c9\u5f37\u3001\u306a\u304b\u3067\u3082Behaviour Tree\u306b\u3064\u3044\u3066\u3059\u3053\u3057\u52c9\u5f37\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002 \u30b2\u30fc\u30e0\u306e\u4e16\u754c\u306eAI\u3063\u3066\u306a\u3093\u3060\u3063\u3051\uff1f \u30b2\u30fc\u30e0\u306e\u4e16\u754c\u306eAI\u3068\u3044\u3048\u3070\u3088\u304f [&hellip;]<\/p>\n","protected":false},"author":100,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9],"tags":[171],"class_list":["post-14026","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-info","tag-info"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/14026","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/users\/100"}],"replies":[{"embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/comments?post=14026"}],"version-history":[{"count":3,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/14026\/revisions"}],"predecessor-version":[{"id":14094,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/14026\/revisions\/14094"}],"wp:attachment":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/media?parent=14026"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/categories?post=14026"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/tags?post=14026"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}