Topic on User talk:Hautarche

Jump to navigation Jump to search
Line 1: Line 1:
The "mean time between" Pyromaniac's random fire-starting sprees, as well as Gourmand's random food binges, is governed by a field called "randomMentalStateMtbDaysMoodCurve" in the XML. IN THEORY, this is a curve using the "SimpleCurve" code, scaling the mean number of days until next trait-induced mental state based on the pawn's mood.
+
It is not easy to test how the mental states randomly induced by Pyromaniac or Gourmand (namely, fire-starting spree and food binge) work. They are, after all, random, and they seem to take a lot of time to proc. Of course, if you go find the XML of these traits, you'll find the randomMentalState and randomMentalStateMtbDaysMoodCurve fields which govern this behavior. The former governs which mental state is randomly induced by the trait. The latter governs the 'mean time between' (MTB) episodes. In both cases, the latter has a sub-field called "points" in which there is only one point, <0,50>. This has a clear relation to the MTB - for example, if you change it to <0,1>, you will very quickly find that this makes the random mental states extremely frequent. But how does it work, and why is it called a "curve"?
  
Now for a basic primer on SimpleCurve. SimpleCurve 'evaluates' a value-to-test (in this case the pawn's mood) and returns an answer-value. It evaluates differently depending on how many points (as in distinct <x,y> coordinates) it is given:
+
In the code, randomMentalStateMtbDaysMoodCurve's only use lies within an MTB calculation. These kinds of calculations use three fields, 'mtb', 'mtbUnit', and 'checkDuration'. In this case, 'checkDuration' is 150 ticks; mtbUnit is 60000 ticks (aka 1 in-game day); and mtb... is the SimpleCurve evaluation of the pawn's current mood, using the points described in randomMentalStateMtbDaysMoodCurve's "points" field. Well, uh, how does THAT work?
  
0) Zero points: the phrase "Evaluating a SimpleCurve with no points." shows up in the error log. The returned value is always 0.
+
A SimpleCurve is created by plotting a list of <x,y> points onto a Cartesian grid. The curve is "simple" because instead of actually creating a curvy line to map the function, it just creates straight lines between each successive point. When "evaluating" a number, it treats that number as the x-value of a coordinate, and returns the y-value of that coordinate as it would be on the plotted 'curve' (again, not actually a curve). If the number would result in a coordinate point left of the 'curve''s leftmost point, the y-value is that of the leftmost point of the 'curve'; and if it would be right of the rightmost, the y-value is that of the rightmost.
  
!0) One or more points: the points are ordered in ascending order of x-values. If the value-to-test is not higher than the first point's x, the answer-value is the first point's y. If the value-to-test is not lower than the last point's x, the answer-value is the first point's y. Otherwise, we take the two points whose x-values the value-to-test is between, and then the answer-value is between the two points' y-values to the same extent that the value-to-test is between the two points' x-values (a linear interpolation).
+
That's fascinating and all, but you may have noticed a problem already. Our SimpleCurve is informed by randomMentalStateMtbDaysMoodCurve, and in both Pyromaniac's and Gourmand's cases, they each only list a SINGLE POINT (<0,50>). How do you make a curve - or a 'curve' - out of a single point?
  
We can ignore the linear interpolation thing, though, because IN PRACTICE: neither Pyromaniac or Gourmand are actually curves. Their randomMentalStateMtbDaysMoodCurves each only have one point, <0,50>. Our value-to-test is mood, a value that ranges from 0-1. Following the path laid out by '!0)', our worst-case mood (0 mood), is not higher than the first point's x, since our first point is <0,50>; literally any other mood IS higher... but it is also not lower than the last point's x, since our last point is also <0,50>. Regardless of the pawn's mood, for these traits, the answer-value is the singular point's y-value i.e. 50.
+
You don't, actually. And this works just fine! Because, if a pawn's mood is lower than 0 (technically impossible, but let's allow it), it's left of the leftmost point... and so the returned y-value is the y-value of the leftmost point... which is 50. And if a pawn's mood is higher than 0, it's right of the rightmost... and so the returned y-value is the y-value of the rightmost... which is 50. And if a pawn's mood is 0, well! Then the y-value of the 'curve' at that point is 50.
 +
 
 +
It really is an MTB of 50 days for both traits.