コード例 #1
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);
     }
 }
コード例 #2
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);
    }
コード例 #3
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);
    }
コード例 #4
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);
    }
コード例 #5
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);
    }