private void CalculateDoorCosts() { //calculate every possible scenario, every yesno, the outer lines are not nessesary 2,3,7,8 _Model tempModel = Model;//.DeepCopy(); List <_Line> allLinesFlat = tempModel.AllLinesFlat(); int[] arr = Enumerable.Range(0, allLinesFlat.Count).ToArray(); //TODO: we could ommit outside lines List <int[]> indicesToSetAsDoors = CFG.printCombination(arr, allLinesFlat.Count, Model.rooms.Count); for (int index = 0; index < indicesToSetAsDoors.Count; index++) { List <_Line> currentLines = new List <_Line>(); int[] elementAt = indicesToSetAsDoors.ElementAt(index); if (elementAt.Contains(1) && elementAt.Contains(2) && elementAt.Contains(7) && elementAt.Contains(8)) { int breakpointint = 0; } foreach (int i in elementAt) { currentLines.Add(allLinesFlat.ElementAt(i)); } tempModel.MakeLineDoor(currentLines); Cost c = CostCalculationService.CalculateDoorCost(tempModel); DoorActions.Add(new MakeDoor(currentLines, c)); } int breakpoint = DoorActions.Count; }
public void MoveEveryLineInNormal() { m = ModelConfigurations.InitNormalModel(); _Line l = null; List <_Line> lines = m.AllLinesFlat(); for (var i = 0; i < lines.Count; i++) { l = lines[i]; m.MoveLine(10, l); m.MoveLine(-10, l); m.MoveLine(-10, l); m.MoveLine(10, l); } }
//[Attribute a=1] public void MoveLineInAllModel() { List <_Model> contents = new List <_Model>(); foreach (string filename in Directory.GetFiles(@"C:\Users\Master\Desktop\Models")) { MessageBox.Show(filename); if (!filename.EndsWith("json")) { continue; } try { string json = File.ReadAllText(filename); MessageBox.Show(json); _Model account = JsonConvert.DeserializeObject <_Model>(json); contents.Add(account); } catch (Exception e) { MessageBox.Show(e.Message + "\n" + e.StackTrace); } } MessageBox.Show(contents.Count.ToString()); foreach (_Model m in contents) { _Model mcopy = m.DeepCopy(); List <_Line> lines = mcopy.AllLinesFlat(); for (var i = 0; i < lines.Count; i++) { _Line l = lines[i]; mcopy.MoveLine(10, l); mcopy.MoveLine(-10, l); mcopy.MoveLine(-10, l); mcopy.MoveLine(10, l); } } //m = LoadModelFromJsonString(); //Line l = Find200200400200Line(); //m.MoveLine(10, l); //Assert m.IsInInvalidState.Equals(false); }
private string GenerateModelNameFromState(_Model currentModel) { return ($"{currentModel.loadedModelType}_{currentModel.rooms.Count}_" + $"{currentModel.AllLinesFlat().Count}"); }