backlinks to this page:
Plugin Backlinks: Nothing was found.
Github:
Theory of probability is a fascinating topic by itself and get becomes even more fascinating if you apply it to games.
Recommended reading:
random
module
To apply it to games with python, you need to import python's random
module (shipped with python).
To simulate the throw of a six-sided dice, write:
>>>import random >>>result = random.randint(1,6) # lower bond, upper bond >>>print result 2
You can find out all functions of the random
module by typing at the python prompt:
>>>import random >>>help("random")
Some useful functions tend to use frequently are:
random.randint(a, b)
creates a random integer between (including) a and bradnom.random()
creates a float between 0 and 1random.choice(list)
randomly choose one element of a list