Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sequence should not tick previous children if a children returns Running #11

Closed
JonPichel opened this issue May 17, 2023 · 1 comment
Closed

Comments

@JonPichel
Copy link

Hi, I have recently started using this library and I wanted to thank you for the amazing work.

I have the following BT. The logic I am trying to implement is making the ship extract resources and sell those not wanted until full. The extract resources action has a cooldown so its sibling node first checks if the cooldown is active and returns running if so:

	return bt.New(bt.Sequence,
		Sell(ship, sellExceptions...),
		bt.New(bt.Sequence,
			bt.New(func(children []bt.Node) (bt.Status, error) {
				if time.Now().Before(ship.Cooldown.Expiration) {
					return bt.Running, nil
				}
				if ship.Cargo.Units == ship.Cargo.Capacity {
					return bt.Failure, nil
				}
				return bt.Success, nil
			}),
			Extract(ship),
		),
	)

From what I understand about Behavior Trees, I expected the outer sequence node to directly Tick its second child (that is the inner Sequence node), since it returned a Running Status. Is this the expected behavior in your implementation? If so, how can I implement the behavior I described?

@joeycumines
Copy link
Owner

Hey @JonPichel :)

It sounds like you want to use either bt.Memorize or bt.Sync. I recommend the former - there are specific niche use cases for the Sync implementation, but Memorize is easiest to use.

It's a tick wrapper, so just changing bt.Sequence -> bt.Memorize(bt.Sequence) should achieve your desired outcome, unless I'm misunderstanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants