{"id":31127206,"url":"https://github.com/horik816/enemybehaviortreedemo","last_synced_at":"2025-09-17T23:03:37.397Z","repository":{"id":279963920,"uuid":"940364591","full_name":"HoriK816/EnemyBehaviorTreeDemo","owner":"HoriK816","description":"This is a repository to demonstrate the enemy's character AI in the 2D shooting game. My enemy character AI is implemented using BT (Behavior Tree), which is often used to create behaviors for robotics or NPCs (Non-Playable Characters) in game development contexts.","archived":false,"fork":false,"pushed_at":"2025-09-03T05:41:35.000Z","size":1559,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-03T07:26:23.231Z","etag":null,"topics":["game","npc","processing"],"latest_commit_sha":null,"homepage":"","language":"Processing","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HoriK816.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-02-28T03:39:23.000Z","updated_at":"2025-09-03T05:41:39.000Z","dependencies_parsed_at":"2025-02-28T19:06:58.447Z","dependency_job_id":"9f88cd62-1ec0-49e0-b3c9-343ea9fc0280","html_url":"https://github.com/HoriK816/EnemyBehaviorTreeDemo","commit_stats":null,"previous_names":["horik816/enemy_ai_test"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/HoriK816/EnemyBehaviorTreeDemo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HoriK816%2FEnemyBehaviorTreeDemo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HoriK816%2FEnemyBehaviorTreeDemo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HoriK816%2FEnemyBehaviorTreeDemo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HoriK816%2FEnemyBehaviorTreeDemo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HoriK816","download_url":"https://codeload.github.com/HoriK816/EnemyBehaviorTreeDemo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HoriK816%2FEnemyBehaviorTreeDemo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275680444,"owners_count":25508570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-17T02:00:09.119Z","response_time":84,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["game","npc","processing"],"created_at":"2025-09-17T23:03:22.631Z","updated_at":"2025-09-17T23:03:37.389Z","avatar_url":"https://github.com/HoriK816.png","language":"Processing","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"/imgs/screenshots/game_scene.gif\" width=\"150%\"\u003e\n\n# Abstract\nThis is a repository to demonstrate the enemy's character AI in the 2D shooting \ngame. My enemy character AI is implemented using BT (Behavior Tree), which is \noften used to create behaviors for robotics or NPCs (Non-Playable Characters) \nin game development contexts. \n\nAnd then, not only the character AI, I implement the entire Demo with Processing. \nProcessing is a programming environment for visual programming. And, you can \ntest it easily with Processing.\n\n# How to use \n![how to use](/imgs/screenshots/how_to_use.png)\n1. Open any program file with Processing by double-clicking it. \n(Opening one file will open all programs.)\n2. Run the demo program with the Start button. The start button is in \nthe upper right of the window.\n3. A new window will open, and the Demo will start. \n\nI confirmed this program works correctly in version 4.3.4 of processing.\n\n# How to Control\n* UP Arrow Key    : move up\n* Down Arrow Key  : move down\n* Right Array Key : move right\n* Left Array Key  : move left\n* Z key           : ranged attack \n* X key           : melee attack\n\n# About BT (Behavior Tree)\nBehavior Tree, often abbreviated to BT, is an algorithm to create behaviors of \nNPC (Non-Playable Character). BT is often used even in commercial games, and \nthe FF (Final Fantasy) series is one of the most famous examples (Strictly \nspeaking, the character AI algorithm used in the FF series is not limited to \nBT...). In this BT, the character's behavior is presented by a tree structure. \nWe use BT nodes to build the tree, and there are mainly three types of nodes. \n\nThey are\n* Control Nodes\n* Leaf Nodes\n* Decorator Nodes\n\nControl Nodes are nodes that control the process flow. For example, Sequence \nNode, a type of control node, executes all child nodes sequentially.\n\nLeaf Nodes are nodes that correspond to the actual character's behavior. \nAll Characters do ACTION and MAKE DECISIONS in the game world. Leaf Nodes \ncorrespond to them.\n\nDecorator Nodes are nodes that alter operations at the specific nodes. \nFor example, Repeater Nodes execute the child node repeatedly, and \nInverter Nodes invert the results of the child node.\n\nFurthermore, all BT nodes return the three types of results.\n\nThey are\n* SUCCESS\n* FAILURE\n* RUNNING\n\nSUCCESS represents that the node finishes its work correctly. FAILURE is vice \nversa. RUNNING represents that the node is still in an \nexecuting state. Normally, the Character's Action (walking, attacking, chanting \na spell, and so on...) takes time, therefore the corresponding node continues \nto return to RUNNING during that time.\n\nIt's possible to decide the next action of the character by tracing the tree \nregularly. By the way, my demo program traces the tree every draw call (this \nfunction in processing a kind of update in other programming platforms).\n\n\n# Structure of My Enemy AI \n![object tree for BT](/imgs/figures/object_tree_bt.png)\nThis image represents the Object Tree for BT in this project. Although I don't \nimplement all types of nodes in BT, it seems to be sufficient to create various \nenemy action patterns in 2D shooting games.\n\nAs mentioned previously, ActionNode and ConditionNode correspond to the actual \nenemy's actions and decisions. Then, we have to inherit them to create each \naction and make decisions.\n\nThere are SequenceNode and SelectorNode as ControlNode.\n\nIn addition, I implemented InverterNode, RepeaterNode, \nKeepRunningUntilFailureNode, and RetryUntilSuccessfulNode as DecoratorNode.\n\n![my enemy AI](/imgs/figures/my_enemy_ai_structure.png)\nbuilt an enemy's behavior tree with these three components.\nThis is the structure of my enemy character AI. It has a lot of nodes, but \nit's not very complicated.\n\nRoughly speaking, the enemy's behavior is like this.\n* The distance to the player is less than L -\u003e close to the player and make a melee attack\n* The distance to the player is greater than or equal to L -\u003e random move or make a ranged attack\n\t* There are three types of ranged shot\n\t\t* Normal shot\n\t\t* Bullet Hell 1 (All range shot + N-way)\n\t\t* Bullet Hell 2 (rapid firing)\n\n![my enemy AI](/imgs/figures/my_enemy_ai_structure_with_indicator.png)\nBy the way, you might find it hard to recognize what you are creating. It's \ndifficult to build complicated behaviors because my program doesn't provide \nDSL(Domain Specific Language) to build a tree. As a countermeasure for it, \nIt works the way that gives an indicator for each node such as the alphabet for \nme.\n\n# Reference\nI used the website below as a reference.\n\n[behaviortree.dev](https://www.behaviortree.dev/docs/Intro)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhorik816%2Fenemybehaviortreedemo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhorik816%2Fenemybehaviortreedemo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhorik816%2Fenemybehaviortreedemo/lists"}