package com.capitalistlepton.model;

import java.util.Random;

/**
 * Created by zanelittrell on 2/5/17.
 */
public class Bacterium {

    private static final Random rand = new Random();

    private int x;
    private int y;
    private String genotype;

    public Bacterium(String parentGenotype, int x, int y) {
        float mutation = rand.nextFloat();
        if (mutation > 0.99f) {
            genotype = "AABBCc";
        } else {
            genotype = parentGenotype;
        }
        this.x = x;
        this.y = y;
    }

    public int getX() { return x; }
    public int getY() { return y; }
    public String getGenotype() { return genotype; }
}

@@ -180,16 +180,69 @@
 andom();
+%0A    private static final float mutationRate = 0.99f;
 %0A%0A    pr
@@ -375,343 +375,1146 @@
     
-float mutation = rand.nextFloat();%0A        if (mutation %3E 0.99f) %7B%0A            genotype = %22AABBCc%22;%0A        %7D else %7B%0A            genotype = parentGenotype;%0A        %7D%0A        this.x = x;%0A        this.y = y;%0A
+this.genotype = generateGenotype(parentGenotype);%0A        this.x = x;%0A        this.y = y;%0A    %7D%0A%0A    public int getX() %7B return x; %7D%0A    public int getY() %7B return y; %7D%0A    public String getGenotype() %7B return genotype; %7D%0A%0A    private static String generateGenotype(String parentGenotype) %7B%0A        StringBuilder gen = new StringBuilder(parentGenotype);%0A        for (int i = 0; i %3C parentGenotype.length(); i += 2) %7B%0A            if (rand.nextFloat() %3E mutationRate) %7B%0A                if (rand.nextFloat() %3E 0.75f) %7B%0A                    gen.setCharAt(i, Character.toLowerCase(gen.charAt(i)));%0A         
     
-%7D%0A%0A
     
-public int getX() %7B return x; %7D%0A    public int getY() %7B return y; %7D%0A    public String getGenotype() %7B return genotype;
+   gen.setCharAt(i+1, Character.toLowerCase(gen.charAt(i+1)));%0A                %7D else if(rand.nextFloat() %3E 0.5f) %7B%0A                    gen.setCharAt(i, Character.toTitleCase(gen.charAt(i)));%0A                    gen.setCharAt(i+1, Character.toLowerCase(gen.charAt(i+1)));%0A                %7D else %7B%0A                    gen.setCharAt(i, Character.toUpperCase(gen.charAt(i)));%0A                    gen.setCharAt(i+1, Character.toUpperCase(gen.charAt(i+1)));%0A                %7D%0A            %7D%0A        %7D%0A        return gen.toString();%0A   
  %7D%0A%7D

Add random mutation method for when bacteria are created.