add tests
parent
892efb18a6
commit
32c8a4daf6
|
|
@ -3,4 +3,6 @@ out/
|
||||||
build/
|
build/
|
||||||
.gradle/
|
.gradle/
|
||||||
plots/
|
plots/
|
||||||
|
lists/
|
||||||
local.properties
|
local.properties
|
||||||
|
data.json
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ public class Database {
|
||||||
public static final Map<Item, Recipe> preferences = new HashMap<>();
|
public static final Map<Item, Recipe> preferences = new HashMap<>();
|
||||||
|
|
||||||
// Items & recipes
|
// Items & recipes
|
||||||
public static final Item IronOre = new Ore("Iron Ore");
|
public static final Item IronOre = add(new Ore("Iron Ore"));
|
||||||
public static final Item IronIngot = new Ingot("Iron Ingot");
|
public static final Item IronIngot = new Ingot("Iron Ingot");
|
||||||
public static final Item CopperOre = new Ore("Copper Ore");
|
public static final Item CopperOre = new Ore("Copper Ore");
|
||||||
public static final Item CopperIngot = new Ingot("Copper Ingot");
|
public static final Item CopperIngot = new Ingot("Copper Ingot");
|
||||||
|
|
@ -805,8 +805,9 @@ public class Database {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void add(Item i) {
|
public static Item add(Item i) {
|
||||||
items.add(i);
|
items.add(i);
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<Item> getItems() {
|
public static Collection<Item> getItems() {
|
||||||
|
|
|
||||||
|
|
@ -17,15 +17,14 @@ import satisfactory.items.Production;
|
||||||
import satisfactory.items.Recipe;
|
import satisfactory.items.Recipe;
|
||||||
import satisfactory.items.SumResult;
|
import satisfactory.items.SumResult;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static satisfactory.Utils.PLOTS;
|
import static satisfactory.Utils.*;
|
||||||
import static satisfactory.Utils.plot2;
|
|
||||||
|
|
||||||
public class Test {
|
public class Test {
|
||||||
public static void main(String[] args) throws JsonProcessingException {
|
public static void main(String[] args) throws JsonProcessingException {
|
||||||
|
|
@ -135,13 +134,17 @@ public class Test {
|
||||||
);
|
);
|
||||||
planFor(
|
planFor(
|
||||||
"phase3",
|
"phase3",
|
||||||
new Production(Database.VersatileFrameWork,5),
|
new Production(Database.VersatileFrameWork, 5),
|
||||||
new Production(Database.ModularEngine,1),
|
new Production(Database.ModularEngine, 1),
|
||||||
new Production(Database.AdaptiveControlUnit,1)
|
new Production(Database.AdaptiveControlUnit, 1)
|
||||||
);
|
);
|
||||||
planFor("allIron",
|
planFor("allIron",
|
||||||
new Production(Database.IronRod,1),
|
new Production(Database.IronRod, 1),
|
||||||
new Production(Database.IronPlate,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, int amount, String name) {
|
private static void planFor(Item item, int amount, String name) {
|
||||||
|
|
@ -154,6 +157,7 @@ public class Test {
|
||||||
SumResult plan = SumResult.sum(prods);
|
SumResult plan = SumResult.sum(prods);
|
||||||
plot2(plan.getProduction(), name);
|
plot2(plan.getProduction(), name);
|
||||||
javaPlot(name);
|
javaPlot(name);
|
||||||
|
list(plan, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void plot(Item target, String name, int amount) {
|
private static void plot(Item target, String name, int amount) {
|
||||||
|
|
@ -180,6 +184,36 @@ public class Test {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
public static Set<String> unlocks(String... unlock) {
|
||||||
return Set.of(unlock);
|
return Set.of(unlock);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import java.util.stream.Collectors;
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
public static final String PLOTS = "plots/";
|
public static final String PLOTS = "plots/";
|
||||||
|
public static final String LISTS = "lists/";
|
||||||
|
|
||||||
public static Map<Item, Integer> getRawOnly(Map<Item, Integer> totals) {
|
public static Map<Item, Integer> getRawOnly(Map<Item, Integer> totals) {
|
||||||
Map<Item, Integer> raws = new HashMap<>();
|
Map<Item, Integer> raws = new HashMap<>();
|
||||||
|
|
|
||||||
|
|
@ -9,17 +9,14 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
import static satisfactory.items.TestHelper.assertMap;
|
||||||
|
import static satisfactory.items.TestHelper.test;
|
||||||
|
|
||||||
class ItemTest {
|
class ItemTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void productionScrews() {
|
void productionScrews() {
|
||||||
/*Map<Item, Double> production = Database.Screw.production(100);
|
test(Database.Screw);
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -36,14 +33,7 @@ class ItemTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void productionReinforcedIronPlates() {
|
void productionReinforcedIronPlates() {
|
||||||
/*Map<Item, Double> production = Database.ReinforcedIronPlate.production(100);
|
test(Database.ReinforcedIronPlate);
|
||||||
assertEquals(100, production.get(Database.ReinforcedIronPlate), "output");
|
|
||||||
assertEquals(1200, production.get(Database.Screw), "Screws");
|
|
||||||
assertEquals(300, production.get(Database.IronRod), "IronRod");
|
|
||||||
assertEquals(1200, production.get(Database.IronIngot), "IronIngot");
|
|
||||||
assertEquals(1200, production.get(Database.IronOre), "IronOre");
|
|
||||||
assertEquals(600, production.get(Database.IronPlate), "IronPlate");*/
|
|
||||||
fail();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -52,51 +42,4 @@ class ItemTest {
|
||||||
assertEquals(40, productionRate);
|
assertEquals(40, productionRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@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, 5), new Production(Database.AdaptiveControlUnit, 1)).getMap();
|
|
||||||
|
|
||||||
// assert
|
|
||||||
ref.forEach((item, amount) -> {
|
|
||||||
assertTrue(calculations.containsKey(item), "exists? " + item.getName());
|
|
||||||
assertEquals(amount, calculations.get(item), 0.01, item.getName());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -3,58 +3,227 @@ package satisfactory.items;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import satisfactory.Database;
|
import satisfactory.Database;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
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 {
|
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
|
@Test
|
||||||
void testPhase3_ME_ACU() {
|
void testPhase3_ME_ACU() {
|
||||||
// references
|
// references
|
||||||
Map<Item, Double> ref = new HashMap<>();
|
Map<Item, Double> ref = new HashMap<>();
|
||||||
ref.put(Database.CircuitBoard, 15.0);
|
ref.put(Database.CircuitBoard, 15.0);
|
||||||
ref.put(Database.Computer, 1.0);
|
ref.put(Database.Computer, 1.0);
|
||||||
ref.put(Database.Limestone,75.0);
|
ref.put(Database.Limestone, 75.0);
|
||||||
ref.put(Database.Concrete,25.0);
|
ref.put(Database.Concrete, 25.0);
|
||||||
ref.put(Database.SteelBeam,20.0);
|
ref.put(Database.SteelBeam, 20.0);
|
||||||
ref.put(Database.EncasedIndustrialBeam, 5.0);
|
ref.put(Database.EncasedIndustrialBeam, 5.0);
|
||||||
ref.put(Database.ModularFrame,5.0);
|
ref.put(Database.ModularFrame, 5.0);
|
||||||
ref.put(Database.HeavyModularFrame,1.0);
|
ref.put(Database.HeavyModularFrame, 1.0);
|
||||||
ref.put(Database.Plastic, 78.0);
|
ref.put(Database.Plastic, 78.0);
|
||||||
ref.put(Database.CopperSheet, 30.0);
|
ref.put(Database.CopperSheet, 30.0);
|
||||||
ref.put(Database.Coal,226.25);
|
ref.put(Database.Coal, 226.25);
|
||||||
ref.put(Database.Cable,159.0);
|
ref.put(Database.Cable, 159.0);
|
||||||
ref.put(Database.CopperOre,329.0);
|
ref.put(Database.CopperOre, 329.0);
|
||||||
ref.put(Database.AutomatedWiring, 7.5);
|
ref.put(Database.AutomatedWiring, 7.5);
|
||||||
ref.put(Database.AdaptiveControlUnit, 1.0);
|
ref.put(Database.AdaptiveControlUnit, 1.0);
|
||||||
ref.put(Database.CrudeOil, 229.5);
|
ref.put(Database.CrudeOil, 229.5);
|
||||||
ref.put(Database.ReinforcedIronPlate, 17.5);
|
ref.put(Database.ReinforcedIronPlate, 17.5);
|
||||||
ref.put(Database.CopperIngot, 329.0);
|
ref.put(Database.CopperIngot, 329.0);
|
||||||
ref.put(Database.SteelIngot, 226.25);
|
ref.put(Database.SteelIngot, 226.25);
|
||||||
ref.put(Database.IronPlate, 105.0);
|
ref.put(Database.IronPlate, 105.0);
|
||||||
ref.put(Database.SmartPlating, 10.0);
|
ref.put(Database.SmartPlating, 10.0);
|
||||||
//ref.put(Database.HeavyOilResidue, 114.0); // TODO: implement calculation
|
//ref.put(Database.HeavyOilResidue, 114.0); // TODO: implement calculation
|
||||||
ref.put(Database.Rubber, 75.0);
|
ref.put(Database.Rubber, 75.0);
|
||||||
ref.put(Database.Wire, 538.0);
|
ref.put(Database.Wire, 538.0);
|
||||||
ref.put(Database.SteelPipe, 97.5);
|
ref.put(Database.SteelPipe, 97.5);
|
||||||
ref.put(Database.Stator, 27.5);
|
ref.put(Database.Stator, 27.5);
|
||||||
ref.put(Database.Screw, 1112.0);
|
ref.put(Database.Screw, 1112.0);
|
||||||
ref.put(Database.IronOre, 841.75);
|
ref.put(Database.IronOre, 841.75);
|
||||||
ref.put(Database.IronIngot, 615.5);
|
ref.put(Database.IronIngot, 615.5);
|
||||||
ref.put(Database.IronRod, 458.0);
|
ref.put(Database.IronRod, 458.0);
|
||||||
ref.put(Database.Rotor, 30.0);
|
ref.put(Database.Rotor, 30.0);
|
||||||
ref.put(Database.Motor, 10.0);
|
ref.put(Database.Motor, 10.0);
|
||||||
ref.put(Database.ModularEngine, 5.0);
|
ref.put(Database.ModularEngine, 5.0);
|
||||||
|
|
||||||
// calculate
|
// calculate
|
||||||
Map<Item, Double> calculations = SumResult.sum(new Production(Database.ModularEngine, 5), new Production(Database.AdaptiveControlUnit, 1)).getMap();
|
Map<Item, Double> calculations = SumResult.sum(new Production(Database.ModularEngine, 1), new Production(Database.AdaptiveControlUnit, 1)).getMap();
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
ref.forEach((item, amount) -> {
|
assertMap(ref, calculations);
|
||||||
assertTrue(calculations.containsKey(item), "exists? " + item.getName());
|
}
|
||||||
assertEquals(amount, calculations.get(item), 0.01, item.getName());
|
|
||||||
});
|
@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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue