示例#1
0
        public static int GetMilWeight(int height, DateTime birthdate, BiologicalSex sex)
        {
            var rv = AnimatorRandom.Rand.Next(5);

            if (rv == 0)
            {
                return(GetMilWeight(height, birthdate, sex, MilitaryBranch.USAF));
            }
            else if (rv == 1)
            {
                return(GetMilWeight(height, birthdate, sex, MilitaryBranch.USARMY));
            }
            else if (rv == 2)
            {
                return(GetMilWeight(height, birthdate, sex, MilitaryBranch.USCG));
            }
            else if (rv == 3)
            {
                return(GetMilWeight(height, birthdate, sex, MilitaryBranch.USMC));
            }
            else
            {
                return(GetMilWeight(height, birthdate, sex, MilitaryBranch.USN));
            }
        }
示例#2
0
        public static int GetHeight(BiologicalSex sex)
        {
            //Generates height using Box-Muller transform
            double mean;
            double std;
            double u1            = 1.0 - AnimatorRandom.Rand.NextDouble();
            double u2            = 1.0 - AnimatorRandom.Rand.NextDouble();
            double randStdNormal = Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2);

            if (sex == BiologicalSex.Male)
            {
                mean = 68.9;
                std  = 2.84;
            }
            else
            {
                mean = 63.62;
                std  = 2.52;
            }

            double randNormal = mean + std + randStdNormal;
            int    inches     = RoundDouble(randNormal);

            return(inches);
        }
示例#3
0
        public static int GetMilHeight(BiologicalSex sex, MilitaryBranch branch = MilitaryBranch.USARMY)
        {
            double mean;
            double std;
            double u1;
            double u2;
            double randStdNormal;
            double randNormal;
            int    inches;

            int low  = 60;
            int high = 80;

            if (sex == BiologicalSex.Female)
            {
                low  = 58;
                high = 80;
            }
            if (branch == MilitaryBranch.USMC)
            {
                low  = 58;
                high = 78;
                if (sex == BiologicalSex.Female)
                {
                    high = 72;
                }
            }

            do
            {
                u1            = 1.0 - AnimatorRandom.Rand.NextDouble();
                u2            = 1.0 - AnimatorRandom.Rand.NextDouble();
                randStdNormal = Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2);

                if (sex == BiologicalSex.Male)
                {
                    mean = 68.9;
                    std  = 2.84;
                }
                else
                {
                    mean = 63.62;
                    std  = 2.52;
                }

                randNormal = mean + std + randStdNormal;
                inches     = RoundDouble(randNormal);
            } while (inches < low || inches > high);

            return(inches);
        }
示例#4
0
 public BiologicalSexDatum(DateTimeOffset timestamp, BiologicalSex sex)
     : base(timestamp)
 {
     _sex = sex;
 }
示例#5
0
    public static void CreateHawk(float speed, float foodViewRange, float waterViewRange, float flybySpeedRate, Vector3 spawnPosition, BiologicalSex sex)
    {
        HawkDNA  dna      = new HawkDNA();
        Mutation mutation = new Mutation();

        dna.speed          = mutation.MutateGene(speed, DNA.SPEED_MIN, DNA.SPEED_MAX);
        dna.foodViewRange  = mutation.MutateGene(foodViewRange, DNA.FOODVIEWRANGE_MIN, DNA.FOODVIEWRANGE_MAX);
        dna.waterViewRange = mutation.MutateGene(waterViewRange, DNA.WATERVIEWRANGE_MIN, DNA.FOODVIEWRANGE_MAX);
        dna.flybySpeedRate = mutation.MutateGene(flybySpeedRate, HawkDNA.FLYBY_SPEEDRATE_MIN, HawkDNA.FLYBY_SPEEDRATE_MAX);

        dna.sex = sex;

        Hawk hawk;

        if (dna.sex == BiologicalSex.Male)
        {
            hawk = Instantiate(Instance.maleHawk, spawnPosition, Quaternion.identity).GetComponent <Hawk>();
        }
        else
        {
            hawk = Instantiate(Instance.femaleHawk, spawnPosition, Quaternion.identity).GetComponent <Hawk>();
        }

        AnimalStatistics.Instance.AddAnimal(hawk);
        hawk.Initialize(dna);
    }
