meniku / NPBehave

Event Driven Behavior Trees for Unity 3D

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Randomized Nodes

Wokarol opened this issue · comments

It would be really handy to have nodes such as "Random Selector" or "Random Sequencer". They would be helpful for creating more non linear enemy behaviours. Especially for bosses.
(For clarity, by "Random Selector" I mean one where nodes are checked in random order and by "Random Sequencer" I mean one where nodes are sequenced in random order.)

commented

Interesting idea. For selectors it should be already possible to do that by putting a Random decorator at all subbranches of the Selector.

Random on childs won't give correct probability I think. And even if, you would have to tweak probability everytime you change number of childs.

commented

Fair enough.
I think that should be possible to implement. Right now I'm on vacation so it could take some time to do it myself... If you want to give it a try yourself, I'm happy to take pull requests ;-)

Okay, I've done some tests and looks like Selector + Random method gives uneven results.

RandomDistribution
(21 tests, each test was stopped when any bar reached 200 points)

You can see that 1st option is chossen more often. Almost twice as often as last one.

commented

I’ve merged your pull-request at #18
Thanks again for the contribution.

One thing that's a bit unclear to me right now is what should happen with the child priorities for the stops rules.
Right now I kept it the original order (not the randomized one), but one could argue that the children priorities should change to the randomized order...

commented

@Wokarol may i ask you how you used the selector and random method? i can't quite get a hand of it.

@Luuno // What Selector and Random methods you have in mind?

@meniku // In theory, best way would be to keep randomised order, but I don't fully understand stop rules yet. I will probably change it, but first I have to understand how it even works.

commented

@Wokarol i would like a set of actions to be picked at random. so my animal behaviour is more random and natural.

@Luuno // Just use Random Selector like Selector.

commented

@Wokarol but the library does not recognize random selector? so i am a bit confused

@Luuno // You have it downloaded from Asset Store or Git? It's feature I've added recently. It's possible that it isn't on Asset Store yet.

commented

@Wokarol asset store indeed. thank you i will get it from here and try again!

commented

I didn't update the asset store version for quite a while. I've planned to do it soonish

commented

I agree that the pre-defined random order might make the most sense, although I'm not quite sure if it really makes sense to use stops rules with those random decorators at all.

I think it makes sense, for end user randomised nodes are basically nodes that shuffle their childrens