コード例 #1
0
ファイル: Habitat.cs プロジェクト: hueblerw/CavemanWorld
    // Get The Seed total for this habitat for the year
    public double getSeeds(int x, int z, DailyLayer rainfall, IntDayList temps, DailyLayer surfaceWater)
    {
        double totalSeeds = grazing.getSeeds(x, z, quality, percentOcean, typePercents, rainfall, temps, surfaceWater);

        totalSeeds += forest.getSeeds(typePercents, quality);
        return(Math.Round(totalSeeds * FORAGECONSTANT, 2));
    }
コード例 #2
0
ファイル: Habitat.cs プロジェクト: hueblerw/CavemanWorld
    // Get The Foiliage total for this habitat for the year
    public double getFoilage(IntDayList temps)
    {
        double totalFoilage = grazing.getFoilage(typePercents, quality, temps);

        totalFoilage += forest.getFoilage(typePercents, quality, temps);
        return(Math.Round(totalFoilage * FORAGECONSTANT, 2));
    }
コード例 #3
0
ファイル: TempEquation.cs プロジェクト: hueblerw/CavemanWorld
    // Return an array of random temperatures for the year
    public IntDayList generateYearsTemps()
    {
        int[]         temps = new int[120];
        System.Random randy = new System.Random();
        for (int day = 1; day <= 120; day++)
        {
            temps[day - 1] = generateTodaysTemp(day, randy);
        }
        IntDayList dayList = new IntDayList(temps);

        return(dayList);
    }
