Hello everyone, I was hoping someone could help me figure out a way to make a number generator that doesn't use specific numbers. Such as a generator that won't roll 13 24 27 33 etc... Also if anyone knows of a way to make it where two random numbers generators won't end up with the same number that would be appreciated.
edit:
I appreciate the responses so far! I've solved the first step of the puzzle by using the random.choice() function. I still can't think of a way to make sure two random number generators won't end up with the same number.
An example would be if random1 = renpy.random.choice(1,2,3) rolled and got 2 then random2 = renpy.random.choice(1,2,3) couldn't also roll 2 it would instead either re-roll until it got a number that wasn't taken or somehow remove the previously rolled number from the random pool... Any Ideas? Someone entertained the idea of using random.sample() but I don't know where to start with that idea
Random number generator with blacklisted numbers
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
-
- Newbie
- Posts: 2
- Joined: Mon Jan 28, 2019 12:35 am
- Contact:
Random number generator with blacklisted numbers
Last edited by Bentley-Sama on Mon Oct 21, 2019 3:41 pm, edited 1 time in total.
- isobellesophia
- Miko-Class Veteran
- Posts: 979
- Joined: Mon Jan 07, 2019 2:55 am
- Completed: None
- Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
- Organization: Friendly Teachers series
- Deviantart: SophBelle
- itch: Child Creation
- Location: Philippines, Mindanao
- Contact:
Re: Random number generator with blacklisted numbers
Maybe rand.int could help, which can randomize things like dialogue and numbers too. I can help if thats what you mean.Bentley-Sama wrote: ↑Mon Oct 21, 2019 11:39 am Hello everyone, I was hoping someone could help me figure out a way to make a number generator that doesn't use specific numbers. Such as a generator that won't roll 13 24 27 33 etc... Also if anyone knows of a way to make it where two random numbers generators won't end up with the same number that would be appreciated
Re: Random number generator with blacklisted numbers
You could use renpy.random.choice with list of allowed values.
Or you could make loop what will generate new random number until it is not in blacklist.
First approach is better, unless you want really wide range of values.
Or you could make loop what will generate new random number until it is not in blacklist.
First approach is better, unless you want really wide range of values.
I may be available for hire, check my thread: viewtopic.php?f=66&t=51350
- IrinaLazareva
- Veteran
- Posts: 399
- Joined: Wed Jun 08, 2016 1:49 pm
- Projects: Legacy
- Organization: SunShI
- Location: St.Petersburg, Russia
- Contact:
Re: Random number generator with blacklisted numbers
Bentley-Sama wrote: ↑Mon Oct 21, 2019 11:39 am Someone entertained the idea of using random.sample() but I don't know where to start with that idea
Code: Select all
$ random1, random2 = renpy.random.sample([1, 2, 3, 4], 2)
Who is online
Users browsing this forum: No registered users