How to not get the number twice with Random Value?

  • 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?

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

  • Here's a link to my example method:
    Tried to explain it with comment behaviours the best I can.

  • @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,

  • 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. πŸ‘Œ

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

Log in to reply