//TODO: validate this protected static List <double> ResolveProbabilities(ActorGeneSetDouble geneSet, List <double> populationAttributes) { var probabilities = new List <double>(); for (var i = Math.Floor(geneSet.Min); i < Math.Ceiling(geneSet.Max); i++) { //Everyone should have at least a little chance probabilities.Add(i); //we're effectively mapping back to ints here for better or worse var count = populationAttributes.Count(a => a > i - 0.5 && a < i + 0.5); for (var j = 0; j < count; j++) { //Weight towards the things that exist for (var l = 0; l < populationAttributes.Count / 100; l++) { probabilities.Add(i); } probabilities.Add(i); } } return(probabilities); }
//TODO: validate this //TODO: can this just call the other version ^ protected static List <List <double> > ResolveProbabilities(ActorGeneSetInt geneSetOuter, ActorGeneSetDouble geneSetInner, List <List <double> > populationAttributes) { var probabilityList = new List <List <double> >(); for (var i = geneSetOuter.Min; i < geneSetOuter.Max; i++) { var probabilities = new List <double>(); for (var j = Math.Floor(geneSetInner.Min); j < Math.Ceiling(geneSetInner.Max); j++) { //Everyone should have at least a little chance probabilities.Add(j); if (populationAttributes.Count <= i) { continue; } //we're effectively mapping back to ints here for better or worse var count = populationAttributes[i].Count(a => a > j - 0.5 && a < j + 0.5); for (var k = 0; k < count; k++) { //Weight towards the things that exist for (var l = 0; l < populationAttributes.Count / 100; l++) { probabilities.Add(i); } probabilities.Add(j); } } probabilityList.Add(probabilities); } return(probabilityList); }