コード例 #4
0
 // Determine if starting on today the previous days have a suitable temperature range.
 private bool DayTempAllowCrop(int day, IntDayList temps)
 {
     // Can grow if the temperature is within +/- 10 degrees of the ideal temperature range
     if (day - growthPeriod > 0)
     {
         int startGrowthDay = day - growthPeriod;
         for (int d = day; d > startGrowthDay; d--)
         {
             if (temps.getDaysTemp(d) < minTemp - 10 || temps.getDaysTemp(d) > maxTemp + 10)
             {
                 return(false);
             }
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #5
0
    // Return the growing crops Quality
    private double cropQuality(int day, IntDayList temps)
    {
        int goodDays       = 0;
        int startGrowthDay = day - growthPeriod;

        // temperature multiplier is % of days that are within the ideal temperature range.
        for (int d = day; d > startGrowthDay; d--)
        {
            if (temps.getDaysTemp(d) >= minTemp || temps.getDaysTemp(d) <= maxTemp)
            {
                goodDays++;
            }
        }
        // rain multiplier is between 50% and 125%  based on how close to ideal the rainfall level was.
        double maxDist        = (maxWater - minWater) / 2.0;
        double idealRain      = (maxWater + minWater) / 2.0;
        double rainMultiplier = 1.25 - ((Math.Abs(rainSum - idealRain) / maxDist) * .75);

        // return the two modifiers used together.
        return((goodDays / growthPeriod) * rainMultiplier * 100.0);
    }
コード例 #6
0
ファイル: ClassTester.cs プロジェクト: hueblerw/CavemanWorld
    public void IntDayListTest()
    {
        int[]         coldCountTest = new int[120];
        int[]         hotCountTest  = new int[120];
        System.Random randy         = new System.Random();

        for (int i = 0; i < 120; i++)
        {
            coldCountTest[i] = randy.Next(-10, 32);
            hotCountTest[i]  = randy.Next(71, 110);
        }

        IntDayList testList = new IntDayList(coldCountTest);

        Assert.AreEqual(120, testList.Count32DegreeDays());
        Assert.AreEqual(0, testList.Count70DegreeDays());

        testList = new IntDayList(hotCountTest);

        Assert.AreEqual(0, testList.Count32DegreeDays());
        Assert.AreEqual(120, testList.Count70DegreeDays());
    }
コード例 #7
0
ファイル: Trees.cs プロジェクト: hueblerw/CavemanWorld
    // Return the Foilage available in the forest
    public double getFoilage(double[] habitatPer, int quality, IntDayList temps)
    {
        // Shrub Foilage - ALL
        double foilage = (habitatPer[11] + habitatPer[12]) * Habitat.SHRUBCONSTANT * Habitat.TROPICALEAFGROWTH;

        foilage += (habitatPer[7] + habitatPer[8]) * Habitat.SHRUBCONSTANT;
        foilage += (habitatPer[3] + habitatPer[4]) * Habitat.SHRUBCONSTANT * Habitat.ARTICLEAFGROWTH;
        // Scrub Foilage - FORESTS ONLY, NO SWAMP
        foilage  = (habitatPer[11] + habitatPer[12]) * Habitat.SCRUBCONSTANT * Habitat.TROPICALEAFGROWTH;
        foilage += (habitatPer[7] + habitatPer[8]) * Habitat.SCRUBCONSTANT;
        foilage += (habitatPer[3] + habitatPer[4]) * Habitat.SCRUBCONSTANT * Habitat.ARTICLEAFGROWTH;
        // Desert Scrub Foilage - NOT APPLICABLE IN FORESTS!
        // Forest Leaves - ALL
        foilage  = (habitatPer[11] * MONSOONFORESTLEAFAGE + habitatPer[12] * RAINFORESTLEAFAGE) * Habitat.FORESTLEAVESCONSTANT;
        foilage += (habitatPer[7] + habitatPer[8] * SWAMPLEAFAGE) * Habitat.FORESTLEAVESCONSTANT;
        // Temperature Effect
        double sum = 0.0;
        int    todayTemp;

        for (int d = 0; d < 120; d++)
        {
            todayTemp = temps.getDaysTemp(d);
            if (todayTemp > 50)
            {
                sum += foilage;
            }
            else
            {
                if (todayTemp > 30)
                {
                    sum += ((todayTemp - 30.0) / 20.0) * foilage;
                }
            }
        }
        // Pine Leaves - ARTIC FORESTS ONLY - NOTE THESE ARE EVERGREEN AND BLOOM EVENLY ALL YEAR!
        sum += (habitatPer[3] + habitatPer[4] * SWAMPLEAFAGE) * Habitat.PINENEEDLECONSTANT * 120;
        return(sum);
    }
コード例 #8
0
ファイル: Graze.cs プロジェクト: hueblerw/CavemanWorld
    // Return the Foilage available in the forest
    public double getFoilage(double[] habitatPer, int quality, IntDayList temps)
    {
        // Shrub Foilage - PLAINS ONLY, NO DESERTS
        double foilage = habitatPer[10] * Habitat.SHRUBCONSTANT * Habitat.TROPICALEAFGROWTH;

        foilage += habitatPer[6] * Habitat.SHRUBCONSTANT;
        foilage += habitatPer[2] * Habitat.SHRUBCONSTANT * Habitat.ARTICLEAFGROWTH;
        // Scrub Foilage - ALL
        foilage  = (habitatPer[9] + habitatPer[10]) * Habitat.SCRUBCONSTANT * Habitat.TROPICALEAFGROWTH;
        foilage += (habitatPer[5] + habitatPer[6]) * Habitat.SCRUBCONSTANT;
        foilage += (habitatPer[1] + habitatPer[2]) * Habitat.SCRUBCONSTANT * Habitat.ARTICLEAFGROWTH;
        // Desert Scrub Foilage - DESERT ONLY
        foilage += (habitatPer[1] + habitatPer[5] + habitatPer[9]) * Habitat.DESERTSCRUBCONSTANT;
        // Forest Leaves - NONE
        // Temperature Effect
        double sum = 0.0;
        int    todayTemp;

        for (int d = 0; d < 120; d++)
        {
            todayTemp = temps.getDaysTemp(d);
            if (todayTemp > 50)
            {
                sum += foilage;
            }
            else
            {
                if (todayTemp > 30)
                {
                    sum += ((todayTemp - 30.0) / 20.0) * foilage;
                }
            }
        }
        // Pine Leaves - NONE - NOTE THESE ARE EVERGREEN AND BLOOM EVENLY ALL YEAR!
        return(sum);
    }
コード例 #9
0
ファイル: Graze.cs プロジェクト: hueblerw/CavemanWorld
    // Returns the seeds produced by the grazing
    public double getSeeds(int x, int z, int quality, double oceanPer, double[] habitatPercents, DailyLayer rainfall, IntDayList temps, DailyLayer surfaceWater)
    {
        double seeds = (YearsGrazingForage(x, z, quality, oceanPer, habitatPercents, rainfall, temps, surfaceWater) / Habitat.FORAGECONSTANT) / GRASSCALORIECONTENT;

        return(seeds * Habitat.SEEDCONSTANT);
    }
コード例 #10
0
ファイル: Graze.cs プロジェクト: hueblerw/CavemanWorld
    // Return the year's total foragable grazing.
    // Used by the game and herds to determine food availability
    public double YearsGrazingForage(int x, int z, int quality, double oceanPer, double[] habitatPercents, DailyLayer rainfall, IntDayList temps, DailyLayer surfaceWater)
    {
        double sum = 0.0;

        for (int d = 0; d < 120; d++)
        {
            sum += getGrazing(d, x, z, quality, oceanPer, habitatPercents, rainfall, temps, surfaceWater);
        }
        return(Math.Round((sum * Habitat.FORAGECONSTANT), 2));
    }
コード例 #11
0
ファイル: Graze.cs プロジェクト: hueblerw/CavemanWorld
    // Return the grazing available for this square today.
    public double getGrazing(int day, int x, int z, int quality, double oceanPer, double[] habitatPercents, DailyLayer rainfall, IntDayList temps, DailyLayer surfaceWater)
    {
        // Get the % of terrain that has grass
        double grassPercent  = 0.0;
        double desertPercent = 0.0;

        for (int i = 0; i < 9; i += 4)
        {
            grassPercent  += habitatPercents[2 + i];
            desertPercent += habitatPercents[1 + i];
        }
        double last5Rain = Last5DaysOfRain(day, x, z, rainfall, surfaceWater);
        // Calculate the grass mass.
        double grass = getGrass(quality, oceanPer, grassPercent, desertPercent, last5Rain, temps.getDaysTemp(day));
        // Calculate the grazing available
        double grazing = grass * GRASSCALORIECONTENT;

        return(grazing);
    }
コード例 #12
0
 // Print that grew the last X days
 public string PrintLastXDaysOfCrops(int today, int range, int x, int z, double oceanPer, DailyLayer rainfall, IntDayList temps, DailyLayer rivers)
 {
     // get a sum of last X days crop arrays
     double[] sumArray = new double[NUM_OF_CROPS];
     double[] cropArray;
     for (int d = today; d > 0 && d > (today - range); d--)
     {
         cropArray = ReturnCurrentCropArray(today, x, z, oceanPer, rainfall, temps, rivers);
         for (int i = 0; i < NUM_OF_CROPS; i++)
         {
             if (cropArray[i] != 0.0)
             {
                 sumArray[i] += cropArray[i];
             }
         }
     }
     return(CreateCropArrayPrintString(sumArray));
 }
コード例 #13
0
 // Print the Current Crop Array
 public string PrintCurrentCropArray(int day, int x, int z, double oceanPer, DailyLayer rainfall, IntDayList temps, DailyLayer rivers)
 {
     // get today's crop array
     double[] cropArray = ReturnCurrentCropArray(day, x, z, oceanPer, rainfall, temps, rivers);
     return(CreateCropArrayPrintString(cropArray));
 }
コード例 #14
0
 // Return an array containing totals of each crop for the entire year.
 public double[] SumCropsForYear(int x, int z, double oceanPer, DailyLayer rainfall, IntDayList temps, DailyLayer rivers)
 {
     double[] cropSum = new double[NUM_OF_CROPS];
     double[] cropDay = new double[NUM_OF_CROPS];
     for (int d = 0; d < 120; d++)
     {
         cropDay = ReturnCurrentCropArray(d, x, z, oceanPer, rainfall, temps, rivers);
         for (int i = 0; i < NUM_OF_CROPS; i++)
         {
             cropSum[i] += cropDay[i];
         }
     }
     return(cropSum);
 }
コード例 #15
0
    // NOTE ***************
    // So far the crops can't grow early in the year because for that they need access to information from the previous year.
    // Implementation of that will be a bit tricky so I am saving it for later.
    // Also, these represent the number of new crops that grew today.  A scavenger would have access to the last x days worth of crops.
    // Calculate how much of a crop is present upon request
    public double[] ReturnCurrentCropArray(int day, int x, int z, double oceanPer, DailyLayer rainfall, IntDayList temps, DailyLayer rivers)
    {
        double[] currentCrops = new double[NUM_OF_CROPS];
        percentGrowable = 1.0;
        // For each of the crops
        // If he crop can grow in the region return the crops store the crops returned value in the current crop array for today.
        for (int i = 0; i < NUM_OF_CROPS; i++)
        {
            SwitchVariables(i);
            if (DayTempAllowCrop(day, temps) && DayRainAllowCrop(day, x, z, rainfall, rivers))
            {
                // Debug.Log("Crops Allowed!");
                double cropMultiplier = (1.0 / ((80 - growthPeriod) * 100.0)) * 400.0 * (1.0 - oceanPer);
                // Calculate the crop quality
                currentCrops[i] = cropQuality(day, temps) * cropMultiplier * humanFoodUnits * percentGrowable;
                // Debug.Log(x + ", " + z + " / " + cropQuality(day, temps) + " / " + percentGrowable + " / " + humanFoodUnits);
            }
        }

        return(currentCrops);
    }
コード例 #16
0
 // Print the Year's Crop Array
 public string PrintYearsCropArray(int x, int z, double oceanPer, DailyLayer rainfall, IntDayList temps, DailyLayer rivers)
 {
     // get year's crop array
     double[] cropArray = SumCropsForYear(x, z, oceanPer, rainfall, temps, rivers);
     return(CreateCropArrayPrintString(cropArray));
 }