Response Curve Design - apoch/curvature GitHub Wiki
The response curve equations in Curvature were originally designed to meet several specific criteria:
- Inputs (x-axis) are normalized from 0 to 1
- Outputs (y-axis) are expected to be normalized from 0 to 1
- The general shape and behavior of equations should all use 4 standard parameters
- Evaluation should be relatively cost efficient
The first two requirements effectively mean that the equations are only considered within the unit square (0,0)-(1,1). This property is essential for composing multiple considerations together into a single behavior.
The four standard parameters (slope, exponent, x-shift, and y-shift) are chosen from Dave Mark's Infinite Axis Utility System. We use these four parameters because they can easily be used to adjust the shape of a curve in a consistent, intuitive, and visually clear fashion. Since all curve types use the same parameters, it is always possible to intuit (roughly) how changing a parameter will affect a curve. The properties of these parameters (such as x/y shifting) are derived from basic Cartesian algebra.
Speed is not quite as important in Curvature as in the real game simulations that inspired the tool. In a shipping game, AI may have to evaluate thousands of response curves every frame, so reliance on simple and cheap functions is paramount. However, in Curvature, we have a considerably less strict performance constraint. As such some of the equations implemented in Curvature are designed to have "appealing" behavior more than highly efficient computational properties.
General Rules for Adding or Changing Response Curves
Aside from the requirements outlined above, there really are no rules. If a particular equation gives a pleasing relationship between input and output values, it's fair game. Some of the more esoteric curves in Curvature arose from whimsical ideas about how to control input/output relationships. Feel free to extend the ResponseCurve class and add new curve types, or refine the existing equations (ComputeValue() function in ResponseCurve.cs).
On Magic Numbers
The implementations of several curves contain some magic constants. For the most part these are simply adjusting input and/or output ranges a bit to better fit into the unit square space. They are found generally by testing a few equations and observing what transformations could be used to fit them to the unit square better. Tools like Desmos are extremely valuable for this experimentation.
Logistic and Logit
The constants used in these equations were found by experimentation and chosen to produce curves that fit well in the unit square and have more or less suitable properties for a utility response curve.
Normal
This is a slightly more whimsical curve in general, but the use of these specific constants derives from fitting the curve into the unit square and generally producing a useful basic slope (which of course can be adjusted via parameterization).
Sine
The constants in this equation are entirely transformations that move the standard sine wave into the unit square. 2 * pi is an obvious conversion from normalized 0-1 inputs into radians (the expected units of Math.Sin in the Curvature implementation). The two 0.5 constants serve to scale the sine wave back down into 0-1 normalized y-space, and shift it up so that the peaks and troughs of the sine wave rest on the upper and lower edges of the unit square, respectively.