CleverRaven/Cataclysm-DDA — pull request #7089 by 1player (2014-04-08 11:04:46+00:00)
Title: Random charges for spawned tools

Why all the flashlights we find have 100 charges? Why can't we find in the wild an empty lighter?

With this changes, the charges of tools are randomly selected from ca. 40 possible values:
I checked the tools with initial_charges > 0, and generated a set of 40 numbers inspired the Preferred Number formula (https://en.wikipedia.org/wiki/Preferred_number), i.e. if a flashlight had 100 initial charges, now it's randomly chosen between [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 15, 16, 18, 20, 23, 26, 29, 32, 36, 40, 45, 51, 57, 64, 71, 80, 90, 100]

That's the hackish python function to generate the series:
```
def charges(maxc, n=40):
n = [int(math.ceil(maxc**(float(i)/n))) for i in range(n)]
n.append(maxc)
n.append(0)
return sorted(set(n))
```

Basically, for all numbers between 0 and "initial_charges", calculate 10 ^ (i / 40), where 40 is the number of steps.