From a543c216a4039ef4f1a074be8c88fe1780090ae0 Mon Sep 17 00:00:00 2001 From: Mo Date: Sat, 3 Dec 2016 16:02:06 +0300 Subject: [PATCH] use formula for compute CC --- core/src/main/java/ru/trader/core/Place.java | 16 +----------- .../src/main/java/ru/trader/core/Profile.java | 26 ------------------- 2 files changed, 1 insertion(+), 41 deletions(-) diff --git a/core/src/main/java/ru/trader/core/Place.java b/core/src/main/java/ru/trader/core/Place.java index 29a63ee..f4a3a22 100644 --- a/core/src/main/java/ru/trader/core/Place.java +++ b/core/src/main/java/ru/trader/core/Place.java @@ -108,22 +108,8 @@ public interface Place extends Connectable { return distance * distance * 0.001 + 20.5; } - //возможно log(0.32 * Население) - static long[] CCgroups = new long[]{0,0,0,3_140,31_530,316_000,3_160_000,31_620_000,320_000_000,3_162_000_000L}; - default long computeCC(){ - return computeCC(CCgroups); + return Math.round(Math.log10(getPopulation())+1); } - default long computeCC(long[] CCgroups){ - long population = getPopulation(); - if (population == 0) return 0; - for (int i = 0; i < CCgroups.length; i++) { - long minPop = CCgroups[i]; - if (population < minPop){ - return i+1; - } - } - return CCgroups.length+1; - } } diff --git a/core/src/main/java/ru/trader/core/Profile.java b/core/src/main/java/ru/trader/core/Profile.java index b676df8..c133578 100644 --- a/core/src/main/java/ru/trader/core/Profile.java +++ b/core/src/main/java/ru/trader/core/Profile.java @@ -25,7 +25,6 @@ public class Profile { private double rechargeTime; private double fuelPrice; private PATH_PRIORITY pathPriority; - private long[] CCgroups; public Profile(Ship ship) { this.ship = ship; @@ -42,7 +41,6 @@ public class Profile { jumpTime = 32; rechargeTime = 12; pathPriority = PATH_PRIORITY.FAST; - CCgroups = Place.CCgroups; } protected Profile(Profile profile){ @@ -65,7 +63,6 @@ public class Profile { this.system = profile.system; this.station = profile.station; this.ship = Ship.clone(profile.ship); - this.CCgroups = profile.CCgroups; } public String getName() { @@ -220,14 +217,6 @@ public class Profile { this.pathPriority = pathPriority; } - public long[] getCCgroups() { - return CCgroups; - } - - public void setCCgroups(long[] CCgroups) { - this.CCgroups = CCgroups; - } - public static Profile readFrom(Properties values, Market market){ Ship ship = Ship.readFrom(values); Profile profile = new Profile(ship); @@ -260,15 +249,6 @@ public class Profile { profile.setTakeoffTime(Double.valueOf(values.getProperty("profile.search.times.takeoff", "40"))); profile.setJumpTime(Double.valueOf(values.getProperty("profile.search.times.jump", "32"))); profile.setRechargeTime(Double.valueOf(values.getProperty("profile.search.times.recharge", "12"))); - v = values.getProperty("profile.powerplay.cc", null); - if (v != null){ - String[] strings = v.split(","); - long[] cc = new long[strings.length]; - for (int i = 0; i < strings.length; i++) { - cc[i] = Long.valueOf(strings[i]); - } - profile.setCCgroups(cc); - } return profile; } @@ -290,12 +270,6 @@ public class Profile { values.setProperty("profile.search.times.takeoff", String.valueOf(takeoffTime)); values.setProperty("profile.search.times.jump", String.valueOf(jumpTime)); values.setProperty("profile.search.times.recharge", String.valueOf(rechargeTime)); - StringBuilder builder = new StringBuilder(); - for (long cc : CCgroups) { - if (builder.length() > 0) builder.append(","); - builder.append(cc); - } - values.setProperty("profile.powerplay.cc", builder.toString()); ship.writeTo(values); }