I want to create a system where it randomly chooses a event every 40-60 minutes or so that is server wide, similar to how Grow a garden handles their weather.
I am unsure how to approach this, and advice or any ideas would be much appreciated.
I want to create a system where it randomly chooses a event every 40-60 minutes or so that is server wide, similar to how Grow a garden handles their weather.
I am unsure how to approach this, and advice or any ideas would be much appreciated.
You can use random numbers with set seeds determined by something that every server has.
A perfect use for this would be os.time() which returns a number that should be the same for every server.
Psuedocode:
timeScale = 3000 – seconds between seed changes
while true:
seed = math.floor(os.time()/timeScale)
randomVal = random.New(seed):NextInteger(0,5)
if randomVal == 0 then
doEvent()
task.wait()
Is this safe??? Also read this
This is not for lootboxes, which obviously would be dangerous to do as it could be predicted. In fact if anyone knew the formula, they could predict when storms occur.
Thing is, this doesn’t matter for the usecase. And if he doesn’t want to worry about it, he could add an offset to the seed to make prediction difficult.
If you care about cryptography level unpredictability, make an external web server using an entropy source from the radioactive decay of americium, and then send that to roblox.
I haven’t played Grow a Garden, though that’s good to know
Would any information about event forecasting not be useful to players?
What do you mean?
Normally in GOG events are not predictable using math formulas as I am pretty sure no one knows how they know when to trigger events.
I was just saying, without knowing the formula or adding an offset, predictability is no longer a problem.
so something like, please correct any errors or general mistakes I made, Sorry that I sorted rushed this. I wanted to show a example really quickly while I had the chance to reply
while true do
local timescale = math.random(2000, 4000)
local seed = math.floor(os.time()/timeScale)
local randomVal = random.New(seed):NextInteger(0,5)
if randomVal == 0 then
doEvent()
end
I agree with your post, but I just wanted to point out that adding an “offset” (input, output or state, doesn’t matter) is pointless, as it can be predicted just as easily. For use cases like you mentioned, it is indeed better to use PCG32
Never use the seed argument unless you need to (e.g. reproducibility) ![]()
No that won’t work, timescale would vary server to server.
Did you see what he wanted? He wanted every server to have the same value. So I made it so the seed is the same across servers via os.time()
So timescale would be how often the seed changed. So if time scale is 100 seconds, every 100 seconds the seed for the RNG would change. Due to that, a new ‘dice’ is rolled every 100 seconds. Then if the dice rolls a particular number, the event is activated.
You’re right, and I apologize for the confusion, but the point still holds.
That is what? The PRNG algorithm is not going to help reduce how predictable it is. Just make the source seed harder to determine. But the basic layout of my idea is pretty solid. The best solution outside of this is an external web server that is hosted that tells the Roblox Servers when to start and event.
My comment was about avoiding “offsets” that give a false sense of security, not that the underlying algorithm will help you reduce its entropy. Besides, you’re wrong, because an algorithm sure does change how predictable its outputs are – It’s literally a different algorithm – its properties are bound to change.
And I’m afraid that your idea’s layout is far from solid. You can simply use a battle-tested CSPRNG and expect close to zero unpredictability, but hosting a webserver is pretty pointless if you ask me, unless you’re working with very sensitive data, and even then, you shouldn’t store or otherwise interact with that data on Roblox in the first place.
You’re miss understanding. The predictablility of a number is pretty much linked to its seed/source of entropy. Sure some algorithms might be more random with respect to how much the seed changes, but in general it’s up to the seed.
Someone would have to know the seed and other facts about the said system I suggested in order to predict weather events. Backtracking the information would be quiet difficult with my system.
I think you’re misunderstanding the web server too. I was trying to say a web server could be used to signal to your game servers when weather is supposed to occur, that way external random number generation could be used.
With how unpredictable you want weather to be in his game, he might as well link it to the spontaneous radioactive decay of some heavy particle to weather!
I apologize yet again for the misunderstanding, you’re right. I got mixed up with one of your reply talking about Americium or some other chemical element and it kind of threw me off ![]()
Though, I disagree on the fact that the seed determines the probability of a number being outputted by a PRNG. However, it does determine the sequence.
You can use today’s day from 1970 epoch as a seed for random generator
OP wants it to be server-wide, so that wouldn’t work.