public void Init(Brain brain, GeneticCode GCode, Vector2 pos, Vector2 ang) { this.brain = brain; Genotype = GCode; stats = new Stats(new List <StatGene>()); stomac = new Stomac(this); stats = new Stats(Genotype.GetGenes(), this); brain.owner = this; position = pos; orientation = ang; }
public GeneticCode(GeneticCode parent) { genes = new List <Gene>(); foreach (var g in parent.GetGenes()) { foreach (var m in g.Mutate()) { genes.Add(m); } } fillerCode = parent.MutateFiller(); decoded = true; }
public List <Gene> GetGenes(params GeneTypes[] type) { HashSet <string> strings = new HashSet <string>(); for (int i = 0; i < type.Length; i++) { switch (type[i]) { case GeneTypes.BrainGene: strings.Add("VH"); break; case GeneTypes.hearing: strings.Add("HHV"); break; case GeneTypes.input: strings.Add("HH"); break; case GeneTypes.pheromone: strings.Add("HHO"); strings.Add("HHX"); break; case GeneTypes.proteinBD: strings.Add("HV"); break; case GeneTypes.proteinGene: strings.Add("HV"); strings.Add("HO"); break; case GeneTypes.proteinS: strings.Add("HO"); break; case GeneTypes.statGene: strings.Add("HX"); break; case GeneTypes.vision: strings.Add("HHH"); break; case GeneTypes.outputGeneP: strings.Add("VVV"); strings.Add("VVH"); break; } } var output = new List <Gene>(); foreach (var g in Genotype.GetGenes()) { if (strings.Contains(g.GetGeneticString().Substring(0, 3)) || strings.Contains(g.GetGeneticString().Substring(0, 2))) { output.Add(g); } } return(output); }