Tuesday, 9 February 2016

Coding - How the Research Settings Work On the Server

Coding - How the Research Settings Work on the Server

Research in the game is performed only in campaign mode. Research is performed on the server.  The end user sees a system whereby the percentage in each focus area of the game (speed, economy, firepower, defense) is increased gradually over time from 0 to a maximum value the more time is spent researching a technology.

The algorithm used for calculating research is very, very simple.

When a research setting is changed we detect the time on the server that the setting was set.  At any point that the game requests information about the player's ships (such as before a battle, or when viewing ship details, or when viewing fleet information) the server reports an updated value of the appropriate value (hitpoints, firepower etc).

The mathematical technique used is to use an atan curve (inverse tangent).

The inverse tangent curve us a curve that goes from -Pi/2 to +Pi/2 for values from -infinity to +infinity.

For the purpose of the game we specify our research modifier (as an additional multiplier) to the base score as equivalent to this:

Modifier = Constant *  Atan(Time Researched * Fudge Factor) / (Pi/2 plus a little bit)

This means that as time goes to infinity the Modifier approaches its maximum value. At time is zero the Modifier begins at zero.  The curve is not linear and instead is similar to an 'S' curve with a low rate of increase at the beginning, a higher rate of increase in the mid section and a slow rate of increase asymptoting to the maximum value at higher values of time.

This is the basis for which research progress is calculated on the server.

No comments:

Post a Comment