im trying to create a genetic network. Its kids difficult to explain but heres the jist of what the program should currently do. When i run the program it should give a list of creatures and give each creature a number between one and ten. After that it will sort them from highest to lowest then get rid of the 5 smaller numbers.
var running = true
var breeding = function()
{
var parent1 = Math.floor((Math.random() * 6));
var parent2 = Math.floor((Math.random() * 6));
var child = (medium[parenta1] + medium[parenta2]) / 2
medium.push(child);;
}
var f1 = function()
{
if(dead = true)
{
breeding()
}
return c1 = Math.floor((Math.random() * 10) + 1);
};
var f2 = function()
{
if(dead = true)
{
breeding()
}
return c2 = Math.floor((Math.random() * 10) + 1);
};
var f3 = function()
{
if(dead = true)
{
breeding()
}
return c3 = Math.floor((Math.random() * 10) + 1);
};
var f4 = function()
{
if(dead = true)
{
breeding()
}
return c4 = Math.floor((Math.random() * 10) + 1);
};
var f5 = function()
{
if(dead = true)
{
breeding()
}
return c5 = Math.floor((Math.random() * 10) + 1);
};
var f6 = function()
{
if(dead = true)
{
breeding()
}
return c6 = Math.floor((Math.random() * 10) + 1);
};
var f7 = function()
{
if(dead = true)
{
breeding()
}
return c7 = Math.floor((Math.random() * 10) + 1);
};
var f8 = function()
{
if(dead = true)
{
breeding()
}
return c8 = Math.floor((Math.random() * 10) + 1);
};
var f9 = function()
{
if(dead = true)
{
breeding()
}
return c9 = Math.floor((Math.random() * 10) + 1);
};
var f10 = function()
{
if(dead = true)
{
breeding()
}
return c10 = Math.floor((Math.random() * 10) + 1);
};
var medium = [f1(), f2(), f3(), f4(), f5(), f6(), f7(), f8(), f9(), f10()];
for(i = 0; i < medium.length; i++)
{
document.write("creature " + (i + 1) + ": " + medium[i] + "<br>");
};
document.write('<br>');
var murder = function()
{
var orderOfKilling = medium.sort(function(a, b){return b-a});
document.write(orderOfKilling);
};
murder();
for(i = 0; i <= 4; i++)
{
medium.pop(i);
};
document.write('<br>');
document.write('<br>');
document.write(medium);