Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/python
- # -*- coding: utf-8 -*-
- from random import *
- def make_stat():
- """
- This function rolls three six-sided dice (3d6) and returns the result. It really
- has no other function than that.
- """
- dice1 = randint(1,6)
- dice2 = randint(1,6)
- dice3 = randint(1,6)
- total_dice = dice1 + dice2 + dice3
- return total_dice
- """
- unlimited_dice function:
- The purpose of the limited dice function is:
- The function rolls xd6 dice.
- Each die is added to a list
- Afterwards, the function checks the list for the result 6. If there is a 6 in
- the list, the function will replace that 6 with two new dice. It repeats this
- untill there is no 6 in the list, in which case it will add the results together
- and return that value.
- An example:
- The user specifies 3d6 is to be rolled.
- The function runs random.randint(1,6) three times. The rolls turns out to be
- 1, 4 and 6, which is added to die_rolls, which is no [1, 4, 6]. When the
- checks the list if find the 6. It takes away the 6, and rolls random.randint(1,6)
- two more times. This time they are 6 and 6. Again, it replaces each 6 with two
- other rolls, in this case the rolls are 1, 1, 4, 6. This list is now:
- [1, 4, 6, 1, 1, 4, 6]. It replaces the 6 with two new rolls, 2 and 3. The list
- is [1, 4, 6, 1, 1, 4, 2, 3]. Now there are no 6, and so the function adds
- the items into dice_result (22), and returns dice_result.
- """
- def unlimited_dice(number_of_rolls):
- roll_result = []
- for i in range(number_of_rolls):
- roll_result.append(random.randint(1,6))
- return roll_result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement