Skip to content

Instantly share code, notes, and snippets.

@georgedorn
Created November 28, 2012 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save georgedorn/4165233 to your computer and use it in GitHub Desktop.
Save georgedorn/4165233 to your computer and use it in GitHub Desktop.
Analysis of Random vs Point-Buy for Rolemaster Playtest
"""
Rolls up a huge number of rolemaster characters,
calculates the equivalent values using point-buy,
aggregates the results.
"""
number_of_rolls_per_stat = 3
minimum_stat_roll = 11
number_of_characters = 100000 #pretty consistant at this number, use more if you feel like it
point_chart = {1:-93,
2:-87,
3:-81,
4:-75,
5:-69,
6:-63,
7:-57,
8:-54,
9:-51,
10:-49,
11:-47,
12:-45,
13:-43,
14:-41,
15:-39,
16:-37,
17:-35,
84:35,
85:37,
86:39,
87:41,
88:43,
89:45,
90:47,
91:49,
92:51,
93:54,
94:57,
95:63,
96:69,
97:75,
98:81,
99:87,
100:93}
for i in range(18,84):
point_chart[i] = i-50
import random
def generate_stat():
"""
Rolls X d100s, returns the two best, representing Potential, Temp.
"""
rolls = [roll_stat() for i in range(number_of_rolls_per_stat)]
rolls.sort(reverse=True)
return rolls[0:2]
def roll_stat():
"""
One d100 roll, with a minimum applied.
"""
return random.randint(minimum_stat_roll,100)
def calculate_point_values(stats):
"""
Given a set of stats of the form (potential, temp),
calculate the equivalent costs via the point-buy system.
"""
pot_value = sum([point_chart[stat[0]] for stat in stats])
temp_value = sum([point_chart[stat[1]] for stat in stats])
return (pot_value, temp_value)
def generate_character():
"""
Generates stats for a character.
"""
return [generate_stat() for i in range(10)]
"""
Calculate mean and standard deviation of data x[]:
mean = {\sum_i x_i \over n}
std = sqrt(\sum_i (x_i - mean)^2 \over n-1)
"""
from math import sqrt
def meanstdv(x):
n, mean, std = len(x), 0, 0
for a in x:
mean = mean + a
mean = mean / float(n)
for a in x:
std = std + (a - mean)**2
std = sqrt(std / float(n-1))
return mean, std
results = []
rolls = number_of_characters
for i in range(rolls):
stats = generate_character()
results.append(calculate_point_values(stats))
results.sort(key=lambda x: x[1])
temp_median = results[rolls/2][1]
temp_average, temp_std = meanstdv([result[1] for result in results])
#temp_average = sum([result[0] for result in results])/rolls
results.sort(key=lambda x: x[0])
pot_median = results[rolls/2][0]
pot_average, pot_std = meanstdv([result[0] for result in results])
print "Median Temp:", temp_median
print "Mean Temp:", temp_average
print "Temp stddev:", temp_std
print "Median Potential:", pot_median
print "Mean Potential:", pot_average
print "Potential stdev:", pot_std
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment