Added math stuff to calculate price based on points (thanks everett)
This commit is contained in:
@@ -3,11 +3,17 @@ package com.alttd.objects;
|
||||
import com.alttd.config.Config;
|
||||
import com.alttd.util.Logger;
|
||||
import com.alttd.util.Utilities;
|
||||
import org.apache.commons.math3.analysis.function.StepFunction;
|
||||
import org.apache.commons.math3.analysis.integration.TrapezoidIntegrator;
|
||||
|
||||
public final class Price {
|
||||
private final double price;
|
||||
private final int points;
|
||||
|
||||
double x_mult[] = {0, 500, 2000, 4000};
|
||||
double y_mult[] = {1.0, 1.5, 2.5, 5.0};
|
||||
StepFunction multiplierModel = new StepFunction(x_mult, y_mult);
|
||||
|
||||
public Price(double price) {
|
||||
this.price = price;
|
||||
for (int key : Config.pointsRangeMap.keySet()) {
|
||||
@@ -28,6 +34,12 @@ public final class Price {
|
||||
return (Utilities.round(price * multiplier, 2));
|
||||
}
|
||||
|
||||
public double calculatePriceThing(int oldPoints, int transPts) {
|
||||
// Compute numerical integration to determine price
|
||||
TrapezoidIntegrator trapez = new TrapezoidIntegrator();
|
||||
return (price * trapez.integrate(10, multiplierModel, oldPoints, oldPoints + transPts));
|
||||
}
|
||||
|
||||
public int getPoints() {
|
||||
return (points);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user