Implementing behavior trees