Created
December 29, 2014 22:27
-
-
Save ivey/b34177cb7e9d4111583a to your computer and use it in GitHub Desktop.
behavior_tree_builder.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b := gobt.NewTreeBuilder() | |
tree := b.Tree("test", | |
b.Sequence("try some things", | |
b.Selector("1 of 3", | |
b.Action("fail at something", | |
func(player interface{}, bb *gobt.Blackboard) bool { | |
fmt.Println("a1: ", bb) | |
return false | |
}), | |
b.Action("fail at something else", | |
func(player interface{}, bb *gobt.Blackboard) bool { | |
fmt.Println("a2: ", bb) | |
return false | |
}), | |
b.Action("succeed", | |
func(player interface{}, bb *gobt.Blackboard) bool { | |
fmt.Println("a3: woot!") | |
return true | |
}, | |
), | |
), | |
), | |
) | |
tree2 := b.Tree("test"). | |
Sequence("try some things"). | |
Selector("1 of 3"). | |
Action("fail at something", | |
func(player interface{}, bb *gobt.Blackboard) bool { | |
fmt.Println("a1: ", bb) | |
return false | |
}). | |
Action("fail at something else", | |
func(player interface{}, bb *gobt.Blackboard) bool { | |
fmt.Println("a2: ", bb) | |
return false | |
}). | |
Action("succeed", | |
func(player interface{}, bb *gobt.Blackboard) bool { | |
fmt.Println("a3: woot!") | |
return true | |
}). | |
Build() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment