Difference between revisions of "Template:Actual Age"

From RimWorld Wiki
Jump to navigation Jump to search
Line 16: Line 16:
 
{{GraphChart|width=200|height=200|xAxisTitle=Age relative to reported adult age|yAxisTitle=Growth|type=line|x=0.0, 0.02, 0.04, 0.06, 0.08, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2, 0.22, 0.24, 0.26, 0.28, 0.3, 0.32, 0.34, 0.36, 0.38, 0.4, 0.42, 0.44, 0.46, 0.48, 0.5, 0.52, 0.54, 0.56, 0.58, 0.6, 0.62, 0.64, 0.66, 0.68, 0.7, 0.72, 0.74, 0.76, 0.78, 0.8, 0.82, 0.84, 0.86, 0.88, 0.9, 0.92, 0.94, 0.96, 0.98|y2=0.001, 0.02121, 0.04184, 0.06291, 0.08443, 0.10642, 0.1289, 0.1519, 0.17545, 0.19956, 0.22427, 0.2496, 0.27559, 0.30228, 0.3297, 0.35789, 0.3869, 0.41677, 0.44757, 0.47934, 0.51216, 0.54609, 0.58121, 0.61761, 0.65539, 0.69465, 0.73551, 0.77812, 0.82262, 0.86919, 0.91804, 0.9694, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 | y1=0.0, 0.02, 0.04, 0.06, 0.08, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2, 0.22, 0.24, 0.26, 0.28, 0.3, 0.32, 0.34, 0.36, 0.38, 0.4, 0.42, 0.44, 0.46, 0.48, 0.5, 0.52, 0.54, 0.56, 0.58, 0.6, 0.62, 0.64, 0.66, 0.68, 0.7, 0.72, 0.74, 0.76, 0.78, 0.8, 0.82, 0.84, 0.86, 0.88, 0.9, 0.92, 0.94, 0.96, 0.98 | yType=number|yAxisMax=1|xAxisMax=1|linewidth=1|colors=red, black|legend=|y1Title=What you would expect|y2Title=What actually happens}}
 
{{GraphChart|width=200|height=200|xAxisTitle=Age relative to reported adult age|yAxisTitle=Growth|type=line|x=0.0, 0.02, 0.04, 0.06, 0.08, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2, 0.22, 0.24, 0.26, 0.28, 0.3, 0.32, 0.34, 0.36, 0.38, 0.4, 0.42, 0.44, 0.46, 0.48, 0.5, 0.52, 0.54, 0.56, 0.58, 0.6, 0.62, 0.64, 0.66, 0.68, 0.7, 0.72, 0.74, 0.76, 0.78, 0.8, 0.82, 0.84, 0.86, 0.88, 0.9, 0.92, 0.94, 0.96, 0.98|y2=0.001, 0.02121, 0.04184, 0.06291, 0.08443, 0.10642, 0.1289, 0.1519, 0.17545, 0.19956, 0.22427, 0.2496, 0.27559, 0.30228, 0.3297, 0.35789, 0.3869, 0.41677, 0.44757, 0.47934, 0.51216, 0.54609, 0.58121, 0.61761, 0.65539, 0.69465, 0.73551, 0.77812, 0.82262, 0.86919, 0.91804, 0.9694, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 | y1=0.0, 0.02, 0.04, 0.06, 0.08, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2, 0.22, 0.24, 0.26, 0.28, 0.3, 0.32, 0.34, 0.36, 0.38, 0.4, 0.42, 0.44, 0.46, 0.48, 0.5, 0.52, 0.54, 0.56, 0.58, 0.6, 0.62, 0.64, 0.66, 0.68, 0.7, 0.72, 0.74, 0.76, 0.78, 0.8, 0.82, 0.84, 0.86, 0.88, 0.9, 0.92, 0.94, 0.96, 0.98 | yType=number|yAxisMax=1|xAxisMax=1|linewidth=1|colors=red, black|legend=|y1Title=What you would expect|y2Title=What actually happens}}
  
A baby animal becomes a juvenile as soon as its growth exceeds <code>juvenile_age/adult_age</code>. For example, horses have a reported juvenile age of 0.2, and a reported adult age of 0.3333, so they become a juvenile when their growth is <code>0.2/0.3333 = 0.75</code>.
+
A baby animal becomes a juvenile as soon as its growth exceeds <code>juvenile_age/adult_age</code>. For example, horses have a reported juvenile age of 0.25, and a reported adult age of 0.3333, so they become a juvenile when their growth exceeds <code>0.25/0.3333 = 0.6</code>.
 
===Maths===
 
===Maths===
 
:<code>with 1 = {sum from [t=0 to actual_ticks_to_adulthood]: 1/(adult_age_expressed_in_ticks - t)},<br>actual_ticks_to_adulthood trends to (1-1/e)×adult_age_expressed_in_ticks as adult_age_expressed_in_ticks trends to infinity</code>
 
:<code>with 1 = {sum from [t=0 to actual_ticks_to_adulthood]: 1/(adult_age_expressed_in_ticks - t)},<br>actual_ticks_to_adulthood trends to (1-1/e)×adult_age_expressed_in_ticks as adult_age_expressed_in_ticks trends to infinity</code>

Revision as of 14:50, 30 September 2021

Returns the actual age at which an animal will reach a life stage age listed in its def files.

Parameters

  • adult_age - this has to be the adult_age listed in the animal's def xml, or seen in the in-game information window
  • juvenile_age - if a second parameter is given, the number returned will be the actual juvenile age. This number must be found from the defs files.

Formula used

actual_juvenile_age = (1-1/e^(juvenile_age/adult_age))×adult_age

actual_adult_age = (1-1/e)×adult_age

Explanation

If the lifeStageAges minAge values from the animals' defs files were to be believed as-is, you would expect that horses, which have a reported minimum adult age of 0.3333, and a reported minimum juvenile age of 0.25, to be juveniles for (0.3333-0.25)*60 = 5 days. However, the time they actually spend in game as a juvenile is only 2 days. This method accurately predicts this.

The reason for this weirdness is because the amount the growth stat increases at each tick is proportional to 1/ticks_to_adulthood, where ticks_to_adulthood is simply the difference between the ticks since birth and the def file's adult_age expressed in ticks. The consequence of growth updating this way is that initially, the growth stat increases at as you would expect, and then as the animal ages, it increases faster, with an infinite growth rate when it's at the adult age reported in the animal's defs file.

A baby animal becomes a juvenile as soon as its growth exceeds juvenile_age/adult_age. For example, horses have a reported juvenile age of 0.25, and a reported adult age of 0.3333, so they become a juvenile when their growth exceeds 0.25/0.3333 = 0.6.

Maths

with 1 = {sum from [t=0 to actual_ticks_to_adulthood]: 1/(adult_age_expressed_in_ticks - t)},
actual_ticks_to_adulthood trends to (1-1/e)×adult_age_expressed_in_ticks as adult_age_expressed_in_ticks trends to infinity
with (juvenile_age/adult_age) = {sum from [t=0 to actual_ticks_to_juvenile]: 1/(adult_age_expressed_in_ticks - t)},
actual_ticks_to_juvenile trends to (1-1/e^(juvenile_age/adult_age))×adult_age_expressed_in_ticks as adult_age_expressed_in_ticks trends to infinity

Example uses

  • Horse adult: {{Actual Age|0.3333}} -> 0.21068578097385
  • Horse juvenile: {{Actual Age|0.3333|0.25}} -> 0.17587203545609
  • Fox juvenile: {{Actual Age|0.3333|0.1}} -> 0.086392694342281