Exemple #1
0
        //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);
        }
Exemple #2
0
        protected static List <int> ResolveProbabilities(ActorGeneSetInt geneSet, List <int> populationAttributes)
        {
            var probabilities = new List <int>();

            for (var i = geneSet.Min; i < geneSet.Max; i++)
            {
                //Everyone should have at least a little chance
                probabilities.Add(i);

                var count = populationAttributes.Count(a => a == i);
                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);
        }