Open tesseradecades opened 5 years ago
While the GA portion is easy, the difficult part is handling the domain in python. In DnD, each character has a race, a background, and a class which all grant different abilities. A character is a collection of basic stats that are modified by these abilities, and even then some abilities effect the character more abstractly. While the calculations are accomplishable in python, the class structure is difficult to represent in python's module system, as characters need to know what abilities they have, and for the sake of being able to modify them, abilities need to know what characters are. This creates a circular dependency that goes down and then up the package tree. A new method of ability realization must be realized.
One possibility is to implement Phenotype
as a CharacterFactory
on the domain side. Phenotype will take in an array of bits(the Genes), and decode them to the proper abilities, which it will then store in a set. This set of Abilities, in combination with the starting stats(also decoded from the genes), will determine all of the Character
's concrete stats, as well as their effective stats for the purpose of calculating CR. This way, Character
doesn't have to know about Ability
, removing the circular dependency.
Thus Phenotype
is as follows
class Phenotype: +generateCharacter(genes:array,level:int)->Character -getStats() -getRace() -getBackground() -getClass()
The Character
has
HP
AC
INITIATIVE
SPEED
STRENGTH SCORE
STRENGTH MODIFIER
DEXTERITY SCORE
DEXTERITY MODIFIER
CONSTITUTION SCORE
CONSTITUTION MODIFIER
INTELLIGENCE SCORE
INTELLIGENCE MODIFIER
WISDOM SCORE
WISDOM MODIFIER
CHARISMA SCORE
CHARISMA MODIFIER
SAVING THROWS
SAVING THROW PROFICIENCIES
SKILLS
SKILL PROFICIENCIES
WEAPON PROFICIENCIES
LANGUAGE PROFICIENCIES
TOOL PROFICIENCIES
ATTACKS
EXPERTISE
For Cohesion and accomplishment, it makes sense to split this project. The first space is devoted to the genetic algorithm portion where the different classes of genetic algorithms shall exist and be capable of running. The second space is the domain.
The GA needs to provide a single endpoint, which takes a GENOME_LENGTH, ALGORITHM_CLASS, ALGORITHM_CLASS_ARGS, and a FITNESS_URL. In order to run, it must be provided with an endpoint that takes an array of integers, and returns a float. The GA can then return an array of integers representing the genome of the fittest individual it could produce.
The domain must provide the above endpoint for the GA, allowing the domain to be responsible for the computation of an individual's fitness.