Repository navigation
Added Random::decision() which returns a bool based on a given probability - #70
Conversation
|
Yeah makes sense I think. There's if Random.decide(0.6):
# Do something.
# vs
if Random.decision(0.6):
# Do something.On the other hand, the Yet |
|
Now that i see both versions side by side i have to agree that |
|
I do think that this is useful, but after thinking about this more, it probably depends on the context. As an active actor (say for NPCs), you'd certainly prefer to use "decision" word. As a passive actor (chests with loot etc.), you'd probably be looking for something else. In this case, perhaps " So, I'm not suggesting to rename the method again, but the above sounds like two valid use cases to me. That said, I wouldn't be against adding additional "chance" method which would be basically an alias for the "decision" (or vice versa). However, if you think that "chance" is a better word to reasonably handle most use cases, then feel free to rename the existing method again. It's basically like having What do you think? I'd merge this in either case. 😮 |
|
I get what you mean, but aliases are in my opinion a bad idea. I already dislike this in Godot ( see |
|
Well, yeah, I think current name is fine as-is. Lets leave this to mean "the decision which is done by a program", rather than "decision which is done by an actor", this is probably just semantics. |
|
Thanks and congrats for your first contribution! |
Random::decision() which returns a bool based on a given probability
I often use something like
randf() < 0.33to do something based on a given probability. This PR adds this functionality toRandom. Not sure about the function name. It makes sense to me, but if you have a different suggestion i can change it of course.