A piece of my
previous post mentioned that I had yet to write a means of changing Pendragon traits after that had been rolled. I want to be able to easily adjust distribution of character traits on the fly, for reasons of player character race, culture, class, alignment, or any other factor I can imagine. For example, Chaotic characters were classically more associated with demons, the unsavory, and generic villainous Bad Guys, and such people are also typically associated with various flaws, both physical and spiritual. So if the character generator determines that this is a Chaotic character, the code needs a means of biasing the scores negatively. Meanwhile, Dwarves may stereotypically (and now actually, per the dictates of the RNG) exhibit certain behaviors more often than the baseline-human, and so adjustments to make them more selfish, honest, vengeful, and valorous would be appropriate.
|
JSFiddle is pretty handy |
I wrote and tested my code on
JSFiddle which I have found is a very convenient environment in which to code. You can see it here, colored and indented for readability, the code in question. This simple function "incTra" takes in two elements when it is called, a trait and a value. The body of the code first combines the 13 vices with the 13 virtues so that they can be trivially accessed at the same time in the variable "all". Then it takes the traits element pointed to when called and converts it to lowercase purely for functionality and to dodge potential future goofs. Then the meat of the function:
- it searches out the pointed-to trait from the combined list
- if the element is a vice (which we determine by it being among the first 13 elements) it subtracts the value from the trait, biasing it negatively
- otherwise, it adjusts the trait score upwards, biasing a positive result
|
Chances of a 3d6 roll summing to at most a specific
number, from Anydice, also handy |
Through some playing around with it I found that an adjustment of 2 caused the results to skew one way more often at a reasonable frequency. Obviously, with a range of 3-18, and money numbers showing up in the ranges of 3-7 and 14-18, adjusting it by as much as 4 ensures that extreme results occur exceptionally rarely (adjusting +4 ensures that negative results occur only on a roll of 3 in 3d6, an occurrence with just .46% chance). A bias of 2 would produce negative results approximately 7%, while an adjustment of just 1 would move that up to 16%, which is actually really close to the 1-in-6 chance favored by Gary's game.
No comments:
Post a Comment