1. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Jul 2004
Posts
58
Rep Power
11

#### random...

im making a text based game and im using random.randint to choose a random number between 1-3 that is assigned to a different monster. What is the code to make a certain number have a better chance at bieng chosen than the other two numbers?
2. Very easy to do, pick a number between 1 and 4 and make two of the numbers point to the same monster - giving that monster double the chance of the remaining two (2 in 4). Or thats the theory .

Mark.
Last edited by netytan; August 15th, 2004 at 06:42 AM.
3. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Jul 2004
Posts
58
Rep Power
11
yes that is a good idea

but what if i need a 1% chance for one thing and a 99% chance for another?
Should i just put 100 different objects in or is there another thing i could do.
4. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Feb 2004
Location
Germany
Posts
11
Rep Power
0
i would do this in that way
Code:
```import random

number = random.randint(0, 101)
if number == 3: # you can choose any number you want between 1 and 101
print "1% chance"
else:
print "99% chance"```
5. Or something like this:
Code:
```import random

num = random.random(0,101)

if num <= 50: # 50% probable
monster = 'A'
elif num >= 51 and num <= 80: # 30% probable
monster = 'B'
elif num >= 81 and num <= 90: # 10% probable
monster = 'C'
else: # 10% probable
monster = 'D'```
grim
6. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Jul 2004
Posts
58
Rep Power
11
thx i would never of thought of using those.