Compare commits

...

4 Commits

Author SHA1 Message Date
agp8x c42915ecb4 reformat 2023-04-09 11:17:57 +02:00
agp8x 25b4444a73 Merge branch 'master' of git.clkl.de:agp8x/satisfactory 2023-04-09 11:15:24 +02:00
agp8x 32c8a4daf6 add tests 2023-04-09 11:07:37 +02:00
agp8x 892efb18a6 update 1.7 2023-04-09 09:03:34 +02:00
45 changed files with 1000 additions and 251 deletions

2
.gitignore vendored
View File

@ -3,4 +3,6 @@ out/
build/
.gradle/
plots/
lists/
local.properties
data.json

0
lists/.gitkeep Normal file
View File

View File

@ -8,32 +8,30 @@ 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", new Recipe(2, IronOre, 1, Smelter.class));
public static final Item IronIngot = new Ingot("Iron Ingot");
public static final Item CopperOre = new Ore("Copper Ore");
public static final Item CopperIngot = new Ingot("Copper Ingot", new Recipe(2, CopperOre, 1, Smelter.class));
public static final Item CopperIngot = new Ingot("Copper Ingot");
public static final Item Coal = new Ore("Coal");
public static final Item SteelIngot = new Ingot("Steel Ingot");
public static final Item CateriumOre = new Ore("Caterium Ore");
public static final Item CateriumIngot = new Ingot("Caterium Ingot", new Recipe(4, CateriumOre, 3, Smelter.class));
public static final Item CateriumIngot = new Ingot("Caterium Ingot");
public static final Item IronPlate = new Part("Iron Plate");
public static final Item IronRod = new Part("Iron Rod", new Recipe(4, IronIngot, 1, Constructor.class));
public static final Item IronRod = new Part("Iron Rod");
public static final Item Screw = new Part("Screw");
public static final Item ReinforcedIronPlate = new Part("Reinforced Iron Plate");
public static final Item ModularFrame = new Part("Modular Frame");
public static final Item SteelBeam = new Part("Steel Beam", new Recipe(4, SteelIngot, 4, Constructor.class));
public static final Item SteelBeam = new Part("Steel Beam");
public static final Item SteelPipe = new Part("Steel Pipe");
public static final Item Limestone = new Ore("Limestone");
public static final Item Concrete = new Part("Concrete", new Recipe(4, Limestone, 3, Constructor.class));
public static final Item Concrete = new Part("Concrete");
public static final Item EncasedIndustrialBeam = new Part("Encased Industrial Beam");
public static final Item HeavyModularFrame = new Part("Heavy Modular Frame");
public static final Item CopperSheet = new Part("Copper Sheet", new Recipe(6, CopperIngot, 2, Constructor.class));
public static final Item CopperSheet = new Part("Copper Sheet");
public static final Item Wire = new Part("Wire");
public static final Item Cable = new Part("Cable", new Recipe(2, Wire, 2, Constructor.class));
public static final Item Cable = new Part("Cable");
public static final Item Quickwire = new Part("Quickwire");
public static final Item CircuitBoard = new Part("Circuit Board");
public static final Item AILimiter = new Part("A.I. Limiter");
@ -43,8 +41,11 @@ public class Database {
public static final Item Mycelia = new Pickup("Mycelia");
public static final Item Leaves = new Pickup("Leaves");
public static final Item Wood = new Pickup("Wood");
public static final Item AlienCarapace = new Pickup("Alien Carapace");
public static final Item AlienOrgans = new Pickup("Alien Organs");
public static final Item AlienProtein = new Pickup("Alien Protein");
public static final Item HogRemains = new Pickup("Hog Remains");
public static final Item PlasmaSpitterRemains = new Pickup("Plasma Spitter Remains");
public static final Item StingerRemains = new Pickup("Stinger Remains");
public static final Item HatcherRemains = new Pickup("Hatcher Remains");
public static final Item Fabric = new Part("Fabric");
public static final Item Rotor = new Part("Rotor");
public static final Item Stator = new Part("Stator");
@ -55,12 +56,12 @@ public class Database {
public static final Item PowerShard = new Pickup("PowerShard");
public static final Item Sulfur = new Ore("Sulfur");
public static final Item BlackPowder = new Part("Black powder");
public static final Item SpikedRebar = new Part("Spiked Rebar", new Recipe(4, IronRod, 1, Constructor.class));
public static final Item IronRebar = new Part("Iron Rebar");
public static final Item FlowerPetals = new Pickup("Flower Petals");
public static final Item ColorCatridge = new Part("Color Catridge");
public static final Item Beacon = new Tool("Beacon");
public static final Item Rubber = new Part("Rubber");
public static final Item RifleCatridge = new Part("Rifle Catridge");
public static final Item RifleAmmo = new Part("Rifle Ammo");
public static final Item GasFilter = new Tool("Gas Filter");
public static final Item Plastic = new Part("Plastic");
public static final Item Computer = new Part("Computer");
@ -77,6 +78,7 @@ public class Database {
public static final Item HeavyOilResidue = new ProcessedFluid("Heavy Oil Residue");
public static final Item Fuel = new ProcessedFluid("Fuel");
public static final Item LiquidBiofuel = new ProcessedFluid("Liquid Biofuel");
public static final Item PackagedLiquidBiofuel = new Part("Packaged Liquid Biofuel");
public static final Item PetroleumCoke = new Part("Petroleum Coke");
public static final Item PolymerResin = new Part("Polymer Resin");
// TODO: verify below!
@ -91,30 +93,33 @@ 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");
public static final Item PackagedTurboFuel = new Part("Packaged Turbofuel");
public static final Item CompactedCoal = new Part("Compated Coal");
public static final Item RebarGun = new Tool("Rebar Gun");
public static final Item Rifle = new Tool("Rifle");
public static final Item StunRebar = new Part("Stun Rebar");
public static final Item ExplosiveRebar = new Part("Explosive Rebar");
public static final Item SmokelessPowder = new Part("Smokeless Powder");
public static final Item HomingRifleAmmo = new Part("Homing Rifle Ammo");
public static final Item GasNobelisk = new Part("Gas Nobelisk");
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 {
{
@ -123,10 +128,12 @@ public class Database {
Set<Item> ores = new HashSet<>(Arrays.asList(IronOre, Coal, Limestone, CopperOre, CateriumOre, Sulfur, Uranium));
ores.addAll(Arrays.asList(Bauxite, RawQuartz));// TODO: rly?
for (Item ore : ores) {
Recipe mk1 = new Recipe(1, "Miner MK 1", false, Miner.class);
Recipe mk1 = new Recipe(1, "Miner Mk1", false, MinerMk1.class);
ore.add(mk1, 1);
Recipe mk2 = new Recipe(1, "Miner MK2", false, Miner.class);
Recipe mk2 = new Recipe(1, "Miner Mk2", false, MinerMk2.class);
ore.add(mk2, 2);
//Recipe mk3 = new Recipe(1, "Miner Mk3", false, MinerMk3.class);
//ore.add(mk3, 3);
ore.setPreference(mk2);
}
@ -142,6 +149,23 @@ public class Database {
// gases
NitrogenGas.add(new Recipe(1, "pressure thingy", false, ResourceWellExtractor.class));
}
{
// Iron Ingot
IronIngot.add(new Recipe(2, IronOre, 1, Smelter.class));
Recipe alt = new Recipe(12, Refinery.class);
alt.addInput(IronOre, 7);
alt.addInput(Water, 4);
alt.addOutput(IronIngot, 13);
IronIngot.add(alt);
}
{
// Copper Ingot
CopperIngot.add(new Recipe(2, CopperOre, 1, Smelter.class));
}
{
// Caterium Ingot
CateriumIngot.add(new Recipe(4, CateriumOre, 3, Smelter.class));
}
{
// Steel Ingot
Recipe recipe = new Recipe(4, Foundry.class);
@ -149,6 +173,10 @@ public class Database {
recipe.addInput(Coal, 3);
SteelIngot.add(recipe, 3);
}
{
// Concrete
Concrete.add(new Recipe(4, Limestone, 3, Constructor.class));
}
{
// Iron Plate
Recipe recipe = new Recipe(6, IronIngot, 3, Constructor.class);
@ -157,18 +185,27 @@ public class Database {
steelCoated.addInput(SteelIngot, 3);
steelCoated.addInput(Plastic, 2);
IronPlate.add(steelCoated, 18);
IronPlate.setPreference(recipe);
}
{
// Iron Rod
IronRod.add(new Recipe(4, IronIngot, 1, Constructor.class));
}
{
// Screw
Screw.add(new Recipe(6, IronRod, 1, Constructor.class), 4);
}
{
// Steel Beam
SteelBeam.add(new Recipe(4, SteelIngot, 4, Constructor.class));
}
{
// Reinforced Iron Plate
Recipe recipe = new Recipe(12, Assembler.class);
recipe.addInput(IronPlate, 6);
recipe.addInput(Screw, 12);
ReinforcedIronPlate.add(recipe);
Recipe bolted = new Recipe(12, "Bolted Iron Plate", false, Assembler.class);
Recipe bolted = new Recipe(4, "Bolted Iron Plate", false, Assembler.class);
bolted.addInput(IronPlate, 18);
bolted.addInput(Screw, 50);
ReinforcedIronPlate.add(bolted, 3);
@ -203,11 +240,41 @@ public class Database {
recipe.addInput(EncasedIndustrialBeam, 5);
recipe.addInput(Screw, 100);
HeavyModularFrame.add(recipe);
HeavyModularFrame.setPreference(recipe);
Recipe heavyEncasedFrame = new Recipe(21, Manufacturer.class);
// TODO: duration = 60/2.812
heavyEncasedFrame.addInput(ModularFrame, 8);
heavyEncasedFrame.addInput(EncasedIndustrialBeam, 10);
heavyEncasedFrame.addInput(SteelPipe, 36);
heavyEncasedFrame.addInput(Concrete, 22);
heavyEncasedFrame.addOutput(HeavyModularFrame, 3);
HeavyModularFrame.add(heavyEncasedFrame);
}
{
// Wire
Wire.add(new Recipe(4, CopperIngot, 1, Constructor.class), 2);
}
{
// Cable
Cable.add(new Recipe(2, Wire, 2, Constructor.class));
Recipe quickWireCable = new Recipe(2, Assembler.class);
// TODO 60/27,5
quickWireCable.addInput(Quickwire, 3);
quickWireCable.addInput(Rubber, 2);
quickWireCable.addOutput(Cable, 11);
Cable.add(quickWireCable);
}
{
// Copper Sheet
CopperSheet.add(new Recipe(6, CopperIngot, 2, Constructor.class));
Recipe steamedCopperSheet = new Recipe(2, Refinery.class);
// TODO: duration = 60/22.5
steamedCopperSheet.addInput(CopperIngot, 3);
steamedCopperSheet.addInput(Water, 3);
steamedCopperSheet.addOutput(CopperSheet, 3);
CopperSheet.add(steamedCopperSheet);
}
{
// Quickwire
Quickwire.add(new Recipe(5, CateriumIngot, 1, Constructor.class), 5);
@ -219,6 +286,11 @@ public class Database {
recipe.addInput(Plastic, 4);
CircuitBoard.add(recipe);
// TODO: alternative
Recipe electrodeCircuitBoard = new Recipe(12, Assembler.class);
electrodeCircuitBoard.addInput(Rubber, 6);
electrodeCircuitBoard.addInput(PetroleumCoke, 9);
electrodeCircuitBoard.addOutput(CircuitBoard, 1);
CircuitBoard.add(electrodeCircuitBoard);
}
{
// A.I. Limiter
@ -237,11 +309,17 @@ public class Database {
}
{
// Biomass
Biomass.add(new Recipe(5, Leaves, 10, Constructor.class), 5);
Biomass.add(new Recipe(4, Wood, 4, Constructor.class), 20);
Biomass.add(new Recipe(4, Mycelia, 10, Constructor.class), 10);
Biomass.add(new Recipe(4, AlienCarapace, 1, Constructor.class), 100);
Biomass.add(new Recipe(8, AlienOrgans, 1, Constructor.class), 200);
Biomass.add(new Recipe(5, Leaves, 10, Constructor.class), 5); // TODO CraftBench
Biomass.add(new Recipe(4, Wood, 4, Constructor.class), 20); // TODO CraftBench
Biomass.add(new Recipe(4, Mycelia, 1, Constructor.class), 10); // TODO CraftBench
Biomass.add(new Recipe(4, AlienProtein, 1, Constructor.class), 100); // TODO CraftBench
}
{
// Alien Protein
AlienProtein.add(new Recipe(3, HogRemains, 1, Constructor.class)); // TODO CraftBench
AlienProtein.add(new Recipe(3, PlasmaSpitterRemains, 1, Constructor.class)); // TODO CraftBench
AlienProtein.add(new Recipe(3, StingerRemains, 1, Constructor.class)); // TODO CraftBench
AlienProtein.add(new Recipe(3, HatcherRemains, 1, Constructor.class)); // TODO CraftBench
}
{
// Fabric
@ -249,6 +327,10 @@ public class Database {
recipe.addInput(Mycelia);
recipe.addInput(Biomass, 5);
Fabric.add(recipe);
Recipe alt = new Recipe(2, Refinery.class);
recipe.addInput(PolymerResin, 1);
recipe.addInput(Water, 1);
recipe.addOutput(Fabric, 1);
}
{
// Solid Biofuel
@ -267,6 +349,13 @@ public class Database {
recipe.addInput(SteelPipe, 3);
recipe.addInput(Wire, 8);
Stator.add(recipe);
Stator.setPreference(recipe);
Recipe quickwireStator = new Recipe(8, Assembler.class);
//TODO 60/8
quickwireStator.addInput(SteelPipe, 4);
quickwireStator.addInput(Quickwire, 15);
quickwireStator.addOutput(Stator, 2);
Stator.add(quickwireStator);
}
{
// Motor
@ -290,16 +379,7 @@ public class Database {
}
{
// Color Catridge
ColorCatridge.add(new Recipe(8, FlowerPetals, 5, Constructor.class), 10);
}
{
// Rifle Catridge
Recipe recipe = new Recipe(20, Manufacturer.class);
recipe.addInput(Beacon, 1);
recipe.addInput(SteelPipe, 10);
recipe.addInput(BlackPowder, 10);
recipe.addInput(Rubber, 10);
RifleCatridge.add(recipe, 5);
ColorCatridge.add(new Recipe(6, FlowerPetals, 5, Constructor.class), 10);
}
{
// Gas Filter
@ -371,6 +451,32 @@ public class Database {
recipe.addInput(SteelPipe, 10);
Nobelisk.add(recipe);
}
{
// Gas Nobelisk
Recipe recipe = new Recipe(12, Assembler.class); //TODO EquipmentWorkshop
recipe.addInput(Nobelisk, 1);
recipe.addInput(Biomass, 10);
recipe.addOutput(GasNobelisk, 1);
GasNobelisk.add(recipe);
}
{
// Cluster Nobelisk
Recipe recipe = new Recipe(24, Assembler.class); //TODO EquipmentWorkshop
recipe.addInput(Nobelisk, 3);
recipe.addInput(SmokelessPowder, 4);
recipe.addOutput(ClusterNobelisk, 1);
ClusterNobelisk.add(recipe);
}
{
// NobeliskDetonator
Recipe recipe = new Recipe(80, EquipmentWorkshop.class);
recipe.addInput(ObjectScanner, 1);
recipe.addInput(SteelBeam, 10);
recipe.addInput(Cable, 50);
recipe.addOutput(NobeliskDetonator, 1);
NobeliskDetonator.add(recipe);
}
{
// Smart Plating
Recipe recipe = new Recipe(30, false, Assembler.class);
@ -404,12 +510,32 @@ public class Database {
Fuel.setPreference(recipe);
}
{
PolymerResin.setPreference(PolymerResin.getRecipe());
// Polymer Resin
Recipe polymerResin = new Recipe(1, Refinery.class);
// TODO: duration=60/130
polymerResin.addInput(CrudeOil, 6);
polymerResin.addOutput(PolymerResin, 13);
polymerResin.addOutput(HeavyOilResidue, 2);
PolymerResin.add(polymerResin);
}
{
// Liquid Biofuel
Recipe recipe = new Recipe(4, false, Refinery.class);
recipe.addInput(SolidBiofuel, 6);
recipe.addInput(Water, 3);
LiquidBiofuel.add(recipe, 4);
Recipe unpack = new Recipe(2, Packager.class);
recipe.addInput(PackagedLiquidBiofuel, 2);
recipe.addOutput(LiquidBiofuel, 2);
recipe.addOutput(EmptyCanister, 2);
LiquidBiofuel.add(unpack);
}
{
// Packaged Liquid Biofuel
}
{
// Plastic
@ -563,10 +689,112 @@ public class Database {
recipe.addInput(NitrogenGas, 25);
recipe.addOutput(FusedModularFrame, 1);
}
{
Recipe recipe = new Recipe(40, true, EquipmentWorkshop.class);
recipe.addInput(IronPlate, 2);
recipe.addInput(IronRod, 2);
recipe.addOutput(PortableMiner, 1);
}
{
//Turbofuel
Recipe recipe = new Recipe(3, Refinery.class);
//TODO: 60/18,75
recipe.addInput(Fuel, 6);
recipe.addInput(CompactedCoal, 4);
recipe.addOutput(Turbofuel, 5);
Turbofuel.add(recipe);
Recipe packaged = new Recipe(3, Packager.class);
recipe.addInput(PackagedTurboFuel, 2);
recipe.addOutput(Turbofuel, 2);
recipe.addOutput(EmptyCanister, 2);
Turbofuel.add(packaged);
}
{
// Packaged Turbofuel
Recipe recipe = new Recipe(3, Packager.class);
recipe.addInput(Turbofuel, 2);
recipe.addInput(EmptyCanister, 2);
recipe.addOutput(PackagedTurboFuel, 2);
PackagedTurboFuel.add(recipe);
}
{
// Compacted Coal
Recipe recipe = new Recipe(2, Assembler.class);
//TODO: 60/25
recipe.addInput(Coal, 5);
recipe.addInput(Sulfur, 5);
recipe.addOutput(CompactedCoal, 5);
CompactedCoal.add(recipe);
}
{
// Iron Rebar
IronRebar.add(new Recipe(4, IronRod, 1, Constructor.class));
}
{
// Stun Rebar
Recipe recipe = new Recipe(6, Assembler.class);//TODO , EquipmentWorkshop.class)
recipe.addInput(IronRebar, 1);
recipe.addInput(Quickwire, 5);
recipe.addOutput(StunRebar, 1);
StunRebar.add(recipe);
}
{
// Explosive Rebar
Recipe recipe = new Recipe(12, Manufacturer.class);//TODO , EquipmentWorkshop.class)
recipe.addInput(IronRebar, 1);
recipe.addInput(SmokelessPowder, 2);
recipe.addInput(SteelPipe, 2);
recipe.addOutput(ExplosiveRebar, 1);
ExplosiveRebar.add(recipe);
}
{
// Rebar Gun
Recipe recipe = new Recipe(60, EquipmentWorkshop.class);
recipe.addInput(ReinforcedIronPlate, 6);
recipe.addInput(IronRod, 16);
recipe.addInput(Screw, 100);
recipe.addOutput(RebarGun, 1);
RebarGun.add(recipe);
}
{
// Rifle Ammo
Recipe recipe = new Recipe(12, Assembler.class);//TODO , EquipmentWorkshop.class)
recipe.addInput(CopperSheet, 3);
recipe.addInput(SmokelessPowder, 2);
recipe.addOutput(RifleAmmo, 15);
RifleAmmo.add(recipe);
}
{
// Homing Rifle Ammo
Recipe recipe = new Recipe(12, Assembler.class);//TODO , EquipmentWorkshop.class)
recipe.addInput(RifleAmmo, 20);
recipe.addInput(HighSpeedConnector, 1);
recipe.addOutput(HomingRifleAmmo, 10);
HomingRifleAmmo.add(recipe);
}
{
// Rifle
Recipe recipe = new Recipe(120, EquipmentWorkshop.class);
recipe.addInput(Motor, 2);
recipe.addInput(Rubber, 10);
recipe.addInput(SteelPipe, 25);
recipe.addInput(Screw, 250);
recipe.addOutput(Rifle, 1);
Rifle.add(recipe);
}
{
// Smokeless Powder
Recipe recipe = new Recipe(6, Refinery.class);
recipe.addInput(BlackPowder, 2);
recipe.addInput(HeavyOilResidue, 1);
recipe.addOutput(SmokelessPowder, 2);
SmokelessPowder.add(recipe);
}
}
public static void add(Item i) {
public static Item add(Item i) {
items.add(i);
return i;
}
public static Collection<Item> getItems() {

View File

@ -15,13 +15,16 @@ import satisfactory.items.Production;
import satisfactory.items.Recipe;
import satisfactory.items.SumResult;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import static satisfactory.Utils.PLOTS;
import static satisfactory.Utils.plot2;
import static satisfactory.Utils.*;
public class Test {
public static void main(String[] args) throws JsonProcessingException {
@ -120,15 +123,43 @@ public class Test {
planFor(Database.UraniumFuelRod, 1, "fuelrod");
planFor(Database.FusedModularFrame, 100, "fusedFrame");
planFor(Database.SteelIngot, 81.75, "steelIngot");
planFor(Database.SteelIngot, 100, "steelIngot");
Set<String> unlocks = unlocks();
planFor(
"phase2",
new Production(Database.SmartPlating, 5),
new Production(Database.VersatileFrameWork, 5),
new Production(Database.AutomatedWiring, 1)
);
planFor(
"phase3",
new Production(Database.VersatileFrameWork, 5),
new Production(Database.ModularEngine, 1),
new Production(Database.AdaptiveControlUnit, 1)
);
planFor("allIron",
new Production(Database.IronRod, 1),
new Production(Database.IronPlate, 1));
planFor("p3_acu", new Production(Database.AdaptiveControlUnit, 1));
planFor("p3_me", new Production(Database.ModularEngine, 1));
planFor("p3_vf", new Production(Database.VersatileFrameWork, 1));
planFor("screw", new Production(Database.ReinforcedIronPlate, 1));
}
private static void planFor(Item item, double amount, String name) {
private static void planFor(Item item, int amount, String name) {
SumResult plan = SumResult.sum(new Production(item, amount));
plot2(plan.getProduction(), name);
javaPlot(name);
}
private static void planFor(String name, Production... prods) {
SumResult plan = SumResult.sum(prods);
plot2(plan.getProduction(), name);
javaPlot(name);
list(plan, name);
}
private static void plot(Item target, String name, int amount) {
Graph<Item, DefaultWeightedEdge> screws = target.hierarchy();
DOTExporter<Item, DefaultWeightedEdge> de = new DOTExporter<>(Utils::dotID);
@ -139,7 +170,9 @@ public class Test {
});
de.exportGraph(screws, new File(PLOTS + name + ".dot"));
System.out.println(name);
Item.production(screws).forEach((item, rate) -> System.out.println("\t" + item.getName() + "\t" + rate));
Item.production(screws).forEach((item, rate) -> {
System.out.println("\t" + item.getName() + "\t" + rate);
});
}
private static void javaPlot(String name) {
@ -150,4 +183,37 @@ public class Test {
e.printStackTrace();
}
}
private static String name2(String name3) {
return Arrays.stream(Database.class.getFields()).filter(field -> {
try {
return field.getType().equals(Item.class) && ((Item) field.get(null)).getName().equals(name3);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}).findFirst().get().getName();
}
private static void list(SumResult plan, String name) {
try (BufferedWriter bw = new BufferedWriter(new FileWriter(LISTS + name + ".txt"))) {
String list = plan.getMap().entrySet().stream().map(item -> item.getKey().getName() + ": " + item.getValue()).reduce("", (s, s2) -> s + "\n" + s2);
bw.write(list);
} catch (IOException e) {
throw new RuntimeException(e);
}
// 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);
bw.write(list);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static Set<String> unlocks(String... unlock) {
return Set.of(unlock);
}
}

View File

@ -18,11 +18,11 @@ import satisfactory.items.ProductionEdge;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
public class Utils {
public static final String PLOTS = "plots/";
public static final String LISTS = "lists/";
public static Map<Item, Integer> getRawOnly(Map<Item, Integer> totals) {
Map<Item, Integer> raws = new HashMap<>();

View File

@ -1,4 +1,15 @@
package satisfactory.buildings;
import satisfactory.items.Item;
import java.util.HashMap;
import java.util.Map;
public abstract class Building {
protected Map<Item, Integer> cost;
protected Integer power;
public Building() {
cost = new HashMap<>();
}
}

View File

@ -0,0 +1,13 @@
package satisfactory.buildings.power;
import satisfactory.Database;
public class BiomassBurner extends PowerGenerationBuilding {
public BiomassBurner() {
power = 30;
cost.put(Database.IronPlate, 15);
cost.put(Database.IronRod, 15);
cost.put(Database.Wire, 25);
consumes.put(Database.Coal, 15);
}
}

View File

@ -0,0 +1,14 @@
package satisfactory.buildings.power;
import satisfactory.Database;
public class CoalGenerator extends PowerGenerationBuilding {
public CoalGenerator() {
power = 75;
cost.put(Database.ReinforcedIronPlate, 20);
cost.put(Database.Rotor, 10);
cost.put(Database.Cable, 30);
consumes.put(Database.Coal, 15);
consumes.put(Database.PetroleumCoke, 25);
}
}

View File

@ -0,0 +1,15 @@
package satisfactory.buildings.power;
import satisfactory.Database;
public class FuelGenerator extends PowerGenerationBuilding {
public FuelGenerator() {
power = 150;
cost.put(Database.Computer, 5);
cost.put(Database.HeavyModularFrame, 10);
cost.put(Database.Motor, 15);
cost.put(Database.Rubber, 50);
cost.put(Database.Quickwire, 50);
consumes.put(Database.Fuel, 12);
}
}

View File

@ -0,0 +1,14 @@
package satisfactory.buildings.power;
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);
}
}

View File

@ -0,0 +1,15 @@
package satisfactory.buildings.power;
import satisfactory.buildings.Building;
import satisfactory.items.Item;
import java.util.HashMap;
import java.util.Map;
public abstract class PowerGenerationBuilding extends Building {
protected Map<Item, Integer> consumes;
public PowerGenerationBuilding() {
consumes = new HashMap<>();
}
}

View File

@ -1,6 +1,13 @@
package satisfactory.buildings.production;
import satisfactory.Database;
import satisfactory.buildings.Building;
public class Assembler extends Building {
public Assembler() {
power = 15;
cost.put(Database.ReinforcedIronPlate, 8);
cost.put(Database.Rotor, 4);
cost.put(Database.Cable, 10);
}
}

View File

@ -3,4 +3,9 @@ package satisfactory.buildings.production;
import satisfactory.buildings.Building;
public class Blender extends Building {
public Blender() {
power = -9999;
cost.put(null, null);
// TODO
}
}

View File

@ -1,6 +1,12 @@
package satisfactory.buildings.production;
import satisfactory.Database;
import satisfactory.buildings.Building;
public class Constructor extends Building {
public Constructor() {
power = 4;
cost.put(Database.ReinforcedIronPlate, 2);
cost.put(Database.Cable, 8);
}
}

View File

@ -1,6 +1,12 @@
package satisfactory.buildings.production;
import satisfactory.Database;
import satisfactory.buildings.Building;
public class CraftBench extends Building {
public CraftBench() {
power = null;
cost.put(Database.IronPlate, 3);
cost.put(Database.IronRod, 3);
}
}

View File

@ -1,6 +1,12 @@
package satisfactory.buildings.production;
import satisfactory.Database;
import satisfactory.buildings.Building;
public class EquipmentWorkshop extends Building {
public EquipmentWorkshop() {
power = null;
cost.put(Database.IronPlate, 6);
cost.put(Database.IronRod, 4);
}
}

View File

@ -1,6 +1,13 @@
package satisfactory.buildings.production;
import satisfactory.Database;
import satisfactory.buildings.Building;
public class Foundry extends Building {
public Foundry() {
power = 16;
cost.put(Database.ModularFrame, 10);
cost.put(Database.Rotor, 10);
cost.put(Database.Concrete, 20);
}
}

View File

@ -1,6 +1,14 @@
package satisfactory.buildings.production;
import satisfactory.Database;
import satisfactory.buildings.Building;
public class Manufacturer extends Building {
public Manufacturer() {
power = 55;
cost.put(Database.Motor, 5);
cost.put(Database.HeavyModularFrame, 10);
cost.put(Database.Cable, 50);
cost.put(Database.Plastic, 50);
}
}

View File

@ -1,6 +0,0 @@
package satisfactory.buildings.production;
import satisfactory.buildings.Building;
public class Miner extends Building {
}

View File

@ -0,0 +1,13 @@
package satisfactory.buildings.production;
import satisfactory.Database;
import satisfactory.buildings.Building;
public class MinerMk1 extends Building {
public MinerMk1() {
power = 5;
cost.put(Database.PortableMiner, 1);
cost.put(Database.IronPlate, 10);
cost.put(Database.Concrete, 10);
}
}

View File

@ -0,0 +1,13 @@
package satisfactory.buildings.production;
import satisfactory.Database;
public class MinerMk2 extends MinerMk1 {
public MinerMk2() {
power = 12;
cost.put(Database.PortableMiner, 2);
cost.put(Database.EncasedIndustrialBeam, 10);
cost.put(Database.SteelPipe, 20);
cost.put(Database.ModularFrame, 10);
}
}

View File

@ -0,0 +1,14 @@
package satisfactory.buildings.production;
import satisfactory.Database;
public class MinerMk3 extends MinerMk1 {
public MinerMk3() {
// TODO: real values!
power = 12;
cost.put(Database.PortableMiner, 2);
cost.put(Database.EncasedIndustrialBeam, 10);
cost.put(Database.SteelPipe, 20);
cost.put(Database.ModularFrame, 10);
}
}

View File

@ -1,6 +1,13 @@
package satisfactory.buildings.production;
import satisfactory.Database;
import satisfactory.buildings.Building;
public class OilExtractor extends Building {
public OilExtractor() {
power = 40;
cost.put(Database.Motor, 15);
cost.put(Database.EncasedIndustrialBeam, 20);
cost.put(Database.Cable, 60);
}
}

View File

@ -1,6 +1,13 @@
package satisfactory.buildings.production;
import satisfactory.Database;
import satisfactory.buildings.Building;
public class Packager extends Building {
public Packager() {
power = 10;
cost.put(Database.SteelBeam, 20);
cost.put(Database.Rubber, 10);
cost.put(Database.Plastic, 10);
}
}

View File

@ -1,6 +1,14 @@
package satisfactory.buildings.production;
import satisfactory.Database;
import satisfactory.buildings.Building;
public class Refinery extends Building {
public Refinery() {
power = 30;
cost.put(Database.Motor, 10);
cost.put(Database.EncasedIndustrialBeam, 10);
cost.put(Database.SteelPipe, 30);
cost.put(Database.CopperSheet, 20);
}
}

View File

@ -3,4 +3,9 @@ package satisfactory.buildings.production;
import satisfactory.buildings.Building;
public class ResourceWellExtractor extends Building {
public ResourceWellExtractor() {
power = -9999;
cost.put(null, null);
// TODO
}
}

View File

@ -1,6 +1,12 @@
package satisfactory.buildings.production;
import satisfactory.Database;
import satisfactory.buildings.Building;
public class Smelter extends Building {
public Smelter() {
power = 4;
cost.put(Database.IronRod, 5);
cost.put(Database.Wire, 8);
}
}

View File

@ -1,6 +1,13 @@
package satisfactory.buildings.production;
import satisfactory.Database;
import satisfactory.buildings.Building;
public class WaterExtractor extends Building {
public WaterExtractor() {
power = 20;
cost.put(Database.CopperSheet, 20);
cost.put(Database.ReinforcedIronPlate, 10);
cost.put(Database.Rotor, 10);
}
}

View File

@ -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;
@ -23,15 +26,23 @@ public abstract class Item {
}
}
public Item(String name, Recipe... recipes) {
this(name, new HashSet<>(Arrays.asList(recipes)));
}
public Item(String name) {
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);
}
add(recipe, 1);
}
@ -85,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);
@ -111,4 +109,8 @@ public abstract class Item {
return preference;
}
public void setPreference(Recipe preference) {
this.preference = preference;
}
}

View File

@ -14,14 +14,12 @@ 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) {
inputs = new HashMap<>();
outputs = new HashMap<>();
this.duration = duration;
this(duration, new HashMap<>(), new HashMap<>(), building);
}
public Recipe(int duration, boolean isHandCraftable, Class<? extends Building> building) {

View File

@ -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);
}
}

View File

@ -1,14 +1,9 @@
package satisfactory.items.type;
import satisfactory.items.Item;
import satisfactory.items.Recipe;
public abstract class Fluid extends Item {
public Fluid(String name, Recipe... recipes) {
super(name, recipes);
}
public Fluid(String name) {
super(name);
}

View File

@ -1,15 +1,9 @@
package satisfactory.items.type;
import satisfactory.items.Item;
import satisfactory.items.Recipe;
public class Gas extends Item {
public Gas(String name, Recipe... recipes) {
super(name, recipes);
setIsRaw();
}
public Gas(String name) {
super(name);
setIsRaw();

View File

@ -1,14 +1,9 @@
package satisfactory.items.type;
import satisfactory.items.Item;
import satisfactory.items.Recipe;
public class Ingot extends Item {
public Ingot(String name, Recipe... recipes) {
super(name, recipes);
}
public Ingot(String name) {
super(name);
}

View File

@ -1,15 +1,9 @@
package satisfactory.items.type;
import satisfactory.items.Item;
import satisfactory.items.Recipe;
public class Ore extends Item {
public Ore(String name, Recipe... recipes) {
super(name, recipes);
setIsRaw();
}
public Ore(String name) {
super(name);
setIsRaw();

View File

@ -1,14 +1,9 @@
package satisfactory.items.type;
import satisfactory.items.Item;
import satisfactory.items.Recipe;
public class Part extends Item {
public Part(String name, Recipe... recipes) {
super(name, recipes);
}
public Part(String name) {
super(name);
}

View File

@ -1,15 +1,9 @@
package satisfactory.items.type;
import satisfactory.items.Item;
import satisfactory.items.Recipe;
public class Pickup extends Item {
public Pickup(String name, Recipe... recipes) {
super(name, recipes);
setIsRaw();
}
public Pickup(String name) {
super(name);
setIsRaw();

View File

@ -1,13 +1,7 @@
package satisfactory.items.type;
import satisfactory.items.Recipe;
public class ProcessedFluid extends Fluid {
public ProcessedFluid(String name, Recipe... recipes) {
super(name, recipes);
}
public ProcessedFluid(String name) {
super(name);
}

View File

@ -1,14 +1,7 @@
package satisfactory.items.type;
import satisfactory.items.Recipe;
public class RawFluid extends Fluid {
public RawFluid(String name, Recipe... recipes) {
super(name, recipes);
setIsRaw();
}
public RawFluid(String name) {
super(name);
setIsRaw();

View File

@ -1,14 +1,9 @@
package satisfactory.items.type;
import satisfactory.items.Item;
import satisfactory.items.Recipe;
public class Tool extends Item {
public Tool(String name, Recipe... recipes) {
super(name, recipes);
}
public Tool(String name) {
super(name);
}

View File

@ -0,0 +1,12 @@
package satisfactory;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class PlanTest {
@Test
void twoItems() {
fail();
}
}

View File

@ -1,40 +1,39 @@
package satisfactory.items;
import org.jgrapht.Graph;
import org.junit.jupiter.api.Test;
import satisfactory.Database;
import satisfactory.Utils;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.*;
import static satisfactory.items.TestHelper.assertMap;
import static satisfactory.items.TestHelper.test;
class ItemTest {
@Test
void productionScrews() {
Collection<Ref> ref = Arrays.asList(
new Ref(Database.Screw, 100.0),
new Ref(Database.IronRod, 25.0),
new Ref(Database.IronIngot, 25.0),
new Ref(Database.IronOre, 25.0)
);
SumResult sum = SumResult.sum(new Production(Database.Screw, 100.0));
compareProductions(sum, ref);
test(Database.Screw);
}
@Test
void productionScrews2() {
/*Map<Item, Double> production = Database.Screw.getRecipe().sum(Database.Screw, 100);
assertEquals(100, production.get(Database.Screw), "Screws (output)");
assertEquals(25, production.get(Database.IronRod), "IronRod");
assertEquals(25, production.get(Database.IronIngot), "IronIngot");
assertEquals(25, production.get(Database.IronOre), "IronOre");
*/
fail("TODO: migrate");
}
@Test
void productionReinforcedIronPlates() {
Collection<Ref> ref = Arrays.asList(
new Ref(Database.ReinforcedIronPlate, 100.0, "output"),
new Ref(Database.Screw, 1200.0),
new Ref(Database.IronRod, 300.0),
new Ref(Database.IronIngot, 1200.0),
new Ref(Database.IronOre, 1200.0),
new Ref(Database.IronPlate, 600.0)
);
SumResult sum = SumResult.sum(new Production(Database.ReinforcedIronPlate, 100.0));
compareProductions(sum, ref);
test(Database.ReinforcedIronPlate);
}
@Test
@ -43,87 +42,4 @@ class ItemTest {
assertEquals(40, productionRate);
}
@Test
void testPhase3_ME_ACU() {
// references
Collection<Ref> ref = Arrays.asList(
new Ref(Database.CircuitBoard, 15.0),
new Ref(Database.Computer, 1.0),
new Ref(Database.Limestone, 75.0),
new Ref(Database.Concrete, 25.0),
new Ref(Database.SteelBeam, 20.0),
new Ref(Database.EncasedIndustrialBeam, 5.0),
new Ref(Database.ModularFrame, 5.0),
new Ref(Database.HeavyModularFrame, 1.0),
new Ref(Database.Plastic, 78.0),
new Ref(Database.CopperSheet, 30.0),
new Ref(Database.Coal, 226.25),
new Ref(Database.Cable, 159.0),
new Ref(Database.CopperOre, 329.0),
new Ref(Database.AutomatedWiring, 7.5),
new Ref(Database.AdaptiveControlUnit, 1.0),
new Ref(Database.CrudeOil, 229.5),
new Ref(Database.ReinforcedIronPlate, 17.5),
new Ref(Database.CopperIngot, 329.0),
new Ref(Database.SteelIngot, 226.25),
new Ref(Database.IronPlate, 105.0),
new Ref(Database.SmartPlating, 10.0),
//new Ref(Database.HeavyOilResidue, 114.0), // TODO: implement calculation
new Ref(Database.Rubber, 75.0),
new Ref(Database.Wire, 538.0),
new Ref(Database.SteelPipe, 97.5),
new Ref(Database.Stator, 27.5),
new Ref(Database.Screw, 1112.0),
new Ref(Database.IronOre, 841.75),
new Ref(Database.IronIngot, 615.5),
new Ref(Database.IronRod, 458.0),
new Ref(Database.Rotor, 30.0),
new Ref(Database.Motor, 10.0),
new Ref(Database.ModularEngine, 5.0)
);
// calculate
SumResult sum = SumResult.sum(new Production(Database.ModularEngine, 5), new Production(Database.AdaptiveControlUnit, 1));
// assert
compareProductions(sum, ref);
fail("Something heavy oil residue");
}
@Test
void uraniumFuelRodWithSteelIngotParents() {
Collection<Ref> refs = Arrays.asList(
new Ref(Database.SteelIngot, 81.75),
new Ref(Database.IronOre, 81.75),
new Ref(Database.Coal, 81.75)
);
SumResult sums = SumResult.sum(new Production(Database.UraniumFuelRod, 1.0));
compareProductions(sums, refs);
}
private void compareProductions(SumResult sum, Collection<Ref> references) {
Map<Item, Double> inputs = sum.getMap();
references.forEach(ref -> {
assertTrue(inputs.containsKey(ref.item), ref.note);
assertEquals(ref.amount, inputs.get(ref.item), ref.note);
});
}
}
class Ref {
Item item;
double amount;
String note;
public Ref(Item item, double amount, String note) {
this.item = item;
this.amount = amount;
this.note = note;
}
public Ref(Item item, double amount) {
this.item = item;
this.amount = amount;
note = item.getName();
}
}

View File

@ -0,0 +1,229 @@
package satisfactory.items;
import org.junit.jupiter.api.Test;
import satisfactory.Database;
import java.util.*;
import static org.junit.jupiter.api.Assertions.*;
import static satisfactory.items.TestHelper.assertMap;
import static satisfactory.items.TestHelper.test;
import static satisfactory.items.ValidatedValues.*;
class Phase3Test {
@Test
void testPhase3_ACU() {
Item item = Database.AdaptiveControlUnit;
test(item);
}
@Test
void testPhase3_ME() {
Item item = Database.ModularEngine;
test(item);
}
@Test
void testPhase3_VF() {
Item item = Database.VersatileFrameWork;
test(item);
}
private Double check(
Double test) {
if (test == null) {
return 0.0;
}
return test;
}
@Test
void testPhase3_ME_ACU_VF() {
// references
Map<Item, Double> ref = merge(
ValidatedValues.get(Database.ModularEngine),
ValidatedValues.get(Database.AdaptiveControlUnit),
ValidatedValues.get(Database.VersatileFrameWork));
ref.forEach((item, aDouble) -> System.out.println(aDouble + "\t" + item.getName()));
// calculate
Map<Item, Double> calculations = SumResult.sum(
new Production(Database.ModularEngine, 1),
new Production(Database.AdaptiveControlUnit, 1),
new Production(Database.VersatileFrameWork, 1)
).getMap();
// assert
assertMap(ref, calculations);
}
@Test
void testMerge() {
Map<String, Double> a = new HashMap<>();
Map<String, Double> b = new HashMap<>();
Map<String, Double> c = new HashMap<>();
Map<String, Double> e = new HashMap<>();
{
a.put("a", 1.0);
b.put("a", 2.0);
c.put("a", 4.0);
e.put("a", 7.);
}
{
a.put("b", 1.0);
b.put("b", 2.0);
//c.put("b", 4.0);
e.put("b", 3.);
}
Map<String, Double> m = merge(a,b,c);
e.forEach((s, aDouble) -> {
assertEquals(aDouble, m.get(s));
});
}
private <K> Map<K, Double> merge(Map<K, Double>... single_refs) {
Map<K, Double> ref = new HashMap<>();
for (Map<K, Double> singleRef : single_refs) {
singleRef.forEach((singleItem, singleValue) -> ref.compute(singleItem, (refItem, refValue) -> singleValue + check(refValue)));
}
return ref;
}
@Test
void testPhase3_ME_ACU() {
// references
Map<Item, Double> ref = new HashMap<>();
ref.put(Database.CircuitBoard, 15.0);
ref.put(Database.Computer, 1.0);
ref.put(Database.Limestone, 75.0);
ref.put(Database.Concrete, 25.0);
ref.put(Database.SteelBeam, 20.0);
ref.put(Database.EncasedIndustrialBeam, 5.0);
ref.put(Database.ModularFrame, 5.0);
ref.put(Database.HeavyModularFrame, 1.0);
ref.put(Database.Plastic, 78.0);
ref.put(Database.CopperSheet, 30.0);
ref.put(Database.Coal, 226.25);
ref.put(Database.Cable, 159.0);
ref.put(Database.CopperOre, 329.0);
ref.put(Database.AutomatedWiring, 7.5);
ref.put(Database.AdaptiveControlUnit, 1.0);
ref.put(Database.CrudeOil, 229.5);
ref.put(Database.ReinforcedIronPlate, 17.5);
ref.put(Database.CopperIngot, 329.0);
ref.put(Database.SteelIngot, 226.25);
ref.put(Database.IronPlate, 105.0);
ref.put(Database.SmartPlating, 10.0);
//ref.put(Database.HeavyOilResidue, 114.0); // TODO: implement calculation
ref.put(Database.Rubber, 75.0);
ref.put(Database.Wire, 538.0);
ref.put(Database.SteelPipe, 97.5);
ref.put(Database.Stator, 27.5);
ref.put(Database.Screw, 1112.0);
ref.put(Database.IronOre, 841.75);
ref.put(Database.IronIngot, 615.5);
ref.put(Database.IronRod, 458.0);
ref.put(Database.Rotor, 30.0);
ref.put(Database.Motor, 10.0);
ref.put(Database.ModularEngine, 5.0);
// calculate
Map<Item, Double> calculations = SumResult.sum(new Production(Database.ModularEngine, 1), new Production(Database.AdaptiveControlUnit, 1)).getMap();
// assert
assertMap(ref, calculations);
}
@Test
void testPhase3_ACU_VF() {
// references
Map<Item, Double> ref = new HashMap<>();
ref.put(Database.CircuitBoard, 15.0);
ref.put(Database.Computer, 1.0);
ref.put(Database.Limestone, 75.0);
ref.put(Database.Concrete, 25.0);
ref.put(Database.SteelBeam, 20.0);
ref.put(Database.EncasedIndustrialBeam, 5.0);
ref.put(Database.ModularFrame, 5.0);
ref.put(Database.HeavyModularFrame, 1.0);
ref.put(Database.Plastic, 78.0);
ref.put(Database.CopperSheet, 30.0);
ref.put(Database.Coal, 226.25);
ref.put(Database.Cable, 159.0);
ref.put(Database.CopperOre, 329.0);
ref.put(Database.AutomatedWiring, 7.5);
ref.put(Database.AdaptiveControlUnit, 1.0);
ref.put(Database.CrudeOil, 229.5);
ref.put(Database.ReinforcedIronPlate, 17.5);
ref.put(Database.CopperIngot, 329.0);
ref.put(Database.SteelIngot, 226.25);
ref.put(Database.IronPlate, 105.0);
ref.put(Database.SmartPlating, 10.0);
//ref.put(Database.HeavyOilResidue, 114.0); // TODO: implement calculation
ref.put(Database.Rubber, 75.0);
ref.put(Database.Wire, 538.0);
ref.put(Database.SteelPipe, 97.5);
ref.put(Database.Stator, 27.5);
ref.put(Database.Screw, 1112.0);
ref.put(Database.IronOre, 841.75);
ref.put(Database.IronIngot, 615.5);
ref.put(Database.IronRod, 458.0);
ref.put(Database.Rotor, 30.0);
ref.put(Database.Motor, 10.0);
ref.put(Database.ModularEngine, 5.0);
// calculate
Map<Item, Double> calculations = SumResult.sum(new Production(Database.AdaptiveControlUnit, 1), new Production(Database.VersatileFrameWork, 1)).getMap();
// assert
assertMap(ref, calculations);
}
@Test
void testPhase3_ME_VF() {
// references
Map<Item, Double> ref = new HashMap<>();
ref.put(Database.CircuitBoard, 15.0);
ref.put(Database.Computer, 1.0);
ref.put(Database.Limestone, 75.0);
ref.put(Database.Concrete, 25.0);
ref.put(Database.SteelBeam, 20.0);
ref.put(Database.EncasedIndustrialBeam, 5.0);
ref.put(Database.ModularFrame, 5.0);
ref.put(Database.HeavyModularFrame, 1.0);
ref.put(Database.Plastic, 78.0);
ref.put(Database.CopperSheet, 30.0);
ref.put(Database.Coal, 226.25);
ref.put(Database.Cable, 159.0);
ref.put(Database.CopperOre, 329.0);
ref.put(Database.AutomatedWiring, 7.5);
ref.put(Database.AdaptiveControlUnit, 1.0);
ref.put(Database.CrudeOil, 229.5);
ref.put(Database.ReinforcedIronPlate, 17.5);
ref.put(Database.CopperIngot, 329.0);
ref.put(Database.SteelIngot, 226.25);
ref.put(Database.IronPlate, 105.0);
ref.put(Database.SmartPlating, 10.0);
//ref.put(Database.HeavyOilResidue, 114.0); // TODO: implement calculation
ref.put(Database.Rubber, 75.0);
ref.put(Database.Wire, 538.0);
ref.put(Database.SteelPipe, 97.5);
ref.put(Database.Stator, 27.5);
ref.put(Database.Screw, 1112.0);
ref.put(Database.IronOre, 841.75);
ref.put(Database.IronIngot, 615.5);
ref.put(Database.IronRod, 458.0);
ref.put(Database.Rotor, 30.0);
ref.put(Database.Motor, 10.0);
ref.put(Database.ModularEngine, 5.0);
// calculate
Map<Item, Double> calculations = SumResult.sum(new Production(Database.ModularEngine, 1), new Production(Database.VersatileFrameWork, 1)).getMap();
// assert
assertMap(ref, calculations);
}
}

View File

@ -0,0 +1,27 @@
package satisfactory.items;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class TestHelper {
public static void assertMap(Map<Item, Double> ref, Map<Item, Double> calculations) {
// assert
ref.forEach((item, amount) -> {
assertTrue(calculations.containsKey(item), "exists? " + item.getName());
assertEquals(amount, calculations.get(item), 0.01, item.getName());
});
}
public static void test(Item item) {
Map<Item, Double> ref = ValidatedValues.get(item);
// calculate
Map<Item, Double> calculations = SumResult.sum(new Production(item, 1)).getMap();
assertMap(ref, calculations);
}
}

View File

@ -0,0 +1,120 @@
package satisfactory.items;
import satisfactory.Database;
import java.util.HashMap;
import java.util.Map;
public class ValidatedValues {
private static Map<Item, Map<Item, Double>> values = new HashMap<>();
static {
values.put(Database.AdaptiveControlUnit, ACU());
values.put(Database.ModularEngine, ME());
values.put(Database.VersatileFrameWork, VF());
{
Item item = Database.Screw;
Map<Item, Double> ref = new HashMap<>();
ref.put(Database.IronOre, 0.25);
ref.put(Database.IronIngot, 0.25);
ref.put(Database.IronRod, 0.25);
ref.put(item, 1.);
values.put(item, ref);
}
{
Item item = Database.ReinforcedIronPlate;
Map<Item, Double> ref = new HashMap<>();
ref.put(Database.IronOre, 12.);
ref.put(Database.IronIngot, 12.);
ref.put(Database.IronRod, 3.);
ref.put(Database.IronPlate, 6.);
ref.put(Database.Screw, 12.);
ref.put(item, 1.);
values.put(item, ref);
}
}
public static Map<Item, Double> get(Item item) {
return values.get(item);
}
private static Map<Item, Double> ACU() {
// references, validated
Map<Item, Double> ref = new HashMap<>();
ref.put(Database.CircuitBoard, 15.0);
ref.put(Database.SteelIngot, 136.25);
ref.put(Database.Screw, 242.0);
ref.put(Database.Cable, 159.0);
ref.put(Database.Plastic, 78.0);
ref.put(Database.ModularFrame, 5.0);
ref.put(Database.CrudeOil, 117.0);
ref.put(Database.Limestone, 75.0);
ref.put(Database.EncasedIndustrialBeam, 5.0);
ref.put(Database.Wire, 378.0);
ref.put(Database.SteelPipe, 37.5);
ref.put(Database.IronPlate, 45.0);
ref.put(Database.SteelBeam, 20.0);
ref.put(Database.Stator, 7.5);
ref.put(Database.AutomatedWiring, 7.5);
ref.put(Database.Computer, 1.0);
ref.put(Database.Coal, 136.25);
ref.put(Database.Concrete, 25.0);
ref.put(Database.AdaptiveControlUnit, 1.0);
ref.put(Database.ReinforcedIronPlate, 7.5);
ref.put(Database.HeavyModularFrame, 1.0);
ref.put(Database.IronOre, 294.25);
ref.put(Database.CopperOre, 249.0);
ref.put(Database.CopperIngot, 249.0);
ref.put(Database.IronRod, 90.5);
ref.put(Database.IronIngot, 158.0);
ref.put(Database.HeavyOilResidue, 39.0);
ref.put(Database.CopperSheet, 30.0);
return ref;
}
private static Map<Item, Double> ME() {
// references, validated
Map<Item, Double> ref = new HashMap<>();
ref.put(Database.IronOre, 109.5);
ref.put(Database.Screw, 174.0);
ref.put(Database.SteelIngot, 18.0);
ref.put(Database.CrudeOil, 22.5);
ref.put(Database.IronIngot, 91.5);
ref.put(Database.IronRod, 73.5);
ref.put(Database.Rotor, 6.0);
ref.put(Database.Wire, 32.0);
ref.put(Database.CopperIngot, 16.0);
ref.put(Database.SteelPipe, 12.0);
ref.put(Database.IronPlate, 12.0);
ref.put(Database.Motor, 2.0);
ref.put(Database.Stator, 4.0);
ref.put(Database.Coal, 18.0);
ref.put(Database.ModularEngine, 1.0);
ref.put(Database.CopperOre, 16.0);
ref.put(Database.SmartPlating, 2.0);
ref.put(Database.ReinforcedIronPlate, 2.0);
ref.put(Database.Rubber, 15.0);
ref.put(Database.HeavyOilResidue, 15.0);
return ref;
}
private static Map<Item, Double> VF() {
// references, validated
Map<Item, Double> ref = new HashMap<>();
ref.put(Database.SteelBeam, 6.0);
ref.put(Database.ModularFrame, 0.5);
ref.put(Database.Coal, 24.0);
ref.put(Database.ReinforcedIronPlate, .75);
ref.put(Database.SteelIngot, 24.0);
ref.put(Database.IronPlate, 4.5);
ref.put(Database.Screw, 9.0);
ref.put(Database.IronOre, 36.0);
ref.put(Database.IronIngot, 12.0);
ref.put(Database.IronRod, 5.25);
ref.put(Database.VersatileFrameWork, 1.0);
return ref;
}
}