-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathroll.py
More file actions
52 lines (36 loc) · 1.47 KB
/
Copy pathroll.py
File metadata and controls
52 lines (36 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from heapq import nlargest
from numpy import std
import numpy.random
# roll 4 6-sided dice and keep the highest three
def roll_stat():
return sum(nlargest(3, numpy.random.random_integers(1, 6, 4)))
# use the roll_stat method to return 6 stats
def roll_stats():
return [stat for stat in [roll_stat() for _ in range(6)]]
# returns the modifier given a score, ranges from -5 for 1 and +5 for 20
def get_mod(score):
return (score - 10) // 2
# roll stats the "colville" way, in order and with at least 2 scores that are 15+
def roll_stats_coville():
stats = roll_stats()
while [i for i in stats if i >= 15].__len__() < 2:
stats = roll_stats()
return stats
# roll stats and make sure the the sum of the mods is at least 5, the sum of the standard array
def roll_stats_min_mod():
stats = roll_stats()
while sum([get_mod(i) for i in stats]) < 5:
stats = roll_stats()
return sorted(stats, reverse=True)
# roll stats and make sure the variance of modifiers is at least 1.5, needs tweaking
def roll_stats_variance():
stats = roll_stats()
while std([get_mod(i) for i in stats]) < 1.5:
stats = roll_stats()
return sorted(stats, reverse=True)
# roll stats and make sure the there is at least one <= 8 and one >= 15
def roll_stats_8_15():
stats = roll_stats()
while [i for i in stats if i >= 15].__len__() < 1 or [i for i in stats if i <= 8].__len__() < 1:
stats = roll_stats()
return sorted(stats, reverse=True)