Code:
public void dam_data_setup()
{
// fill list
damgtype.Add( den1);
damgtype.Add( den2);
damgtype.Add( da1);
damgtype.Add( da2);
damgtype.Add( db1);
damgtype.Add( db2);
damgtype.Add( dc1);
damgtype.Add( dc2);
damgtype.Add( dd1);
damgtype.Add( dd2);
damgtype.Add( de1);
damgtype.Add( de2);
damgtype.Add( dv1);
damgtype.Add( dv2);
// convert list to array
int[] dam = damgtype.ToArray();
int dx = 0; // dam data array pointer
den = 1; da = 1; db = 1; dc = 1; dd = 1; de = 1; dv = 1; //sets array col position counters to starting values
int broken_max = rows, agouti_max = (broken_max / 2), brown_max = (agouti_max / 2), colour_max = (brown_max / 2), dilute_max = (colour_max / 2), ext_max = (dilute_max / 2), vienna_max = (ext_max / 2);
int dam_dom_dilute = (dd / (dilute_max / 2));
do
{
// loading array right to left. starts by loading all itirations of broken starting with the Dominant gene (locii)
// when gene counter is > 1/2 gene max counter; recessive is loaded
{ //broken
if ( den <= (broken_max / 2))
{
damdata[dx, 0] = dam[0];
}
else
{
damdata[dx, 0] = dam[1];
}
den++;
if ( den > broken_max)
{ den = 1; }
}
{
// Agouti
if ( da <= (agouti_max / 2))
{ damdata[dx, 1] = dam[2]; }
else if ( da > (agouti_max / 2)) { damdata[dx, 1] = dam[3]; }
da++;
if ( da > agouti_max) { da = 1; } // resets Agouti counter
}
{
// Brown
if ( db <= (brown_max / 2))
{ damdata[dx, 2] = dam[4]; }
else if ( db > (brown_max / 2)) { damdata[dx, 2] = dam[5]; }
db++;
if ( db > brown_max) { db = 1; } // resets Brown counter
}
{
// Colour
if ( dc <= (colour_max / 2))
{ damdata[dx, 3] = dam[6]; }
else if ( dc > (colour_max / 2)) { damdata[dx, 3] = dam[7]; }
dc++;
if ( dc > colour_max) { dc = 1; } // resets Colour counter
}
{ // Dilute
if (dd > (dilute_max / 2))
{ damdata[dx, 3] = dam[9]; }
else if (dd <= (dilute_max / 2)) { damdata[dx, 4] = dam[8]; }
sd++;
if ( dd > dilute_max) { dd = 1; } // resets Dilute counter
}
{
// Extension
if ( de > (ext_max / 2))
{ damdata[dx, 5] = dam[11]; }
else if ( de <= (ext_max / 2)) { damdata[dx, 5] = dam[10]; }
de++;
if ( de > ext_max) { de = 1; } // resets Extension counter
}
{
// Vienna
if ( dv > (vienna_max / 2))
{
damdata[dx, 6] = dam[13];
}
else if ( dv <= (vienna_max / 2))
{
damdata[dx, 6] = dam[12];
}
dv++;
if ( dv > vienna_max) { dv = 1; } // resets vienna counter
}
dx++;
} // end do bracket
while (dx < rows); // end do while loop
return;
}
This is a genetics program and is to parse the source array and write all possible combinations to a new array.
All sections but dilute work correctly. For some reason the dilute's Boolean is not testing true when it should. This is causing data corruption. What am I doing wrong?