Code:

#!/usr/bin/python
import argparse
import numpy as np
import sys
from scipy.optimize import curve_fit
thrusters = {
'3P': { 'mass': [70, 90, 200], 'mul': [90, 115, 137], 'fudge': [1, 1.0839, 1.1678] },
'3A': { 'mass': [60, 120, 180], 'mul': [96, 100, 116], 'fudge': [1, 1, 1] },
'3B': { 'mass': [55, 110, 165], 'mul': [93, 100, 113], 'fudge': [1, 1, 1] },
'3C': { 'mass': [50, 100, 150], 'mul': [90, 100, 110], 'fudge': [1, 1, 1] },
'3D': { 'mass': [45, 90, 145], 'mul': [86, 100, 106], 'fudge': [1, 1, 1] },
'3E': { 'mass': [40, 80, 120], 'mul': [83, 100, 103], 'fudge': [1, 1, 1] },
'2P': { 'mass': [50, 60, 120], 'mul': [90, 115, 137], 'fudge': [1, 1.0839, 1.1678] },
'2A': { 'mass': [36, 72, 108], 'mul': [96, 100, 116], 'fudge': [1, 1, 1] },
'2B': { 'mass': [33, 66, 99], 'mul': [93, 100, 113], 'fudge': [1, 1, 1] },
'2C': { 'mass': [30, 60, 90], 'mul': [90, 100, 110], 'fudge': [1, 1, 1] },
'2D': { 'mass': [27, 54, 81], 'mul': [86, 100, 106], 'fudge': [1, 1, 1] },
'2E': { 'mass': [24, 48, 72], 'mul': [83, 100, 103], 'fudge': [1, 1, 1] }
}
def quadratic(x, a, b, c):
return (a * x) + b * (x ** 2) + c
def exponential(x, a, b, c):
return a + (b * np.exp(-c * x))
def apply_modifier(value, mod):
if mod == 0:
return value
elif mod > 0:
return value * mod
else:
return value * (1.0 + mod)
parser = argparse.ArgumentParser(description='Speed.')
parser.add_argument('-m', '--mass', type=float)
parser.add_argument('-s', '--speed', type=float, default=100)
parser.add_argument('-b', '--boost', type=float, default=100)
parser.add_argument('-O', '--mass-mod', type=float, default=1)
parser.add_argument('-M', '--multiplier-mod', type=float, default=1)
parser.add_argument('thruster')
args = parser.parse_args()
thruster = thrusters[args.thruster]
speed = args.speed
boost = args.boost
mod_mul = args.multiplier_mod
mod_mass = args.mass_mod
min_mul, opt_mul, max_mul = map(lambda m: apply_modifier(m / 100.0, mod_mul), thruster['mul'])
min_mass, opt_mass, max_mass = map(lambda m: apply_modifier(m, mod_mass), thruster['mass'])
mass = max(min_mass, args.mass)
fudge = thruster['fudge']
s = (float) (mass - min_mass) / (max_mass - min_mass)
m = (float) (opt_mass - min_mass) / (float) (max_mass - min_mass)
o = (float) (opt_mul - min_mul) / (float) (max_mul - min_mul)
x = [0, m, 1]
y = [max_mul * fudge[2], opt_mul * fudge[1], min_mul * fudge[0]]
func = quadratic if opt_mul == 1 else exponential
p, m = curve_fit(func, x, y)
multiplier = func(s, *p)
print '%s mass %.2f/%.2f/%.2f mul %.2f/%.2f/%.2f ship %.2fT mul %.2f -> speed %d boost %d' % (args.thruster, min_mass, opt_mass, max_mass, min_mul, opt_mul, max_mul, mass, multiplier, speed * multiplier, boost * multiplier)