public Gene Clone(float mutationProb) { PhysicsU.Directions newDirection = GetDirection(); CellType newType = GetCellType(); if (Random.value < mutationProb) { if (Random.value < 0.5) { newDirection = GetRandomDirection(); } else { newType = GetRandomType(); } } return(new Gene(newDirection, newType)); }
private void PopulateCellMatrix(ref CellType[,] CellMatrix) { List <Gene> Genes = DNA.GetGenes(); Point pos = BaseU.GetMatrixMid(CellMatrix); foreach (Gene gene in Genes) { CellType type = gene.GetCellType(); PhysicsU.Directions dir = gene.GetDirection(); Vector2 dirVec = PhysicsU.Dir2Vec(dir); pos.x += (int)dirVec.x; pos.y += (int)dirVec.y; pos.x = MathU.MinMax(pos.x, 0, CellMatrix.GetLength(0) - 1); pos.y = MathU.MinMax(pos.y, 0, CellMatrix.GetLength(1) - 1); CellMatrix[pos.x, pos.y] = type; } }
public GameObject GetCoupledAt(PhysicsU.Directions anchorDir) { IDictionary <PhysicsU.Directions, GameObject> Coupleds = GetCoupleds(); return(Coupleds[anchorDir]); }
public Gene() { Direction = GetRandomDirection(); Type = GetRandomType(); }
public Gene(PhysicsU.Directions direction, CellType type) { Direction = direction; Type = type; }