示例#6
0
    public static void CreateMonkey(float speed, float foodViewRange, float waterViewRange, Vector3 spawnPosition, BiologicalSex sex)
    {
        MonkeyDNA dna      = new MonkeyDNA();
        Mutation  mutation = new Mutation();

        dna.speed          = mutation.MutateGene(speed, DNA.SPEED_MIN, DNA.SPEED_MAX);
        dna.foodViewRange  = mutation.MutateGene(foodViewRange, DNA.FOODVIEWRANGE_MIN, DNA.FOODVIEWRANGE_MAX);
        dna.waterViewRange = mutation.MutateGene(waterViewRange, DNA.WATERVIEWRANGE_MIN, DNA.FOODVIEWRANGE_MAX);

        dna.sex = sex;

        Monkey monkey;

        if (dna.sex == BiologicalSex.Male)
        {
            monkey = Instantiate(Instance.maleMonkey, spawnPosition, Quaternion.identity).GetComponent <Monkey>();
        }
        else
        {
            monkey = Instantiate(Instance.femaleMonkey, spawnPosition, Quaternion.identity).GetComponent <Monkey>();
        }

        AnimalStatistics.Instance.AddAnimal(monkey);
        monkey.Initialize(dna);
    }
示例#7
0
        //TODO: Update to reflect weight distribution statistics instead of even distribution within bounds
        public static int GetMilWeight(int height, DateTime birthdate, BiologicalSex sex, MilitaryBranch branch)
        {
            string input   = File.ReadAllText("config/military_height_weight.json");
            var    hwChart = JsonConvert.DeserializeObject <MilitaryHeightWeight.MilitaryHeightWeightManager>(input);
            int    age     = DateTime.Now.Year - birthdate.Year;

            if (DateTime.Now.Month < birthdate.Month)
            {
                age -= 1;
            }
            if (DateTime.Now.Month == birthdate.Month && DateTime.Now.Day < birthdate.Day)
            {
                age -= 1;
            }
            int min;
            int max;

            if (branch == MilitaryBranch.USAF)
            {
                var b = hwChart.Branches.FirstOrDefault(x => x.Branch == "USAF");
                var h = b.Heights.FirstOrDefault(x => x.Height == height);
                min = h.MinWeight;
                max = h.MaxWeight;
            }
            else if (branch == MilitaryBranch.USCG)
            {
                var b = hwChart.Branches.FirstOrDefault(x => x.Branch == "USCG");
                var h = b.Heights.FirstOrDefault(x => x.Height == height);
                min = h.MinWeight;
                max = h.MaxWeight;
            }
            else if (branch == MilitaryBranch.USMC)
            {
                var b = hwChart.Branches.FirstOrDefault(x => x.Branch == "USMC");
                if (sex == BiologicalSex.Male)
                {
                    var s = b.Sexes.FirstOrDefault(x => x.Sex == "Male");
                    var h = s.Heights.FirstOrDefault(x => x.Height == height);
                    min = h.MinWeight;
                    max = h.MaxWeight;
                }
                else
                {
                    var s = b.Sexes.FirstOrDefault(x => x.Sex == "Female");
                    var h = s.Heights.FirstOrDefault(x => x.Height == height);
                    min = h.MinWeight;
                    max = h.MaxWeight;
                }
            }
            else if (branch == MilitaryBranch.USN)
            {
                var b = hwChart.Branches.FirstOrDefault(x => x.Branch == "USN");
                if (sex == BiologicalSex.Male)
                {
                    var s = b.Sexes.FirstOrDefault(x => x.Sex == "Male");
                    var h = s.Heights.FirstOrDefault(x => x.Height == height);
                    min = h.MinWeight;
                    max = h.MaxWeight;
                }
                else
                {
                    var s = b.Sexes.FirstOrDefault(x => x.Sex == "Female");
                    var h = s.Heights.FirstOrDefault(x => x.Height == height);
                    min = h.MinWeight;
                    max = h.MaxWeight;
                }
            }
            else
            {
                var b = hwChart.Branches.FirstOrDefault(x => x.Branch == "USARMY");
                if (sex == BiologicalSex.Male)
                {
                    var s = b.Sexes.FirstOrDefault(x => x.Sex == "Male");
                    if (age < 21)
                    {
                        var a = s.Ages.FirstOrDefault(x => x.Age == 17);
                        var h = a.Heights.FirstOrDefault(x => x.Height == height);
                        min = h.MinWeight;
                        max = h.MaxWeight;
                    }
                    else if (age < 28)
                    {
                        var a = s.Ages.FirstOrDefault(x => x.Age == 21);
                        var h = a.Heights.FirstOrDefault(x => x.Height == height);
                        min = h.MinWeight;
                        max = h.MaxWeight;
                    }
                    else if (age < 40)
                    {
                        var a = s.Ages.FirstOrDefault(x => x.Age == 28);
                        var h = a.Heights.FirstOrDefault(x => x.Height == height);
                        min = h.MinWeight;
                        max = h.MaxWeight;
                    }
                    else
                    {
                        var a = s.Ages.FirstOrDefault(x => x.Age == 40);
                        var h = a.Heights.FirstOrDefault(x => x.Height == height);
                        min = h.MinWeight;
                        max = h.MaxWeight;
                    }
                }
                else
                {
                    var s = b.Sexes.FirstOrDefault(x => x.Sex == "Female");
                    if (age < 21)
                    {
                        var a = s.Ages.FirstOrDefault(x => x.Age == 17);
                        var h = a.Heights.FirstOrDefault(x => x.Height == height);
                        min = h.MinWeight;
                        max = h.MaxWeight;
                    }
                    else if (age < 28)
                    {
                        var a = s.Ages.FirstOrDefault(x => x.Age == 21);
                        var h = a.Heights.FirstOrDefault(x => x.Height == height);
                        min = h.MinWeight;
                        max = h.MaxWeight;
                    }
                    else if (age < 40)
                    {
                        var a = s.Ages.FirstOrDefault(x => x.Age == 28);
                        var h = a.Heights.FirstOrDefault(x => x.Height == height);
                        min = h.MinWeight;
                        max = h.MaxWeight;
                    }
                    else
                    {
                        var a = s.Ages.FirstOrDefault(x => x.Age == 40);
                        var h = a.Heights.FirstOrDefault(x => x.Height == height);
                        min = h.MinWeight;
                        max = h.MaxWeight;
                    }
                }
            }
            return(CalcMilWeight(min, max));
        }
