dbchest

Beast Master
Veteran
Joined
Oct 1, 2013
Messages
434
Reaction score
306
First Language
English
Primarily Uses
RMMV
Hi, everyone! I would like to talk about the "parameter curves" game mechanic today; specifically, I am curious what algorithm is used within the "Parameter Curves" sub-section of the "Classes" section of the database in order to "bend" a linear growth pattern by applying a single growth-rate parameter.

So, if you open the database and go to the "Classes" section and double-click on any of the graphs there-in the "Parameter Curves" sub-section it will open the window which uses the algorithm I want to discuss. I have looked for functions using this algorithm in the default scripts, but I did not have any success.

On the other hand, if you open the /data/Classes.json source file and scroll through the corresponding data, then you will find a two-dimensional array containing 100 elements for each parameter, where; element 0 represents the minimum value for that parameter, while the remaining 99 elements represent the value of the parameter at its corresponding level between 1 and 99. All right, so this leads me to believe that the algorithm is only utilized in the editor and never called upon at runtime.

This being the case, I am hoping that one of the more experienced developers here at the forums might be able to walk me through the mathematical side to this algorithm, because I think that having this knowledge may open a few doors for me and I would really like to figure it out.

I'll wrap this up with a little more information about the way rmmv incorporates this into the editor; so, applying any of the quick settings
[A, B, C, D, E] generates a linear growth pattern for that parameter, by which you can further individualize by clicking on the "Generate Curve" button and adjusting the growth-rate variable inside.

So, I think that when you press "Ok" the editor calls a function to generate a two-dimensional array that uses the algorithm to apply the parameter value to each level in the array and then updates the associated .json file before closing the window.

I am hoping that somebody is able to teach me the algorithm that actually generates the "curve" between levels 1-99 based on the growth-rate variable.

**p.s. the growth-rate starts in the center and can be adjusted either way, so I am thinking it represents a value between -1 and 1.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,264
Reaction score
1,673
First Language
EN
Primarily Uses
RMMZ
My guess would be the product of a straight line and an exponential, yielding an equation with three constants:
  • y = ( mx + c ) * exp( kx )
This reduces to a straight line when k is zero. Increasing m makes it increase faster, c shifts all values up/down a bit.

Exponentials grow much faster than straight lines, so to avoid eclipsing the linear behaviour on [1, 99] you'll want a low value for the constant k. After a little fiddling around in a spreadsheet, I'd suggest trying a k value of 0.005 or so. Make it positive to accelerate, negative to decelerate.
 

dbchest

Beast Master
Veteran
Joined
Oct 1, 2013
Messages
434
Reaction score
306
First Language
English
Primarily Uses
RMMV
Isn't this how they handle exp growth?
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,264
Reaction score
1,673
First Language
EN
Primarily Uses
RMMZ
RPG Maker MV's experience equation can be found in the code (rpg_objects.js):
Code:
Game_Actor.prototype.expForLevel = function(level) {
    var c = this.currentClass();
    var basis = c.expParams[0];
    var extra = c.expParams[1];
    var acc_a = c.expParams[2];
    var acc_b = c.expParams[3];
    return Math.round(basis*(Math.pow(level-1, 0.9+acc_a/250))*level*
            (level+1)/(6+Math.pow(level,2)/50/acc_b)+(level-1)*extra);
};
  • exp = A L (L + 1) (L - 1)^(0.9 + C / 250) / (6 + D L^2 / 50 + B (L - 1))
Doesn't have quite the same shape. :kaoswt:

Edit @dbchest: since you mention this was mostly for learning, I realise some elaboration may be helpful here. First: this messy-looking formula is a fairly typical result. I imagine it started out as a simple cubic polynomial, then went through various numerical/trial-and-error adjustments (dividing through by a quadratic, lowering the degree of the nominator from 3 to 2.9) to suit a "nice" range of values for the editor.

I don't know how much experience you have with maths in general, but this stuff becomes a little less mysterious if you have some familiarity with graph sketching, including knowledge of a few simple function shapes (polynomials, exponentials, sinusoids, etc) and how they combine (addition vs multiplication, dependent/output vs independent/input shifts, etc).

So, for instance, for the parameters I noticed the C curve looks just like a straight line, giving me the mx+c bit of my guess, the parameters of which would be set by the user-specified endpoints. Then for the curve I just assumed it was an exponential, though it's possible it's a quadratic or something, or an addition rather than a multiplication. (Most functions are representable as polynomials, look up Taylor series if you're interested!)

Ultimately the best teacher here is experience~ :kaoslp:
 
Last edited:

dbchest

Beast Master
Veteran
Joined
Oct 1, 2013
Messages
434
Reaction score
306
First Language
English
Primarily Uses
RMMV
@caethyril
I would like to thank you for sharing what you know about this subject; I didn't know what to expect in terms of responses here at the forums, because I consider this an intermediate aspect of game mechanics; I feel like the ability to generate a system like this requires a math foundation above a beginner (which I clearly am).

I have no experience with mathematical graph sketching and I knew that was the basic foundation for exp and param mechanics, which is why I stand mystified in the first place.

do you happen to know of any online websites that offer some introductory courses into mathematical graph sketching? I remember doing some of this stuff using a graphing calculator back in high school, but that was quite some time ago and I think it would open a few doors to understand the foundation behind curving linear patterns and such.

All in all, you have given me good information to dissect and I really appreciate your assistance.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,264
Reaction score
1,673
First Language
EN
Primarily Uses
RMMZ
I've heard good stuff about the Khan Academy videos on Youtube, not sure what sort of level they're aimed at though. I picked up my knowledge at school/university. :kaoswt:

For graph-sketching, beyond knowing roughly what shape the graphs of various common functions are, it's helpful to have some knowledge of limits and calculus. I'd suggest starting with straight lines, since all other [continuous] curves can be thought of as a series of infinitesimally (i.e. "really really") short straight lines. That notion leads naturally into calculus: the derivative of a curve at a point is the gradient of that curve at that point. Then you can start using that knowledge to extract information from an equation about how it changes...

Common functions (other than straight lines) include:
  • Polynomials: stuff like y = A + ax + bx^2 + cx^3 + ..., as well as y = 1/x (interesting because it introduces the idea of "asymptotes")
  • Exponentials: when it's stuff to the power x instead, e.g. y = e^x
  • Logarithms: inverse of exponential, i.e. if y = e^x then x = log(y)
  • Trigonometric: sine, cosine, and tangent are the basics, these are what you'll see in almost anything that repeats
Combining functions can be a bit trickier. Add two straight lines together and you'll get another straight line: just add the gradients and the intercepts, easy! Multiplying two straight lines together, though, gives you something you may not expect: y = ax^2 + bx + c, which is generally not straight at all! :kaoback:

I find spreadsheets are great for experimenting. Excel is good if you have a copy, but if not then there are alternatives such as Google Sheets or OpenOffice Calc. Make one column with 0, 1, 2, 3, ... for your x-values, stick a formula in the next column, copy it down, select all, insert chart: instant graph-sketching! :kaoluv:
 

Latest Threads

Latest Posts

Latest Profile Posts

just destroyed hours of work again. i don't know why I bother.
World Map for the inside of my main character's head. Every spot is an area that either occupies his thoughts or staples of everyone's "headspace"
How can I look up the components for a medieval bomb for my game without the FBI showing up at my door?
I don't think I can handle using the real SNES resolution of 512x448 because resizing absolutely every interface element I had on hand by painstaking trial & error/guess and check (is there any other way?) is KILLING me.

Forum statistics

Threads
108,992
Messages
1,041,107
Members
141,458
Latest member
EvieOverwrite
Top