public void Mutate() { if (gen.GetRandom(set.mutationChancePointMax) == 0) { x = gen.GetRandom(); y = gen.GetRandom(); SetCalculated(false); } if (gen.WillMutate(set.mutationChancePointMed)) { x = Math.Max(0, Math.Min(1, x + 2 * (gen.GetRandom() - 0.5) * set.mutationAmountPointMed)); y = Math.Max(0, Math.Min(1, y + 2 * (gen.GetRandom() - 0.5) * set.mutationAmountPointMed)); SetCalculated(false); } if (gen.WillMutate(set.mutationChancePointMin)) { x = Math.Max(0, Math.Min(1, x + 2 * (gen.GetRandom() - 0.5) * set.mutationAmountPointMin)); y = Math.Max(0, Math.Min(1, y + 2 * (gen.GetRandom() - 0.5) * set.mutationAmountPointMin)); SetCalculated(false); } }
public void Mutate() { if (gen.WillMutate(set.mutationChanceAddPolygon) && polygons.Count < set.polygonCountMax) { int ind = gen.GetRandom(polygons.Count); polygons.Insert(ind, new DNAPolygon()); SetCalculated(false); } if (gen.WillMutate(set.mutationChanceRemovePolygon) && polygons.Count > set.polygonCountMin) { int ind = gen.GetRandom(polygons.Count); polygons.RemoveAt(ind); SetCalculated(false); } if (gen.WillMutate(set.mutationChanceMovePolygon) && polygons.Count > 0) { int ind = gen.GetRandom(polygons.Count); polygons.RemoveAt(ind); ind = gen.GetRandom(polygons.Count); polygons.Insert(ind, new DNAPolygon()); SetCalculated(false); } for (int i = 0; i < polygons.Count; ++i) { polygons[i].Mutate(); if (polygons[i].IsCalculated == false) { SetCalculated(false); } } }
public void Mutate() { if (gen.WillMutate(set.mutationChanceAddPoint) && points.Count < set.pointCountMax) { int ind = 1 + gen.GetRandom(points.Count); DNAPoint prev = points[ind - 1]; DNAPoint next = points[ind % points.Count]; DNAPoint newPoint = new DNAPoint(); newPoint.x = (prev.x + next.x) / 2; newPoint.y = (prev.y + next.y) / 2; points.Insert(ind, newPoint); SetCalculated(false); } if (gen.WillMutate(set.mutationChanceRemovePoint) && points.Count > set.pointCountMin) { int ind = gen.GetRandom(points.Count); points.RemoveAt(ind); SetCalculated(false); } for (int i = 0; i < points.Count; ++i) { points[i].Mutate(); if (points[i].IsCalculated == false) { SetCalculated(false); } } brush.Mutate(); if (brush.IsCalculated == false) { SetCalculated(false); } }
public void Mutate() { if (gen.WillMutate(set.mutationChanceAlpha)) { a = gen.GetRandom(set.minValueAlpha, set.maxValueAlpha + 1); SetCalculated(false); } if (gen.WillMutate(set.mutationChanceRed)) { r = gen.GetRandom(set.minValueRed, set.maxValueRed + 1); SetCalculated(false); } if (gen.WillMutate(set.mutationChanceGreen)) { g = gen.GetRandom(set.minValueGreen, set.maxValueGreen + 1); SetCalculated(false); } if (gen.WillMutate(set.mutationChanceBlue)) { b = gen.GetRandom(set.minValueBlue, set.maxValueBlue + 1); SetCalculated(false); } }