Hello friends,
I am programming a genome that’s made of chromosomes. Each chromosome is an array. Each defines its values through symmetry producing operations (symmetry as in retrogrades of the integer sequence of its segments).
I made a function for this, so that I can call it in setup. It makes an array called tempChromosome. I would like that array to define each separate chromosome array. The problem is that it is defining all of the chromosomes as the same, as you can see in the console, but I want them to be different from each other!
int[] tempChromosome = new int[16];
int[] chromosome0 = new int[16];
int[] chromosome1 = new int[16];
int[] chromosome2 = new int[16];
int[] chromosome3 = new int[16];
int[] chromosome4 = new int[16];
int[] chromosome5 = new int[16];
//int[] genotype = new int[6];
void setup() {
determineSymmetry(); //stochastic generation of number pattern. it defines tempChromosome.
chromosome0 = tempChromosome;
determineSymmetry(); //I would like this to redefine tempChromosome, so that chromosome1 is different from chromosome0.
chromosome1 = tempChromosome;
determineSymmetry(); // and so on, with each call to the function..., so that every chromosome is different.
chromosome2 = tempChromosome;
determineSymmetry();
chromosome3 = tempChromosome;
determineSymmetry();
chromosome4 = tempChromosome;
determineSymmetry();
chromosome5 = tempChromosome;
println("=o=o=o=o=chromosome0");
printArray(chromosome0);
println("=o=o=o=o=chromosome1");
printArray(chromosome1);
println("=o=o=o=o=chromosome2");
printArray(chromosome2);
println("=o=o=o=o=chromosome3");
printArray(chromosome3);
println("=o=o=o=o=chromosome4");
printArray(chromosome4);
println("=o=o=o=o=chromosome5");
printArray(chromosome5);
}
void draw() {
}
int[] determineSymmetry() {
for (int i = 0; i < 4; i++) {
tempChromosome[i] = int(random(5));
}
float smallSymm1 = random(3);
float largeSymm = random(3);
float smallSymm2 = random(3);
if (smallSymm1 < 1) { //repeat sequence
tempChromosome[4] = tempChromosome[0];
tempChromosome[5] = tempChromosome[1];
tempChromosome[6] = tempChromosome[2];
tempChromosome[7] = tempChromosome[3];
} else if (smallSymm1 < 2) { //retrograde sequence
tempChromosome[4] = tempChromosome[3];
tempChromosome[5] = tempChromosome[2];
tempChromosome[6] = tempChromosome[1];
tempChromosome[7] = tempChromosome[0];
} else {
for (int i = 4; i < 8; i++) { //generate another random sequence
tempChromosome[i] = int(random(5));
}
}
if (largeSymm < 1) { //repeat sequence (large scale)
tempChromosome[8] = tempChromosome[0];
tempChromosome[9] = tempChromosome[1];
tempChromosome[10] = tempChromosome[2];
tempChromosome[11] = tempChromosome[3];
tempChromosome[12] = tempChromosome[4];
tempChromosome[13] = tempChromosome[5];
tempChromosome[14] = tempChromosome[6];
tempChromosome[15] = tempChromosome[7];
} else if (largeSymm < 2) { //retrograde sequence (large scale)
tempChromosome[8] = tempChromosome[7];
tempChromosome[9] = tempChromosome[6];
tempChromosome[10] = tempChromosome[5];
tempChromosome[11] = tempChromosome[4];
tempChromosome[12] = tempChromosome[3];
tempChromosome[13] = tempChromosome[2];
tempChromosome[14] = tempChromosome[1];
tempChromosome[15] = tempChromosome[0];
} else {
for (int i = 8; i < 12; i++) { //generate another random sequence of four numbers
tempChromosome[i] = int(random(5));
}
if (smallSymm2 < 1) { //repeat sequence
tempChromosome[12] = tempChromosome[8];
tempChromosome[13] = tempChromosome[9];
tempChromosome[14] = tempChromosome[10];
tempChromosome[15] = tempChromosome[11];
} else if (smallSymm2 < 2) { //retrograde sequence
tempChromosome[12] = tempChromosome[11];
tempChromosome[13] = tempChromosome[10];
tempChromosome[14] = tempChromosome[9];
tempChromosome[15] = tempChromosome[8];
} else {
for (int i = 12; i < 16; i++) { //generate another random sequence
tempChromosome[i] = int(random(5));
}
}
}
return tempChromosome;
}
I feel this is simple to fix but I don’t know how. Help would be appreciated. Thank you.