random_set_seed() in Fuze
-
@Rxvlism I am afraid that we do not currently have this function. I assume that you want to get a predictable set of random results. For the time being you will have to implement your own pseudo random number generator
-
-
@Rxvlism You could try this one https://mathoverflow.net/questions/29494/pseudo-random-number-generation-algorithms
-
Ima have to sit down and try understand this cuz I don’t get it even after reading the code on the page, time to study I guess lol
-
@Rxvlism Yes me too. I will put in a request for a random_set_Seed function but it could be a while (assuming it is accepted)
-
In the meantime you could generate some random results and store them in a file so that you can read them back into an array.
-
It is a very useful function that and get_perlin_noise
I will try that 🤔
Lol how would u make it, if u don’t mind me asking lol I’m really stumped
-
@Rxvlism OK try something like this:
maxNumbers = 1000 randomRange = 1000 numberLen = 4 seed = 0 nextRandom = seed randomNumbers = [] // run this once to store the random number sequence //saveNumbers() // read previously saved numbers loadNumbers() clear() for i = 0 to 10 loop printAt(0, i, getRandom(6) + 1) repeat update() sleep(3) function getRandom(range) result = int(randomNumbers[nextRandom] / randomRange * range) nextRandom += 1 if nextRandom == maxNumbers then nextRandom = 0 endif return result function saveNumbers() handle = open() for i = 0 to maxNumbers loop randomNumber = random(randomRange) write(handle, padStr(str(randomNumber), numberLen, " ")) repeat close(handle) return void function loadNumbers() handle = open() for i = 0 to maxNumbers loop randomNumbers[i] = int(read(handle, numberLen)) repeat close(handle) return void function padStr(theStr, padLen, padChar) result = theStr while len(result) < padLen loop result += padChar repeat return result
-
I will try it out 😂 honestly I don’t know what im doing at this point so hopefully I learn something from you’re code thanks 🙏🏽
-
I've had success with repeatable random numbers in the past (not Fuze) with a linear congruential generator https://rosettacode.org/wiki/Linear_congruential_generator
Good luck!
-
-
@jmcdowall thanks I’ll take a look 👀
-
@Rxvlism Sorry missed a line when I re-keyed it you need an array declaration near the top
randomNumbers = []
-
@pianofire kk now I need to understand how to implement this into my game. If I post it can u help me lol I’ll credit...
Just need to wrap my head around it
-
-
@Rxvlism no that doesn't look right!. Did you run the saveNumbers() function the first time that you ran it?
uncomment //saveNumbers() by removing the //. This will save a list of 1000 random numbers to a file. Then comment that line out again so that the next time you run it, it loads the same list of 1000 numbers.