Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    random_set_seed() in Fuze

    Help
    help please
    3
    17
    914
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Rxvlism
      Rxvlism last edited by

      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

      pianofire 1 Reply Last reply Reply Quote 1
      • pianofire
        pianofire Fuze Team @Rxvlism last edited by

        @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)

        pianofire 1 Reply Last reply Reply Quote 1
        • pianofire
          pianofire Fuze Team @pianofire last edited by MikeDX

          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.

          1 Reply Last reply Reply Quote 1
          • Rxvlism
            Rxvlism last edited by MikeDX

            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

            pianofire 1 Reply Last reply Reply Quote 1
            • pianofire
              pianofire Fuze Team @Rxvlism last edited by pianofire

              @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
              
              Rxvlism 1 Reply Last reply Reply Quote 1
              • Rxvlism
                Rxvlism last edited by

                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 🙏🏽

                1 Reply Last reply Reply Quote 2
                • jmcdowall
                  jmcdowall last edited by

                  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!

                  Rxvlism 1 Reply Last reply Reply Quote 1
                  • Rxvlism
                    Rxvlism @pianofire last edited by

                    @pianofire

                    pianofire 1 Reply Last reply Reply Quote 0
                    • Rxvlism
                      Rxvlism @jmcdowall last edited by

                      @jmcdowall thanks I’ll take a look 👀

                      1 Reply Last reply Reply Quote 0
                      • pianofire
                        pianofire Fuze Team @Rxvlism last edited by pianofire

                        @Rxvlism Sorry missed a line when I re-keyed it you need an array declaration near the top

                        randomNumbers = []
                        
                        Rxvlism 1 Reply Last reply Reply Quote 0
                        • Rxvlism
                          Rxvlism @pianofire last edited by

                          @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

                          1 Reply Last reply Reply Quote 0
                          • Rxvlism
                            Rxvlism last edited by

                            I think this is what it’s supposed to do

                            pianofire 1 Reply Last reply Reply Quote 0
                            • pianofire
                              pianofire Fuze Team @Rxvlism last edited by

                              @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.

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post