mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-10-31 17:06:50 +08:00 
			
		
		
		
	 149f16fe29
			
		
	
	149f16fe29
	
	
	
		
			
			The status badge paths were updated and the query params `?branch=main` don't work with the old schema. https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/monitoring-workflows/adding-a-workflow-status-badge
		
			
				
	
	
	
		
			2.1 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			2.1 KiB
		
	
	
	
	
	
	
	
This package provides a simple and easy to use behavior tree API in pure dart.
Behavior tree is a very common way of implementing AI behavior in game and robotics. Using this, you can break-down a complex behavior of an in game AI, into multiple smaller nodes.
Features
- Nodes
- Composite
- Sequence: Continues execution until one of the children fails.
- Selector: Continues execution until one of the children succeeds.
 
- Decorator
- Inverter: Flips the status of the child node.
- Limiter: Limits the number of ticks for child node.
 
- Task
- Task: Executes a given callback when ticked.
- AsyncTask: Executes an async callback when ticked.
- Condition: Checks a condition when ticked.
 
 
- Composite
Getting started
Add this package to your dart project using,
dart pub add behavior_tree
Usage
- Create a behavior tree.
final treeRoot = Sequence(
  children: [
    Condition(() => isHungry),
    Task(() => goToShop()),
    Task(() => buyFood()),
    Task(() => goToHome()),
    Task(() => eatFood()),
  ]
);
- Tick the root node to update the tree.
final treeRoot = ...;
treeRoot.tick();
