Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
hyperPad

hyperPad Forum

  1. Home
  2. Help and Support
  3. How to not get the number twice with Random Value?

How to not get the number twice with Random Value?

Scheduled Pinned Locked Moved Help and Support
6 Posts 4 Posters 1.3k Views 1 Watching
  • 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.
  • LinkoGamesL Offline
    LinkoGamesL Offline
    LinkoGames
    wrote on last edited by
    #1

    Recently got back into HyperPad and was working on some games when I noticed the random behaviour tends to output the same number twice, or even more. Any ways to change this?

    Aidan_FireA KamdroidK 2 Replies Last reply
    0
    • LinkoGamesL LinkoGames

      Recently got back into HyperPad and was working on some games when I noticed the random behaviour tends to output the same number twice, or even more. Any ways to change this?

      Aidan_FireA Offline
      Aidan_FireA Offline
      Aidan_Fire
      wrote on last edited by Aidan_Fire
      #2

      @linkogames You mean you want to use the Random Number behaviour repeatedly, but you don't want the numbers to ever be the same as the previous number? If so, it's possible but needs some logic, I'll help you with it if I've interpreted the question right.

      1 Reply Last reply
      0
      • Aidan_FireA Offline
        Aidan_FireA Offline
        Aidan_Fire
        wrote on last edited by
        #3

        Here's a link to my example method: http://bit.ly/2Irp5Cz
        Tried to explain it with comment behaviours the best I can.

        1 Reply Last reply
        0
        • LinkoGamesL LinkoGames

          Recently got back into HyperPad and was working on some games when I noticed the random behaviour tends to output the same number twice, or even more. Any ways to change this?

          KamdroidK Offline
          KamdroidK Offline
          Kamdroid
          wrote on last edited by
          #4

          @linkogames You will have to add an if statement to generate another random number if the 2nd one is the same as the 1st (though by doing this you're technically making it less random πŸ˜›)


          Or if you're ralking about something that could be a potential bug, it could be due to your behaviours being wired incorrectly or rarely a hyperPad bug,

          I just tested it right now and it works fine, so maybe it's something wrong with your behaviours, if so, give us a link to download your project that produces these strange results so we can help you,

          1 Reply Last reply
          0
          • RobinsonXR Offline
            RobinsonXR Offline
            RobinsonX
            wrote on last edited by
            #5

            If the two input numbers are close to each other, it will seem β€œless random.” Like 1 and 5. The chances of getting the same number twice is 1 out of 10.

            While inputs 1 and 100 will have the chances being 1 out of 200 of getting the same number twice.

            You can prevent getting a number twice by using a conditional statement:
            If it’s the same number as previously, retry.

            The argorithm will repeat itself until it has found a different number. πŸ‘Œ

            1 Reply Last reply
            0
            • Aidan_FireA Offline
              Aidan_FireA Offline
              Aidan_Fire
              wrote on last edited by
              #6

              The retry if the number generated is the same as the previous method is a lot more simple than what I did πŸ˜‚.

              1 Reply Last reply
              0

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better πŸ’—

              Register Login
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Search