reformat
parent
25b4444a73
commit
c42915ecb4
|
|
@ -8,9 +8,7 @@ import satisfactory.items.type.*;
|
|||
import java.util.*;
|
||||
|
||||
public class Database {
|
||||
private static final Collection<Item> items = new HashSet<>();
|
||||
public static final Map<Item, Recipe> preferences = new HashMap<>();
|
||||
|
||||
// Items & recipes
|
||||
public static final Item IronOre = new Ore("Iron Ore");
|
||||
public static final Item IronIngot = new Ingot("Iron Ingot");
|
||||
|
|
@ -95,29 +93,17 @@ public class Database {
|
|||
public static final Item Silica = new Part("Silica");
|
||||
public static final Item Bauxite = new Ore("Bauxite");
|
||||
public static final Item AluminaSolution = new ProcessedFluid("Alumina Solution");
|
||||
|
||||
public static final Item SulfuricAcid = new ProcessedFluid("Sulfuric Acid");
|
||||
|
||||
public static final Item EncasedUraniumCell = new Part("Encased Uranium Cell");
|
||||
|
||||
public static final Item ElectromagneticControlRod = new Part("Electromagnetic Control Rod");
|
||||
|
||||
public static final Item UraniumFuelRod = new Part("Uranium Fuel Rod");
|
||||
|
||||
public static final Item Uranium = new Ore("Uranium");
|
||||
|
||||
public static final Item Battery = new Part("Battery");
|
||||
|
||||
public static final Item MagneticFieldGenerator = new Part("Magnetic Field Generator");
|
||||
|
||||
public static final Item HeatSink = new Part("Heat Sink");
|
||||
|
||||
public static final Item AssemblyDirectorSystem = new Part("Assembly Director System");
|
||||
|
||||
public static final Item NitrogenGas = new Gas("Nitrogen Gas");
|
||||
|
||||
public static final Item CoolingSystem = new Part("Cooling System");
|
||||
|
||||
public static final Item FusedModularFrame = new Part("Fused Modular Frame");
|
||||
public static final Item PortableMiner = new Tool("Portable Miner");
|
||||
public static final Item Turbofuel = new ProcessedFluid("Turbofuel");
|
||||
|
|
@ -133,6 +119,7 @@ public class Database {
|
|||
public static final Item ClusterNobelisk = new Part("Cluster Nobelisk");
|
||||
public static final Item ObjectScanner = new Tool("Object Scanner");
|
||||
public static final Item NobeliskDetonator = new Tool("Nobelisk Detonator");
|
||||
private static final Collection<Item> items = new HashSet<>();
|
||||
|
||||
static {
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@ package satisfactory;
|
|||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import guru.nidi.graphviz.engine.Format;
|
||||
import guru.nidi.graphviz.engine.Graphviz;
|
||||
import guru.nidi.graphviz.engine.GraphvizCmdLineEngine;
|
||||
import guru.nidi.graphviz.engine.GraphvizJdkEngine;
|
||||
import guru.nidi.graphviz.model.MutableGraph;
|
||||
import guru.nidi.graphviz.parse.Parser;
|
||||
import org.jgrapht.Graph;
|
||||
|
|
@ -21,8 +19,10 @@ import java.io.BufferedWriter;
|
|||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static satisfactory.Utils.*;
|
||||
|
||||
|
|
@ -204,7 +204,6 @@ public class Test {
|
|||
}
|
||||
// ref.put(Database.CircuitBoard, 15.0);
|
||||
try (BufferedWriter bw = new BufferedWriter(new FileWriter(LISTS + name + "_java.txt"))) {
|
||||
|
||||
String list = plan.getMap().entrySet().stream().map(item ->
|
||||
"ref.put(Database." + name2(item.getKey().getName()) + ", " + item.getValue() + ");"
|
||||
).reduce("", (s, s2) -> s + "\n" + s2);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import satisfactory.items.ProductionEdge;
|
|||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Utils {
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ import satisfactory.Database;
|
|||
public class GeothermalGenerator extends PowerGenerationBuilding {
|
||||
public GeothermalGenerator() {
|
||||
power = 9999; // TODO
|
||||
cost.put(Database.SuperComputer,8);
|
||||
cost.put(Database.HeavyModularFrame,16);
|
||||
cost.put(Database.HighSpeedConnector,16);
|
||||
cost.put(Database.CopperSheet,40);
|
||||
cost.put(Database.Rubber,80);
|
||||
cost.put(Database.SuperComputer, 8);
|
||||
cost.put(Database.HeavyModularFrame, 16);
|
||||
cost.put(Database.HighSpeedConnector, 16);
|
||||
cost.put(Database.CopperSheet, 40);
|
||||
cost.put(Database.Rubber, 80);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@ public abstract class PowerGenerationBuilding extends Building {
|
|||
protected Map<Item, Integer> consumes;
|
||||
|
||||
public PowerGenerationBuilding() {
|
||||
consumes=new HashMap<>();
|
||||
consumes = new HashMap<>();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package satisfactory.buildings.production;
|
|||
|
||||
import satisfactory.Database;
|
||||
|
||||
public class MinerMk2 extends MinerMk1{
|
||||
public class MinerMk2 extends MinerMk1 {
|
||||
public MinerMk2() {
|
||||
power = 12;
|
||||
cost.put(Database.PortableMiner, 2);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package satisfactory.buildings.production;
|
|||
|
||||
import satisfactory.Database;
|
||||
|
||||
public class MinerMk3 extends MinerMk1{
|
||||
public class MinerMk3 extends MinerMk1 {
|
||||
public MinerMk3() {
|
||||
// TODO: real values!
|
||||
power = 12;
|
||||
|
|
|
|||
|
|
@ -4,15 +4,18 @@ import org.jgrapht.Graph;
|
|||
import org.jgrapht.graph.DefaultWeightedEdge;
|
||||
import satisfactory.Database;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public abstract class Item {
|
||||
protected boolean isRaw = false;
|
||||
private final String name;
|
||||
private final Set<Recipe> recipes;
|
||||
private Recipe preference = null;
|
||||
public int sum = 0;
|
||||
protected boolean isRaw = false;
|
||||
private Recipe preference = null;
|
||||
|
||||
protected Item(String name, Set<Recipe> recipes) {
|
||||
this.name = name;
|
||||
|
|
@ -27,6 +30,15 @@ public abstract class Item {
|
|||
this(name, new HashSet<>());
|
||||
}
|
||||
|
||||
public static Map<Item, Double> production(Graph<Item, DefaultWeightedEdge> graph) {
|
||||
Map<Item, Double> map = new HashMap<>();
|
||||
graph.vertexSet().forEach(item -> {
|
||||
double rate = graph.outgoingEdgesOf(item).stream().mapToDouble(graph::getEdgeWeight).sum();
|
||||
map.put(item, rate);
|
||||
});
|
||||
return map;
|
||||
}
|
||||
|
||||
public void add(Recipe recipe) {
|
||||
if (recipes.isEmpty()) {
|
||||
setPreference(recipe);
|
||||
|
|
@ -84,19 +96,6 @@ public abstract class Item {
|
|||
'}';
|
||||
}
|
||||
|
||||
public void setPreference(Recipe preference) {
|
||||
this.preference = preference;
|
||||
}
|
||||
|
||||
public static Map<Item, Double> production(Graph<Item, DefaultWeightedEdge> graph) {
|
||||
Map<Item, Double> map = new HashMap<>();
|
||||
graph.vertexSet().forEach(item -> {
|
||||
double rate = graph.outgoingEdgesOf(item).stream().mapToDouble(graph::getEdgeWeight).sum();
|
||||
map.put(item, rate);
|
||||
});
|
||||
return map;
|
||||
}
|
||||
|
||||
public Graph<Item, DefaultWeightedEdge> hierarchy() {
|
||||
System.out.println(getRecipe() + " == " + this.preference);
|
||||
return getRecipe().buildGraph(this);
|
||||
|
|
@ -110,4 +109,8 @@ public abstract class Item {
|
|||
return preference;
|
||||
}
|
||||
|
||||
public void setPreference(Recipe preference) {
|
||||
this.preference = preference;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ import java.util.stream.Collectors;
|
|||
public class Recipe {
|
||||
private final Map<Item, Double> inputs;
|
||||
private final Map<Item, Double> outputs;
|
||||
private final int duration;
|
||||
private boolean isHandCraftable = true;
|
||||
private String name;
|
||||
private final int duration;
|
||||
|
||||
public Recipe(int duration, Class<? extends Building> building) {
|
||||
this(duration, new HashMap<>(), new HashMap<>(), building);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import java.util.Arrays;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SumResult {
|
||||
private final Graph<Item, ProductionEdge> production;
|
||||
|
|
@ -23,21 +22,6 @@ public class SumResult {
|
|||
map = new HashMap<>();
|
||||
}
|
||||
|
||||
public Graph<Item, ProductionEdge> getProduction() {
|
||||
return production;
|
||||
}
|
||||
|
||||
public Map<Item, Double> getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
public SumResult merge(SumResult other) {
|
||||
HashMap<Item, Double> map = new HashMap<>();
|
||||
map.putAll(this.map);
|
||||
other.map.forEach((item, aDouble) -> map.merge(item, aDouble, Double::sum));
|
||||
return new SumResult(merge(production, other.getProduction()), map);
|
||||
}
|
||||
|
||||
public static Graph<Item, ProductionEdge> sum(Item item, int amount) {
|
||||
return item.getRecipe().sum(item, amount).getProduction();
|
||||
}
|
||||
|
|
@ -77,4 +61,19 @@ public class SumResult {
|
|||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
public Graph<Item, ProductionEdge> getProduction() {
|
||||
return production;
|
||||
}
|
||||
|
||||
public Map<Item, Double> getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
public SumResult merge(SumResult other) {
|
||||
HashMap<Item, Double> map = new HashMap<>();
|
||||
map.putAll(this.map);
|
||||
other.map.forEach((item, aDouble) -> map.merge(item, aDouble, Double::sum));
|
||||
return new SumResult(merge(production, other.getProduction()), map);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package satisfactory.items.type;
|
||||
|
||||
import satisfactory.items.Item;
|
||||
import satisfactory.items.Recipe;
|
||||
|
||||
public abstract class Fluid extends Item {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package satisfactory.items.type;
|
||||
|
||||
import satisfactory.items.Item;
|
||||
import satisfactory.items.Recipe;
|
||||
|
||||
public class Gas extends Item {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package satisfactory.items.type;
|
||||
|
||||
import satisfactory.items.Item;
|
||||
import satisfactory.items.Recipe;
|
||||
|
||||
public class Ingot extends Item {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package satisfactory.items.type;
|
||||
|
||||
import satisfactory.items.Item;
|
||||
import satisfactory.items.Recipe;
|
||||
|
||||
public class Ore extends Item {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package satisfactory.items.type;
|
||||
|
||||
import satisfactory.items.Item;
|
||||
import satisfactory.items.Recipe;
|
||||
|
||||
public class Part extends Item {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package satisfactory.items.type;
|
||||
|
||||
import satisfactory.items.Item;
|
||||
import satisfactory.items.Recipe;
|
||||
|
||||
public class Pickup extends Item {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package satisfactory.items.type;
|
||||
|
||||
import satisfactory.items.Recipe;
|
||||
|
||||
public class ProcessedFluid extends Fluid {
|
||||
|
||||
public ProcessedFluid(String name) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package satisfactory.items.type;
|
||||
|
||||
import satisfactory.items.Recipe;
|
||||
|
||||
public class RawFluid extends Fluid {
|
||||
|
||||
public RawFluid(String name) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package satisfactory.items.type;
|
||||
|
||||
import satisfactory.items.Item;
|
||||
import satisfactory.items.Recipe;
|
||||
|
||||
public class Tool extends Item {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue