Decision Tree Delays

Started by
0 comments, last by Whorse 9 years, 10 months ago

I've graduated from using a cluttered FSM for my AI to a Decision Tree of my own creation. I'm using Unity3d and C# for this pet project. I've structured my tree in the following manner without pointer capabilities. However my question, could apply to any decision tree which might implement coroutines.


	protected virtual void Update()
	{
		StartCoroutine(TriggerTree());
	}

	IEnumerator TriggerTree()
	{
		yield return rootDecisionNode.StartCoroutine(rootDecisionNode.TriggerPath());
	}

Currently every Update() call a run through of the tree's branches is triggered and it checks branch logic paths to see what leaf should be reached. The last Action leaves at the end of each branch return new WaitForSeconds.

I'm interested in learning the best way to halt the decision tree or perform an animation but still be able to run the tree and check if another leaf has been reached. So if my character is idling, wait for the idle animation to finish before playing another idle animation but if the character is damaged then trigger the damage animation. Is my code design for a decision tree without pointers sound enough as it is?

Advertisement

Upon further thought, a structure could be returned with the Action type that was run and the amount of seconds to wait. Store the last Action type, if the new Action type is the same as the last Action type do nothing, if it's a different action type then trigger it.

This topic is closed to new replies.

Advertisement