sort intersects by CC, implement max profit search
This commit is contained in:
@@ -12,6 +12,8 @@ import javafx.scene.input.*;
|
|||||||
import javafx.util.converter.NumberStringConverter;
|
import javafx.util.converter.NumberStringConverter;
|
||||||
import org.controlsfx.control.CheckComboBox;
|
import org.controlsfx.control.CheckComboBox;
|
||||||
import org.controlsfx.control.MasterDetailPane;
|
import org.controlsfx.control.MasterDetailPane;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import ru.trader.Main;
|
import ru.trader.Main;
|
||||||
import ru.trader.analysis.PowerPlayAnalyzator;
|
import ru.trader.analysis.PowerPlayAnalyzator;
|
||||||
import ru.trader.core.*;
|
import ru.trader.core.*;
|
||||||
@@ -31,6 +33,7 @@ import java.util.Optional;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class PowerPlayController {
|
public class PowerPlayController {
|
||||||
|
private final static Logger LOG = LoggerFactory.getLogger(PowerPlayController.class);
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private TextField checkedSystemText;
|
private TextField checkedSystemText;
|
||||||
@@ -56,6 +59,8 @@ public class PowerPlayController {
|
|||||||
@FXML
|
@FXML
|
||||||
private RadioButton rbControlling;
|
private RadioButton rbControlling;
|
||||||
@FXML
|
@FXML
|
||||||
|
private RadioButton rbMaxProfit;
|
||||||
|
@FXML
|
||||||
private ListView<SystemModel> historySystems;
|
private ListView<SystemModel> historySystems;
|
||||||
@FXML
|
@FXML
|
||||||
private ListView<SystemModel> controlSystems;
|
private ListView<SystemModel> controlSystems;
|
||||||
@@ -80,7 +85,7 @@ public class PowerPlayController {
|
|||||||
private PowerPlayAnalyzator analyzator;
|
private PowerPlayAnalyzator analyzator;
|
||||||
private final ObservableList<ResultEntry> result = FXCollections.observableArrayList();
|
private final ObservableList<ResultEntry> result = FXCollections.observableArrayList();
|
||||||
private final ObservableList<ResultEntry> detail = FXCollections.observableArrayList();
|
private final ObservableList<ResultEntry> detail = FXCollections.observableArrayList();
|
||||||
|
private Place detailSystem;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void initialize(){
|
private void initialize(){
|
||||||
@@ -181,12 +186,12 @@ public class PowerPlayController {
|
|||||||
NumberStringConverter converter = new NumberStringConverter("#,##0.##");
|
NumberStringConverter converter = new NumberStringConverter("#,##0.##");
|
||||||
result.addListener((InvalidationListener) i -> {
|
result.addListener((InvalidationListener) i -> {
|
||||||
resultPopSumm.setText(converter.toString(getPopulationSumm(result)));
|
resultPopSumm.setText(converter.toString(getPopulationSumm(result)));
|
||||||
resultCCSumm.setText(getCCSummText(result));
|
resultCCSumm.setText(getCCSummText(result, getCheckedSystem()));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
detail.addListener((InvalidationListener) i -> {
|
detail.addListener((InvalidationListener) i -> {
|
||||||
detailPopSumm.setText(converter.toString(getPopulationSumm(detail)));
|
detailPopSumm.setText(converter.toString(getPopulationSumm(detail)));
|
||||||
detailCCSumm.setText(getCCSummText(detail));
|
detailCCSumm.setText(getCCSummText(detail, detailSystem));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -195,7 +200,7 @@ public class PowerPlayController {
|
|||||||
return collection.stream().mapToLong(ResultEntry::getPopulation).sum();
|
return collection.stream().mapToLong(ResultEntry::getPopulation).sum();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCCSummText(Collection<ResultEntry> collection){
|
private String getCCSummText(Collection<ResultEntry> collection, Place starSystem){
|
||||||
String ccFormat = Localization.getString("powerplay.label.summcc");
|
String ccFormat = Localization.getString("powerplay.label.summcc");
|
||||||
String pwCCFormat = Localization.getString("powerplay.label.cc");
|
String pwCCFormat = Localization.getString("powerplay.label.cc");
|
||||||
PowerStringConverter converter = new PowerStringConverter();
|
PowerStringConverter converter = new PowerStringConverter();
|
||||||
@@ -218,8 +223,13 @@ public class PowerPlayController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
double upkeep = 0;
|
||||||
|
if (hqSystem.isPresent() && starSystem != null){
|
||||||
|
upkeep = starSystem.computeUpkeep(ModelFabric.get(hqSystem.get()));
|
||||||
|
}
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append(String.format(ccFormat, summCc, contested, summCc - contested));
|
builder.append(String.format(ccFormat, summCc, contested, upkeep, summCc - contested - upkeep));
|
||||||
for (int i = 0; i < POWER.values().length; i++) {
|
for (int i = 0; i < POWER.values().length; i++) {
|
||||||
if (totalCc[i] > 0 || contestedCc[i] > 0){
|
if (totalCc[i] > 0 || contestedCc[i] > 0){
|
||||||
builder.append("\n");
|
builder.append("\n");
|
||||||
@@ -231,6 +241,7 @@ public class PowerPlayController {
|
|||||||
|
|
||||||
private void fillDetail(SystemModel detailSystem) {
|
private void fillDetail(SystemModel detailSystem) {
|
||||||
final Place starSystem = ModelFabric.get(detailSystem);
|
final Place starSystem = ModelFabric.get(detailSystem);
|
||||||
|
this.detailSystem = starSystem;
|
||||||
detail.clear();
|
detail.clear();
|
||||||
if (starSystem != null){
|
if (starSystem != null){
|
||||||
Collection<PowerPlayAnalyzator.IntersectData> controllings = analyzator.getControlling(starSystem);
|
Collection<PowerPlayAnalyzator.IntersectData> controllings = analyzator.getControlling(starSystem);
|
||||||
@@ -239,9 +250,12 @@ public class PowerPlayController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Place getCheckedSystem(){
|
||||||
|
return ModelFabric.get(checkedSystem.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
private void getIntersects(){
|
private void getIntersects(){
|
||||||
Place starSystem = ModelFabric.get(checkedSystem.getValue());
|
Place starSystem = getCheckedSystem();
|
||||||
Collection<Place> controlls = getControlSystems();
|
Collection<Place> controlls = getControlSystems();
|
||||||
result.clear();
|
result.clear();
|
||||||
if (starSystem != null && !controlls.isEmpty()){
|
if (starSystem != null && !controlls.isEmpty()){
|
||||||
@@ -251,7 +265,7 @@ public class PowerPlayController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void getControlling(){
|
private void getControlling(){
|
||||||
final Place starSystem = ModelFabric.get(checkedSystem.getValue());
|
final Place starSystem = getCheckedSystem();
|
||||||
result.clear();
|
result.clear();
|
||||||
if (starSystem != null){
|
if (starSystem != null){
|
||||||
Collection<PowerPlayAnalyzator.IntersectData> controllings = analyzator.getControlling(starSystem);
|
Collection<PowerPlayAnalyzator.IntersectData> controllings = analyzator.getControlling(starSystem);
|
||||||
@@ -269,6 +283,16 @@ public class PowerPlayController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getMaxProfit(){
|
||||||
|
final Place hq = ModelFabric.get(hqSystem.get());
|
||||||
|
if (hq != null){
|
||||||
|
Collection<Place> controlls = getControlSystems();
|
||||||
|
result.clear();
|
||||||
|
Collection<PowerPlayAnalyzator.IntersectData> near = analyzator.getMaxProfit(hq, controlls);
|
||||||
|
result.addAll(BindingsHelper.observableList(near, ResultEntry::new));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void getNearExpansions(){
|
private void getNearExpansions(){
|
||||||
Collection<Place> controlls = getControlSystems();
|
Collection<Place> controlls = getControlSystems();
|
||||||
result.clear();
|
result.clear();
|
||||||
@@ -323,6 +347,9 @@ public class PowerPlayController {
|
|||||||
if (rbMaxIntersect.isSelected()){
|
if (rbMaxIntersect.isSelected()){
|
||||||
getMaxIntersect();
|
getMaxIntersect();
|
||||||
}
|
}
|
||||||
|
if (rbMaxProfit.isSelected()){
|
||||||
|
getMaxProfit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -410,8 +437,9 @@ public class PowerPlayController {
|
|||||||
private final ReadOnlyStringProperty intersecting;
|
private final ReadOnlyStringProperty intersecting;
|
||||||
private final ReadOnlyStringProperty controlling;
|
private final ReadOnlyStringProperty controlling;
|
||||||
private final ReadOnlyLongProperty population;
|
private final ReadOnlyLongProperty population;
|
||||||
private final ReadOnlyLongProperty upkeep;
|
private final ReadOnlyLongProperty currentUpkeep;
|
||||||
private final ReadOnlyLongProperty income;
|
private final ReadOnlyLongProperty income;
|
||||||
|
private final ReadOnlyDoubleProperty upkeep;
|
||||||
private final ReadOnlyLongProperty cc;
|
private final ReadOnlyLongProperty cc;
|
||||||
|
|
||||||
public ResultEntry(PowerPlayAnalyzator.IntersectData data) {
|
public ResultEntry(PowerPlayAnalyzator.IntersectData data) {
|
||||||
@@ -428,7 +456,8 @@ public class PowerPlayController {
|
|||||||
Place hq = ModelFabric.get(hqSystem.orElse(null));
|
Place hq = ModelFabric.get(hqSystem.orElse(null));
|
||||||
distanceHQ = new SimpleDoubleProperty(hq != null ? hq.getDistance(data.getStarSystem()) : Double.NaN);
|
distanceHQ = new SimpleDoubleProperty(hq != null ? hq.getDistance(data.getStarSystem()) : Double.NaN);
|
||||||
population = new SimpleLongProperty(data.getStarSystem().getPopulation());
|
population = new SimpleLongProperty(data.getStarSystem().getPopulation());
|
||||||
upkeep = new SimpleLongProperty(data.getStarSystem().getUpkeep());
|
currentUpkeep = new SimpleLongProperty(data.getStarSystem().getUpkeep());
|
||||||
|
upkeep = new SimpleDoubleProperty(hq != null ? data.getStarSystem().computeUpkeep(hq) : Double.NaN);
|
||||||
income = new SimpleLongProperty(data.getStarSystem().getIncome());
|
income = new SimpleLongProperty(data.getStarSystem().getIncome());
|
||||||
cc = new SimpleLongProperty(data.getStarSystem().computeCC(ModelFabric.get(profile).getCCgroups()));
|
cc = new SimpleLongProperty(data.getStarSystem().computeCC(ModelFabric.get(profile).getCCgroups()));
|
||||||
}
|
}
|
||||||
@@ -529,10 +558,14 @@ public class PowerPlayController {
|
|||||||
return population;
|
return population;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReadOnlyLongProperty upkeepProperty() {
|
public ReadOnlyDoubleProperty upkeepProperty() {
|
||||||
return upkeep;
|
return upkeep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ReadOnlyLongProperty currentUpkeepProperty() {
|
||||||
|
return currentUpkeep;
|
||||||
|
}
|
||||||
|
|
||||||
public ReadOnlyLongProperty incomeProperty() {
|
public ReadOnlyLongProperty incomeProperty() {
|
||||||
return income;
|
return income;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -274,6 +274,7 @@ missions.supply.text=Supply %d %s to %s at %s
|
|||||||
powerplay.analyze.title=Analyze parameters
|
powerplay.analyze.title=Analyze parameters
|
||||||
powerplay.analyze.intersect=Intersect search
|
powerplay.analyze.intersect=Intersect search
|
||||||
powerplay.analyze.near=Near search without intersect
|
powerplay.analyze.near=Near search without intersect
|
||||||
|
powerplay.analyze.maxProfit=Max profit search
|
||||||
powerplay.analyze.maxIntersect=Max intersection search
|
powerplay.analyze.maxIntersect=Max intersection search
|
||||||
powerplay.analyze.expansions=Near expansions
|
powerplay.analyze.expansions=Near expansions
|
||||||
powerplay.analyze.controlling=Systems in controlled radius
|
powerplay.analyze.controlling=Systems in controlled radius
|
||||||
@@ -285,7 +286,7 @@ powerplay.label.power.systems=Systems of Power:
|
|||||||
powerplay.label.power.state=State:
|
powerplay.label.power.state=State:
|
||||||
powerplay.label.populationSumm=Summ populations:
|
powerplay.label.populationSumm=Summ populations:
|
||||||
powerplay.label.cc=%s: %4d CC Contested: %4d CC
|
powerplay.label.cc=%s: %4d CC Contested: %4d CC
|
||||||
powerplay.label.summcc=Summ: %6d CC Contested: %6d CC Total: %6dCC
|
powerplay.label.summcc=Summ: %6d CC Contested: %6d CC Upkeep: %6.1f CC Total: %6.1f CC
|
||||||
powerplay.result.title=Analyze result
|
powerplay.result.title=Analyze result
|
||||||
powerplay.column.intersecting=Intersect
|
powerplay.column.intersecting=Intersect
|
||||||
powerplay.column.intersectCount=Intersect count
|
powerplay.column.intersectCount=Intersect count
|
||||||
|
|||||||
@@ -274,6 +274,7 @@ missions.supply.text=\u041A\u0443\u043F\u0438\u0442\u044C \u0438 \u0434\u043E\u0
|
|||||||
powerplay.analyze.title=\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u0430\u043D\u0430\u043B\u0438\u0437\u0430
|
powerplay.analyze.title=\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u0430\u043D\u0430\u043B\u0438\u0437\u0430
|
||||||
powerplay.analyze.intersect=\u041F\u043E\u0438\u0441\u043A \u043F\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043D\u0438\u0439
|
powerplay.analyze.intersect=\u041F\u043E\u0438\u0441\u043A \u043F\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043D\u0438\u0439
|
||||||
powerplay.analyze.near=\u041F\u043E\u0438\u0441\u043A \u0431\u043B\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u0431\u0435\u0437 \u043F\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043D\u0438\u0439
|
powerplay.analyze.near=\u041F\u043E\u0438\u0441\u043A \u0431\u043B\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u0431\u0435\u0437 \u043F\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043D\u0438\u0439
|
||||||
|
powerplay.analyze.maxProfit=\u041F\u043E\u0438\u0441\u043A \u043F\u0440\u0438\u0431\u044B\u043B\u044C\u043D\u044B\u0445 \u0441\u0438\u0441\u0442\u0435\u043C
|
||||||
powerplay.analyze.maxIntersect=\u041F\u043E\u0438\u0441\u043A \u0441 \u043C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u044B\u043C \u043F\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043D\u0438\u0435\u043C
|
powerplay.analyze.maxIntersect=\u041F\u043E\u0438\u0441\u043A \u0441 \u043C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u044B\u043C \u043F\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043D\u0438\u0435\u043C
|
||||||
powerplay.analyze.expansions=\u0411\u043B\u0438\u0436\u0430\u0439\u0448\u0438\u0435 \u044D\u043A\u0441\u043F\u0430\u043D\u0441\u0438\u0438
|
powerplay.analyze.expansions=\u0411\u043B\u0438\u0436\u0430\u0439\u0448\u0438\u0435 \u044D\u043A\u0441\u043F\u0430\u043D\u0441\u0438\u0438
|
||||||
powerplay.analyze.controlling=\u0421\u0438\u0441\u0442\u0435\u043C\u044B \u0432 \u043F\u043E\u0434\u043A\u043E\u043D\u0442\u0440\u043E\u043B\u044C\u043D\u043E\u043C \u0440\u0430\u0434\u0438\u0443\u0441\u0435
|
powerplay.analyze.controlling=\u0421\u0438\u0441\u0442\u0435\u043C\u044B \u0432 \u043F\u043E\u0434\u043A\u043E\u043D\u0442\u0440\u043E\u043B\u044C\u043D\u043E\u043C \u0440\u0430\u0434\u0438\u0443\u0441\u0435
|
||||||
@@ -285,7 +286,7 @@ powerplay.label.power.systems=C\u0438\u0441\u0442\u0435\u043C\u044B \u0441\u0438
|
|||||||
powerplay.label.power.state=\u0421\u043E\u0441\u0442\u043E\u044F\u043D\u0438\u0435:
|
powerplay.label.power.state=\u0421\u043E\u0441\u0442\u043E\u044F\u043D\u0438\u0435:
|
||||||
powerplay.label.populationSumm=\u0421\u0443\u043C\u043C\u0430 \u043D\u0430\u0441\u0435\u043B\u0435\u043D\u0438\u044F:
|
powerplay.label.populationSumm=\u0421\u0443\u043C\u043C\u0430 \u043D\u0430\u0441\u0435\u043B\u0435\u043D\u0438\u044F:
|
||||||
powerplay.label.cc=%s: %4d \u041A\u041A \u041E\u0441\u043F\u0430\u0440\u0438\u0432\u0430\u0435\u043C\u044B\u0445: %4d \u041A\u041A
|
powerplay.label.cc=%s: %4d \u041A\u041A \u041E\u0441\u043F\u0430\u0440\u0438\u0432\u0430\u0435\u043C\u044B\u0445: %4d \u041A\u041A
|
||||||
powerplay.label.summcc=\u0421\u0443\u043C\u043C\u0430: %6d \u041A\u041A \u041E\u0441\u043F\u0430\u0440\u0438\u0432\u0430\u0435\u043C\u044B\u0445: %6d \u041A\u041A \u0418\u0442\u043E\u0433\u043E: %6d\u041A\u041A
|
powerplay.label.summcc=\u0421\u0443\u043C\u043C\u0430: %6d \u041A\u041A \u041E\u0441\u043F\u0430\u0440\u0438\u0432\u0430\u0435\u043C\u044B\u0445: %6d \u041A\u041A \u0420\u0430\u0441\u0445\u043E\u0434\u044B: %6.1f \u041A\u041A \u0418\u0442\u043E\u0433\u043E: %6.1f \u041A\u041A
|
||||||
powerplay.result.title=\u0420\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442\u044B \u0430\u043D\u0430\u043B\u0438\u0437\u0430
|
powerplay.result.title=\u0420\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442\u044B \u0430\u043D\u0430\u043B\u0438\u0437\u0430
|
||||||
powerplay.column.intersecting=\u041F\u0435\u0440\u0435\u0441\u0435\u043A\u0430\u0435\u0442\u0441\u044F \u0441
|
powerplay.column.intersecting=\u041F\u0435\u0440\u0435\u0441\u0435\u043A\u0430\u0435\u0442\u0441\u044F \u0441
|
||||||
powerplay.column.intersectCount=\u041F\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043D\u0438\u0439
|
powerplay.column.intersectCount=\u041F\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043D\u0438\u0439
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<fx:define><Insets fx:id="tablePadding" left="0" right="0" top="0" bottom="0" /></fx:define>
|
<fx:define><Insets fx:id="tablePadding" left="0" right="0" top="0" bottom="0" /></fx:define>
|
||||||
<fx:define><Insets fx:id="summPadding" left="4" right="4" top="4" bottom="4" /></fx:define>
|
<fx:define><Insets fx:id="summPadding" left="4" right="4" top="4" bottom="4" /></fx:define>
|
||||||
<TitledPane text="%powerplay.analyze.title" collapsible="false">
|
<TitledPane text="%powerplay.analyze.title" collapsible="false">
|
||||||
<HBox spacing="50" alignment="CENTER" minHeight="210" maxHeight="210">
|
<HBox spacing="50" alignment="CENTER" minHeight="230" maxHeight="230">
|
||||||
<VBox minWidth="250" maxWidth="250" spacing="4">
|
<VBox minWidth="250" maxWidth="250" spacing="4">
|
||||||
<Label text="%powerplay.label.checked" />
|
<Label text="%powerplay.label.checked" />
|
||||||
<HBox spacing="4" alignment="BASELINE_LEFT">
|
<HBox spacing="4" alignment="BASELINE_LEFT">
|
||||||
@@ -47,6 +47,7 @@
|
|||||||
<fx:define><ToggleGroup fx:id="analyzeType" /></fx:define>
|
<fx:define><ToggleGroup fx:id="analyzeType" /></fx:define>
|
||||||
<RadioButton fx:id="rbIntersect" text="%powerplay.analyze.intersect" selected="true" toggleGroup="$analyzeType"/>
|
<RadioButton fx:id="rbIntersect" text="%powerplay.analyze.intersect" selected="true" toggleGroup="$analyzeType"/>
|
||||||
<RadioButton fx:id="rbNear" text="%powerplay.analyze.near" selected="false" toggleGroup="$analyzeType"/>
|
<RadioButton fx:id="rbNear" text="%powerplay.analyze.near" selected="false" toggleGroup="$analyzeType"/>
|
||||||
|
<RadioButton fx:id="rbMaxProfit" text="%powerplay.analyze.maxProfit" selected="false" toggleGroup="$analyzeType"/>
|
||||||
<RadioButton fx:id="rbMaxIntersect" text="%powerplay.analyze.maxIntersect" selected="false" toggleGroup="$analyzeType"/>
|
<RadioButton fx:id="rbMaxIntersect" text="%powerplay.analyze.maxIntersect" selected="false" toggleGroup="$analyzeType"/>
|
||||||
<RadioButton fx:id="rbExpansions" text="%powerplay.analyze.expansions" selected="false" toggleGroup="$analyzeType"/>
|
<RadioButton fx:id="rbExpansions" text="%powerplay.analyze.expansions" selected="false" toggleGroup="$analyzeType"/>
|
||||||
<RadioButton fx:id="rbControlling" text="%powerplay.analyze.controlling" selected="false" toggleGroup="$analyzeType"/>
|
<RadioButton fx:id="rbControlling" text="%powerplay.analyze.controlling" selected="false" toggleGroup="$analyzeType"/>
|
||||||
@@ -129,7 +130,7 @@
|
|||||||
<cellValueFactory><PropertyValueFactory property="income"/></cellValueFactory>
|
<cellValueFactory><PropertyValueFactory property="income"/></cellValueFactory>
|
||||||
</TableColumn>
|
</TableColumn>
|
||||||
<TableColumn prefWidth="60" text="%market.system.upkeep">
|
<TableColumn prefWidth="60" text="%market.system.upkeep">
|
||||||
<cellValueFactory><PropertyValueFactory property="upkeep"/></cellValueFactory>
|
<cellValueFactory><PropertyValueFactory property="currentUpkeep"/></cellValueFactory>
|
||||||
</TableColumn>
|
</TableColumn>
|
||||||
<TableColumn prefWidth="80" text="%market.population">
|
<TableColumn prefWidth="80" text="%market.population">
|
||||||
<cellFactory><TextCell><converter><CustomNumberStringConverter pattern="#,##0.##" /></converter></TextCell></cellFactory>
|
<cellFactory><TextCell><converter><CustomNumberStringConverter pattern="#,##0.##" /></converter></TextCell></cellFactory>
|
||||||
|
|||||||
@@ -44,6 +44,11 @@ public class PowerPlayAnalyzator {
|
|||||||
return getIntersects(starSystem, candidates, starSystems, Market.CONTROLLING_RADIUS).collect(Collectors.toList());
|
return getIntersects(starSystem, candidates, starSystems, Market.CONTROLLING_RADIUS).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Collection<IntersectData> getMaxProfit(Place headquarter, Collection<Place> starSystems){
|
||||||
|
Stream<Place> candidates = market.get().stream().filter(Place::isPopulated);
|
||||||
|
return getMaxProfit(candidates, headquarter, starSystems, Market.CONTROLLING_RADIUS, 200).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
public Collection<IntersectData> getMaxIntersect(Collection<Place> starSystems){
|
public Collection<IntersectData> getMaxIntersect(Collection<Place> starSystems){
|
||||||
Stream<Place> candidates = market.get().stream().filter(Place::isPopulated);
|
Stream<Place> candidates = market.get().stream().filter(Place::isPopulated);
|
||||||
return getMaxIntersect(candidates, starSystems, Market.CONTROLLING_RADIUS).collect(Collectors.toList());
|
return getMaxIntersect(candidates, starSystems, Market.CONTROLLING_RADIUS).collect(Collectors.toList());
|
||||||
@@ -120,9 +125,9 @@ public class PowerPlayAnalyzator {
|
|||||||
.map(checkedMapper)
|
.map(checkedMapper)
|
||||||
.filter(IntersectData::isIntersect)
|
.filter(IntersectData::isIntersect)
|
||||||
.sorted((d1, d2) -> {
|
.sorted((d1, d2) -> {
|
||||||
long pop1 = d1.getControllingSystems().stream().mapToLong(d -> d.center.getPopulation()).sum();
|
long cc1 = d1.getControllingIncome();
|
||||||
long pop2 = d2.getControllingSystems().stream().mapToLong(d -> d.center.getPopulation()).sum();
|
long cc2 = d2.getControllingIncome();
|
||||||
int cmp = Long.compare(pop2, pop1);
|
int cmp = Long.compare(cc2, cc1);
|
||||||
if (cmp == 0) cmp = Integer.compare(d2.getCount(), d1.getCount());
|
if (cmp == 0) cmp = Integer.compare(d2.getCount(), d1.getCount());
|
||||||
return cmp;
|
return cmp;
|
||||||
})
|
})
|
||||||
@@ -131,6 +136,30 @@ public class PowerPlayAnalyzator {
|
|||||||
.filter(IntersectData::isIntersect);
|
.filter(IntersectData::isIntersect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Stream<IntersectData> getMaxProfit(Stream<Place> starSystems, Place headquarter, Collection<Place> centers, double radius, double maxDistance){
|
||||||
|
Collection<Place> candidates = new ArrayList<>();
|
||||||
|
starSystems.filter(p ->p.getPower() == POWER.NONE && p.getDistance(headquarter) <= maxDistance)
|
||||||
|
.forEach(candidates::add);
|
||||||
|
IntersectsMapper candidatesMapper = new IntersectsMapper(candidates, radius, false, true);
|
||||||
|
IntersectsMapper centersMapper = new IntersectsMapper(centers, radius*2, false, true);
|
||||||
|
|
||||||
|
return candidates.stream()
|
||||||
|
.map(candidatesMapper)
|
||||||
|
.filter(IntersectData::isIntersect)
|
||||||
|
.sorted((d1, d2) -> {
|
||||||
|
double upkeep1 = d1.getStarSystem().computeUpkeep(headquarter);
|
||||||
|
double upkeep2 = d2.getStarSystem().computeUpkeep(headquarter);
|
||||||
|
double profit1 = d1.getIncome() - upkeep1;
|
||||||
|
double profit2 = d2.getIncome() - upkeep2;
|
||||||
|
int cmp = Double.compare(profit2, profit1);
|
||||||
|
if (cmp == 0) cmp = Integer.compare(d1.getCount(), d2.getCount());
|
||||||
|
return cmp;
|
||||||
|
})
|
||||||
|
.map(IntersectData::getStarSystem)
|
||||||
|
.map(centersMapper)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
public static Collection<IntersectData> getNearExpansions(Collection<Place> starSystems, Collection<Place> centers, double maxDistance){
|
public static Collection<IntersectData> getNearExpansions(Collection<Place> starSystems, Collection<Place> centers, double maxDistance){
|
||||||
return getNearExpansions(starSystems.stream(), centers, maxDistance).collect(Collectors.toList());
|
return getNearExpansions(starSystems.stream(), centers, maxDistance).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
@@ -310,22 +339,26 @@ public class PowerPlayAnalyzator {
|
|||||||
public static class IntersectData {
|
public static class IntersectData {
|
||||||
private final Place starSystem;
|
private final Place starSystem;
|
||||||
private final ControllingData[] contollings;
|
private final ControllingData[] contollings;
|
||||||
|
private final long income;
|
||||||
|
|
||||||
public IntersectData(Place starSystem) {
|
public IntersectData(Place starSystem) {
|
||||||
this.starSystem = starSystem;
|
this.starSystem = starSystem;
|
||||||
this.contollings = new ControllingData[0];
|
this.contollings = new ControllingData[0];
|
||||||
|
this.income = computeIncome();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IntersectData(Place starSystem, Place control, double distance) {
|
public IntersectData(Place starSystem, Place control, double distance) {
|
||||||
this.starSystem = starSystem;
|
this.starSystem = starSystem;
|
||||||
this.contollings = new ControllingData[]{new ControllingData(control,distance)};
|
this.contollings = new ControllingData[]{new ControllingData(control,distance)};
|
||||||
|
this.income = computeIncome();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntersectData(Place starSystem, Collection<ControllingData> controlling) {
|
public IntersectData(Place starSystem, Collection<ControllingData> controlling) {
|
||||||
this.starSystem = starSystem;
|
this.starSystem = starSystem;
|
||||||
this.contollings = controlling.toArray(new ControllingData[controlling.size()]);
|
this.contollings = controlling.toArray(new ControllingData[controlling.size()]);
|
||||||
Arrays.sort(contollings);
|
Arrays.sort(contollings);
|
||||||
|
this.income = computeIncome();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Place getStarSystem() {
|
public Place getStarSystem() {
|
||||||
@@ -347,6 +380,25 @@ public class PowerPlayAnalyzator {
|
|||||||
public boolean isIntersect(){
|
public boolean isIntersect(){
|
||||||
return contollings.length > 0;
|
return contollings.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getIncome() {
|
||||||
|
return income;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getControllingIncome(){
|
||||||
|
long income = 0;
|
||||||
|
for (ControllingData contolling : contollings) {
|
||||||
|
Place place = contolling.center;
|
||||||
|
if (place.getPowerState() != POWER_STATE.CONTESTED){
|
||||||
|
income += place.computeCC();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return income;
|
||||||
|
}
|
||||||
|
|
||||||
|
private long computeIncome(){
|
||||||
|
return starSystem.computeCC() + getControllingIncome();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ControllingData implements Comparable<ControllingData> {
|
public static class ControllingData implements Comparable<ControllingData> {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class Profile {
|
|||||||
jumpTime = 32;
|
jumpTime = 32;
|
||||||
rechargeTime = 12;
|
rechargeTime = 12;
|
||||||
pathPriority = PATH_PRIORITY.FAST;
|
pathPriority = PATH_PRIORITY.FAST;
|
||||||
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};
|
CCgroups = Place.CCgroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Profile(Profile profile){
|
protected Profile(Profile profile){
|
||||||
|
|||||||
Reference in New Issue
Block a user