tesseradecades / dndCharGASandbox

A thought experiment in creating dnd characters using genetic algorithms
0 stars 0 forks source link

Individual Character #1

Closed tesseradecades closed 5 years ago

tesseradecades commented 5 years ago

There must be a class Individual which has...

tesseradecades commented 5 years ago

Fitness

Fitness shall be determined in X steps

  1. Parse the genes array for the abilityScoreGenes ,raceGenes, and classGenes
  2. Use the abilityScoreGenes to determine the character's starting ability scores
  3. Use the raceGenes to determine the character's race and added abilities
  4. Use the classGenes to determine the character's class, and thus the strategy that shall be used to calculate it's Phenotype
  5. The Phenotype is the judged using the DMG's formula for CR rating to determine the fitness
tesseradecades commented 5 years ago

Genes

Genes shall be represented as a fixed length array of bits. Different sections of the array shall determine different things about the individual.

  1. The first 135 bits shall determine the distribution of the character's starting ability scores.
  2. The next Y bits shall determine the character's race and subrace where Y is equal to the number of subraces the can be picked from
  3. The next Z bits shall determine the character's class and subclass where Z is equal to the number of subclasses that can be picked from

Thus the final gene array

[ability score,race,class] [0]*135+[0,0,0,0,0,0,0,0,0,0,0,0,0]+[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

tesseradecades commented 5 years ago

Ability Score Determination

The first 135 bits are broken into groups of 5, where the number of active bits determines which ability each group gives a point to.

0 -> Str 1 ->Dex 2 ->Con 3 ->Int 4 -> Wis 5 -> Cha

Unusable Chromosomes

In biology, everyone gets a set of chromosomes from each of their parents. In humans and most mammals, this means each chromosome is paired(one from mom, and one from dad). However, occasionally one of these chromosomes is unusable. Maybe during crossing over, one ended up taking a bit of extra DNA, leaving the other too short to be usable. Maybe a mutation occurred, causing the DNA at a particular point of the chromosome to be unusable. This is why genetic diversity is important. If one chromosome in the pair is unusable, normally the DNA from the other is used. If both chromosomes are unusable, then that's where we start seeing birth defects, and genetic diseases.

In the context of the chromosomes used here, an unusable chromosome is one that cannot possibly render a valid phenotype. The most obvious of which is one where the ability score genes violate the rules of stat generation(we're going with point buy for simplicity's sake).

Some examples are

  1. Devoting more than 9 points to any single stat
  2. Devoting 6 or 8 points to any single stat
  3. Not devoting all 27 points

What do in this case? Is the individual still created with it's deformities? Do we rectify this at every gene assignment?

The proposed solution is to allow the character to be created, but impose limits upon the max ability score at phenotype generation. Even though it will be possible to spend all 27 points in strength, the strength score shall be no different than if you spent 18 points in strength. This will partially mitigate things, however very SAD builds will be less punished by this than the more MAD ones. A Barbarian will be significantly less punished for only spending on Str and Con than a Paladin when CR calculation comes into play. Maybe the solution is to modify the fitness calculation to incorporate skills and saving throws in addition to CR.

tesseradecades commented 5 years ago

Thus, the final genome of an individual is [point 1], [point 2], [point 3], [point 4], [point 5], [point 6], [point 7], [point 8], [point 9], [point 10], [point 11], [point 12], [point 13], [point 14], [point 15], [point 16], [point 17], [point 18], [point 19], [point 20], [point 21], [point 22], [point 23], [point 24], [point 25], [point 26], [point 27], [race], [class]

Where each of the point chromosomes is 5 bits long, the race chromosome is 13(# of PHB subraces-1) bits long, and the class chromosome is 40(# of PHB subclasses-1) bits long, making the entire genome a 188 bit array