public static Model NoRedundancyCircularModel() { // create 3 stations var dispenser = new ParticulateDispenser(); var stations = new Station[] { new ContainerLoader(), dispenser, new PalletisationStation() }; dispenser.SetStoredAmount(IngredientType.BlueParticulate, 50u); dispenser.SetStoredAmount(IngredientType.RedParticulate, 50u); dispenser.SetStoredAmount(IngredientType.YellowParticulate, 50u); // connect them to a circle for (var i = 0; i < stations.Length; ++i) { var next = stations[(i + 1) % stations.Length]; stations[i].Outputs.Add(next); next.Inputs.Add(stations[i]); } var model = new Model(stations, new FastObserverController(stations)); var recipe = new Recipe(ingredients: new[] { new Ingredient(IngredientType.BlueParticulate, 12), new Ingredient(IngredientType.RedParticulate, 4), new Ingredient(IngredientType.YellowParticulate, 5) }, amount: 3); model.ScheduleProduction(recipe); return model; }
public Model Parse(string fileName) { var lines = File.ReadAllLines(fileName); int lineIndex; // read model setup for (lineIndex = 0; lineIndex < lines.Length && lines[lineIndex] != ""; ++lineIndex) { int currentPosition = 0; var input = lines[lineIndex]; // read alternating sequence of station identifiers and connections Station lastStation = ReadStation(input, ref currentPosition); while (currentPosition < input.Length) { var isTwoWay = ReadConnection(input, ref currentPosition); var station = ReadStation(input, ref currentPosition); Connect(lastStation, station); if (isTwoWay) Connect(station, lastStation); lastStation = station; } } var model = new Model(_stations.ToArray(), new FastObserverController(_stations.ToArray())); // read recipes to be produced by the model for (lineIndex++; lineIndex < lines.Length; ++lineIndex) { var input = lines[lineIndex]; int currentPosition = 0; var amount = ReadUntil(input, ref currentPosition, ' '); var ingredients = new List<Ingredient>(); while (currentPosition < input.Length) { ingredients.Add(ReadIngredient(input, ref currentPosition)); } model.ScheduleProduction(new Recipe(ingredients.ToArray(), uint.Parse(amount))); } return model; }