示例#8
0
        /*
         * //Depricated
         * private static int StrHeightToIntHeight(string height)
         * {
         *  var data = height.Split('\'');
         *  data[0].Trim();
         *  data[1].TrimEnd('"');
         *  int feet = Convert.ToInt32(data[0]);
         *  int inches = Convert.ToInt32(data[1]);
         *  return feet * 12 + inches;
         * }
         */

        public static int GetWeight(int height, BiologicalSex sex)
        {
            int weightClass = AnimatorRandom.Rand.Next(0, 1000);
            int bmi;

            if (sex == BiologicalSex.Male)
            {
                if (weightClass < 55)
                {
                    //Extreme Obesity (40-54)
                    bmi = AnimatorRandom.Rand.Next(40, 55);
                }
                else if (weightClass < 350)
                {
                    //Obese(30-39)
                    bmi = AnimatorRandom.Rand.Next(30, 40);
                }
                else if (weightClass < 737)
                {
                    //Overweight(25-29)
                    bmi = AnimatorRandom.Rand.Next(25, 30);
                }
                else
                {
                    //Normal Weight(19-24)
                    bmi = AnimatorRandom.Rand.Next(19, 25);
                }
            }
            else
            {
                if (weightClass < 99)
                {
                    bmi = AnimatorRandom.Rand.Next(40, 55);
                }
                else if (weightClass < 404)
                {
                    bmi = AnimatorRandom.Rand.Next(30, 40);
                }
                else if (weightClass < 669)
                {
                    bmi = AnimatorRandom.Rand.Next(25, 30);
                }
                else
                {
                    bmi = AnimatorRandom.Rand.Next(19, 25);
                }
            }

            string input    = File.ReadAllText("config/bmi.json");
            var    bmiChart = JsonConvert.DeserializeObject <BMIManager>(input);
            double weight;
            var    heightList  = bmiChart.Heights.FirstOrDefault(x => x.Height == height);
            var    selectedBMI = heightList.BMIs.FirstOrDefault(x => x.BMI == bmi);

            if (height <= 76 && height >= 58 &&
                bmiChart.Heights.FirstOrDefault(x => x.Height == height) != null &&
                heightList.BMIs.FirstOrDefault(x => x.BMI == bmi) != null)
            {
                //grab from table
                weight = selectedBMI.Weight;
            }
            else
            {
                //BMI = kg/m^2, kg = BMI * m^2
                double metricHeight = height / 39.37;
                weight = bmi * metricHeight * metricHeight;
            }

            //creates a random variance of up to 2 pounds (plus or minus)
            double variation = (AnimatorRandom.Rand.NextDouble() * 2 - 1) * 2;
            int    result    = RoundDouble(variation + weight);

            return(result);
        }
示例#9
0
        public static string GetFirstName(BiologicalSex sex)
        {
            var file = $"config/names_{sex.ToString().ToLower()}.txt";

            return(file.GetRandomFromFile());
        }
示例#10
0
 public BiologicalSexDatum(DateTimeOffset timestamp, BiologicalSex sex)
     : base(timestamp)
 {
     _sex = sex;
 }
示例#11
0
 /*! @brief		The default constructor.
  *      @param node	the XmlNode to create this object from.
  */
 public BiologicalSexCharacteristic(XmlNode node)
 {
     this.value = (BiologicalSex)Int32.Parse(node.InnerText);
 }