Weather System (Weighted random number)

Hey there,

So I’ve stumbled into something that I thought’d be easy, I’m creating a 8bit weather system.

But everyone seems to do it a slightly different way.

The best way I can think of is essentially like 5 branches that ask for a random bool with weight.

And re-ask it over and over until it ends with a result.

But I gotta say, I’m getting that icky messy feeling when I feel like I’m being a hack.

I’m curious if anyone has a better system, Or if the community as a whole has come to the conclusion of a system that’s overall just best/effective.

Thank yee

ps. the bool weights are just placeholders to get an outcome.

I would also say this system does work surprisingly well.
I’m just looking to be as effective and efficient as possible.

Hey there @Skyboy! So if I understand correctly, you’d just like some basic weighted random rolls for a weather system? Would you be able to make a function that rolls once instead of repeated branches

I’d recommend taking a look at these two weighted random implementations, they might give you some inspiration:

Disclaimer: One or more of these links are unaffiliated with Epic Games. Epic Games is not liable for anything that may occur outside of this Unreal Engine domain. Please exercise your best judgment when following links outside of the forums.

The probability functions in the vids linked by support are the best way to deal with random unknowns. But since potential weather types probably won’t change often, a quick way to fake it might be to add multiple versions of each event in the array to approximate probability. Then just generate one random int in range with max being the length, and use the result as an index.

Var here was just strings to make it readable.