Reward interval distribution algorithm
From DKPLP Doc
The reward interval distribution algorithm is used by DKP Log Parser to distribute global DKP between reward intervals. The real code can be viewed by downloading the source code and looking at the com.lokorin.dkplp.DayBlock.calculateDkp() method.
Contents |
The example setup
In the example a parsed day with the following attributes are used.
Loot bought: 1200 DKP Global bonus: 400 DKP Reward modifer: 0.8 Zero-sum distribution mode: Per interval Weights should affect zero-sum DKP: yes Weights should affect global bonus DKP: no
The following reward intervals are going to be used in the example.
Name: I1 Weight: 2.0 Interval bonus: 100 DKP Participant bonus: 0 DKP Number of participants: 10
Name: I2 Weight: 1.0 Interval bonus: 0 DKP Participant bonus: 2.0 DKP Number of participants: 20
Name: I3 Weight: 2.0 Interval bonus: 0 DKP Participant bonus: 0 DKP Number of participants: 10
Step 1: Calculate the total number of units and weighted units
The units that are used differ depending on the zero-sum distribution used. Per interval is used in this case. That means that the number of units is the number of participants in the reward interval, and the number of weighted units is the number of participants times the weight.
- Units
- The sum of all the reward intervals' units as defined by the zero-sum distribution.
- Weighted units
- The sum of all the reward intervals' units as defined by the zero-sum distribution, but with each individual reward interval's units weighted by that reward interval's weight.
Units: 10 + 20 + 10 = 40 Weighted units: 10 * 2.0 + 20 + 10 * 2.0 = 60
Step 2: Split the global DKP
The global DKP now has to be split. Which global DKP types that weight affect come into play here. DKP types that are not affected by weights are calculated by the units calculated, the types that are affected are calculated with the weighted units. The zero-sum mode also comes into play here, if we were using Off as the mode, then the zero-sum DKP would be set to zero. The following happends in the example.
- Zero-sum DKP per weighted unit
- The reward modifier times the zero-sum DKP to award divided by the number of weighted units.
- Global bonus per unit
- The global bonus to award divided by the units.
Zero-sum DKP per weighted unit: 0.8 * 1200 / 60 = 16 DKP Global bonus per unit: 400 / 40 = 10 DKP
Step 3: Distribute the DKP
The split DKP is now applied to each interval and multiplied with the number of units that the reward interval represents. If weights should be applied then they are applied at this stage (and weighted units are used). Two rewards are calculated, one for the zero-sum part that should be awarded to each participant and one for the global bonus part.
- Zero-sum reward
- The interval's weighted units times the zero-sum per weighted unit divided by the number of participants in the interval.
- Global bonus reward
- The interval's units times the global bonus per unit divided by the number of participants in the interval.
I1 Zero-sum reward: 20 * 16 / 10 = 32 DKP Global bonus reward: 10 * 10 / 10 = 10 DKP
I2 Zero-sum reward: 20 * 16 / 20 = 16 DKP Global bonus reward: 10 * 10 / 10 = 10 DKP
I3 Zero-sum reward: 20 * 16 / 10 = 32 DKP Global bonus reward: 10 * 10 / 10 = 10 DKP
Step 4: Calculate the total reward
All rewards have now been calculated, so it's time to combine them all inte one total reward value. This is the step where the participation and intervals bonuses have effect.
- Interval bonus reward
- The reward interval bonus divided by the number of participants in the interval.
- Total reward
- The sum of the zero-sum reward, the global bonus reward, the interval bonus reward and the participation bonus.
I1 Interval bonus reward: 100 / 10 = 10 DKP Total reward: 32 + 10 + 10 + 0 = 52 DKP
I2 Interval bonus reward: 0 / 20 = 0 DKP Total reward: 16 + 10 + 0 + 2.0 = 28 DKP
I3 Interval bonus reward: 0 / 10 = 0 DKP Total reward: 32 + 10 + 0 + 0 = 42 DKP
The result
DKP in: 52 * 10 + 28 * 20 + 42 * 10 = 520 + 560 + 420 = 1500 DKP DKP out: 1200 DKP
Zero-sum is not maintained because of the bonuses applied, which inflates the system.
Total bonus points: 400 + 100 + 2 * 20 = 540 DKP DKP in - Total bonus points = 1500 - 540 = 960 DKP DKP out * reward modifier = 1200 * 0.8 = 960 DKP
So without any bonuses, and a reward modifier set to 1.0, zero-sum is maintained.
