A ship gets 18 "build points."
In order:
1-5 BP spent on HP at 1 BP = 25 HP (min 175). [BP spent is r; so HP = 150 + r * 25 ] *
0-5 BP spent on Armor at 1 BP = 2.75 armor (rounded down to the nearest integer) [BP spent is t]
2-9 BP spent on Damage at 1 BP = 3 damage [BP spent is m]
if the damage is 12 or lower, the unit gets Armor Piercing (free):
AP value is equal to 20 - (m * 5)
And m is recalculated to be m - 5 (low damage ships get a slight boost to speed and number of shots)
Speed is a function of HP, Armor, and Damage. Speed = 16 - (r+t+Math.ceil(m/1.75));
Number of shots is fiddly, but essentially, a random number squared times 6, rounded up. However, m plays a small portion in this as well: more damage, fewer shots.
Costs (NumShots * 3 / 4) round up.
Reload Speed is a function of damage and number of shots. (Damage * (NumShots-1, min 1) / 12)+1. Keeps things roughly in the same DPS area. More damage or more shots -> longer reload
Then some fiddly bits with speed to cut down on long range + speed combos as well as units that have near 0 speed. The former costs BP for units with speed > 10, the latter trades 2 BP for 3 speed (only if the unit's speed is less than 4). Both insure that there will still be adequate points for the range function below.
The remaining BP is spend on range: (pointsLeft-4)*(pointsLeft-4) + 25
*I am looking at allowing a wider range. Starting at 100, and making each BP worth 30.