So I want to generate a random number, for example between 1-100. I want the probability of 100 being generated to be way more likely than 1, going up like that. The greater the number is, the more likely it is to be generated.
If it helps to have some context, I'm making a game where weapons have an accuracy. The higher the accuracy, the more chance there is of the weapon hitting the target, but I still want it to be (however remotely) possible for the weapon to miss, even if the accuracy is really high.
I've done some research into APD, but not found much in the way of a solid solution. Can anyone help?
So, thanks to the brilliant mind of timchen, the solution is as simple as:
import random accuracy = int(input("Accuracy (1-100): ")) randomNumber = random.randint(1,101) if accuracy > randomNumber: print("Hit!") else: print("Miss!")
Awesome community here :)