public void AssignedWorkAffectsQuotaFactor() { var blueprint = new Blueprint("A", 1, new ItemAndQuantity("Ore/A", 10), new ItemAndQuantity("Ingot/A", 10)); var stockpiles = new IngotStockpiles(new TestIngotDefinitions { { "Ingot/A", 100 } }); var ingotWorklist = new IngotWorklist(stockpiles); var refinery = Refinery.Get(mockRefinery, new RefineryType("Refinery") { SupportedBlueprints = { "A" } }, 1); stockpiles.UpdateQuantities(new TestIngotQuantities { { "Ingot/A", 50 } }); ingotWorklist.Initialise(); IngotStockpile preferred; Assume.That(ingotWorklist.TryGetPreferred(out preferred)); Assume.That(preferred.EstimatedProduction, Is.EqualTo(0)); var initialQuotaFraction = preferred.QuotaFraction; ingotWorklist.UpdateStockpileEstimates(refinery, blueprint, 5); IngotStockpile updatedPreferred; Assume.That(ingotWorklist.TryGetPreferred(out updatedPreferred)); Assert.That(updatedPreferred.QuotaFraction, Is.GreaterThan(initialQuotaFraction)); Assert.That(updatedPreferred.EstimatedProduction, Is.GreaterThan(0)); }
public void SilverAndCobalt() { var stockpiles = new IngotStockpiles(new[] { new IngotStockpile(new IngotType("Ingot/Cobalt", 220) { ProductionNormalisationFactor = 0.075 }), new IngotStockpile(new IngotType("Ingot/Silver", 10) { ProductionNormalisationFactor = 0.1 }) }); var ingotWorklist = new IngotWorklist(stockpiles); stockpiles.UpdateAssemblerSpeed(10); stockpiles.UpdateQuantities(new TestIngotQuantities { { "Ingot/Cobalt", 275 }, { "Ingot/Silver", 34 } }); ingotWorklist.Initialise(); IngotStockpile preferred; Assert.That(ingotWorklist.TryGetPreferred(out preferred)); Assert.That(preferred.Ingot.ItemType, Is.EqualTo(new ItemType("Ingot/Cobalt"))); }
public void IronAndGold() { var stockpiles = new IngotStockpiles(new[] { new IngotStockpile(new IngotType("Ingot/Gold", 5) { ProductionNormalisationFactor = 0.025 }), new IngotStockpile(new IngotType("Ingot/Iron", 80) { ProductionNormalisationFactor = 14 }) }); var ingotWorklist = new IngotWorklist(stockpiles); stockpiles.UpdateAssemblerSpeed(10); stockpiles.UpdateQuantities(new TestIngotQuantities { { "Ingot/Gold", 27 }, { "Ingot/Iron", 15000 } }); ingotWorklist.Initialise(); IngotStockpile preferred; Assert.That(ingotWorklist.TryGetPreferred(out preferred)); Assert.That(preferred.Ingot.ItemType, Is.EqualTo(new ItemType("Ingot/Gold"))); }
public void SkippingLastStockpileLeavesEmptyWorklist() { var stockpiles = new IngotStockpiles(new TestIngotDefinitions { { "Ingot/A", 10 }, { "Ingot/B", 100 } }); var ingotWorklist = new IngotWorklist(stockpiles); stockpiles.UpdateQuantities(new TestIngotQuantities { { "Ingot/A", 5 }, // 50% { "Ingot/B", 10 } // 10% }); ingotWorklist.Initialise(); ingotWorklist.UpdateStockpileEstimates(Util.DefaultRefinery, Util.DefaultBlueprintProducing("Ingot/B"), 100); IngotStockpile preferred; Assume.That(ingotWorklist.TryGetPreferred(out preferred)); ingotWorklist.Skip(); Assume.That(ingotWorklist.TryGetPreferred(out preferred)); ingotWorklist.Skip(); Assert.That(ingotWorklist.TryGetPreferred(out preferred), Is.False); }
public void UpdatingStockpilesUpdatesPreferredIngotType() { var stockpiles = new IngotStockpiles(new TestIngotDefinitions { { "Ingot/A", 10 }, { "Ingot/B", 100 } }); var ingotWorklist = new IngotWorklist(stockpiles); stockpiles.UpdateQuantities(new TestIngotQuantities { { "Ingot/A", 5 }, // 50% { "Ingot/B", 10 } // 10% }); ingotWorklist.Initialise(); ingotWorklist.UpdateStockpileEstimates(Util.DefaultRefinery, Util.DefaultBlueprintProducing("Ingot/B"), 100); IngotStockpile preferred; Assert.That(ingotWorklist.TryGetPreferred(out preferred)); Assert.That(preferred.Ingot.ItemType, Is.EqualTo(new ItemType("Ingot/A"))); }
public void InitialPreferredIngotTypeIsFurthestFromTarget() { var stockpiles = new IngotStockpiles(new TestIngotDefinitions { { "Ingot/A", 10 }, { "Ingot/B", 100 }, { "Ingot/C", 20 }, { "Ingot/D", 8 } }); var ingotWorklist = new IngotWorklist(stockpiles); stockpiles.UpdateQuantities(new TestIngotQuantities { { "Ingot/A", 5 }, // 50% { "Ingot/B", 10 }, // 10% { "Ingot/C", 8 }, // 40% { "Ingot/D", 12 } // 150% }); ingotWorklist.Initialise(); IngotStockpile preferred; Assume.That(ingotWorklist.TryGetPreferred(out preferred)); Assert.That(preferred.Ingot.ItemType, Is.EqualTo(new ItemType("Ingot/B"))); }