Obligatory GitHub repository link.

I want to say like, a week ago I finished the logic for “optimizing” a character’s armor equipment. It did this by starting with either the heaviest armor (period), or the heaviest ‘light’ armor, then searching the character’s inventory for a matching type.

For example, a fighter would try to find plate armor in his inventory. Failing that, he’d look for splint. Then chain mail. Until he found one and put it on. A ranger by contrast, would check to see if he had Dexterity greater than 15, in which case he’d try to equip studded leather, then leather, etc. If the ranger’s Dexterity were 15 or less, he’d start by looking for half plate (the heaviest medium armor).

Originally I used a big switch statement to cycle from the heaviest to the least heavy armor (all their types are enumerated). When I started on the algorithm to optimize weapons, I came up with a um, better way to do it.

Rather than using a switch and re-sorting it manually (since weapons are a bit more complex than armor) every time I want to create a new selection method, it occurred to me to just create an array of weapon types and pass them, one at a time, to a pair of “can equip” and “is carrying” functions.

So the other night, I implemented the first version of my weapon optimization function and ran a bunch of tests on it. I’m delighted to say that I can presently arm a million NPCs in about 62 seconds. There’s more I could do to streamline the process. As it stands, I should probably have unique methods for determining the optimal weapon load-out for each class (at least).

I’m trying to think a little more abstract than that though… I’m thinking of using 4e’s combat roles to guide equipment choices, and take ability scores and character class as parameters. I might have to write a different selection process for all 12 classes, but it’s something I should only have to do once.

Alternatively, I might make it a two-step process where ability scores inform one half of the process, and character class supplies the rest–either confirming the choice made at the ability level, or suggesting like, a split or hybrid role. I don’t know, obviously I haven’t written it yet.

There is a TON of stuff left to do.

For starters, all this generation occurs at 1st level only. While I have implemented a Challenge Rating evaluation process, I have yet to see a character generated with a CR greater than “-4” which would be the equivalent of like, CR 1/10 or 1/12 or whatever. (5e CR only goes as low as 1/2, 1/4, and 1/8)

I haven’t decided yet if I want to implement leveling first, or like, basic combat mechanics. I could go either way.