ATH Connect Productions
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Go down
Antwand T. Howard
Antwand T. Howard
Lead Developer
Lead Developer
Clan : dev
Posts : 61
Points : 736
https://antwandhoward.com/

Calculating Your XP Gain Per Match Empty Calculating Your XP Gain Per Match

Mon Jan 23, 2023 4:59 pm
Last updated: January 23, 2023.

For those wondering how the XP gain is calculated in online matches, you've landed on the right post. Here, we will describe in detail how your XP changes per battle. It'll involve some algebra-level math.

First, we need a few things from the battle we just wrapped up. We'll need:
- The scores for each player
- The current XP of each player
- How long the battle lasted.
- How many players were in the match.

These variables will be studied and combined to form our three important factors in determine the change in XP:
- The time multiplier, or "time mult"
- The XP multiplier, or "xp mult"
- And the score multiplier, or "score mult"

Time mult is the easiest to get. Time mult is a function of how long the battle is, so that the longer the battle, the greater magnitude of XP change.

Code:
time mult = the log of "BattleLengthInMinutes*20"

After that, we'll need to get some more information about the battle. For both score and xp mult, each player's score and XP are added up to get the average of them all, and the "mid" point, which is essentially the total XP or score divided by 2.

Code:

total score = sum of all player's scores
mid score = half of total score
avg score = the average of all scores

total xp = sum of all player's XPs
mid score = half of total xp
avg xp = average of all XPs

Now, score mult and XP mult pairs their associated values in some complicated math.

Code:
score mult = ((player score - avg score)/mid score^0.6 -1 +(player score as a percent of average score) * 30%

xp mult = | avg xp - player xp |^0.7 * sign(avg xp - player xp) * 10%

Finally, we multply time mult, score mult, and xp mult together with one more function to make our XP gain proportional, rather than linear.

A multiplier is added based on the player mode: 0.2 for classic, and 0.3 for stock mayhem.
Code:

xp gain = multiplier * (score mult + square root of |xp mult| * sign(xp mult)) * the number of players * time mult

"sign" just means that if it's greater than 0, sign(xp mult) is 1, and if it's less than 0, sign(xp mult) is -1.

We add the xp mult function to score mult, so that having a higher XP simply slides the gain up or down, upwards for lower XP.
Back to top
Permissions in this forum:
You cannot reply to topics in this forum