public List<BestFirstNode> Expand(FixedPinTry fixedPinTry) { List<BestFirstNode> newNodesList = new List<BestFirstNode>(); for (int firstTriangle = 0; firstTriangle < 20; firstTriangle++) { for (int secondTriangle = firstTriangle + 1; secondTriangle < 20; secondTriangle++) { for (int firstRotation = 0; firstRotation < 3; firstRotation++) { for (int secondRotation = 0; secondRotation < 3; secondRotation++) { IsoCoKuData newData = new IsoCoKuData(data); newData.swap(firstTriangle, secondTriangle, firstRotation, secondRotation); AddToList(newNodesList, newData, fixedPinTry); } } } } for (int triangle = 0; triangle < 20; triangle++) { for (int rotation = 1; rotation < 3; rotation++) { IsoCoKuData newData = new IsoCoKuData(data); newData.rotate(triangle, rotation); AddToList(newNodesList, newData, fixedPinTry); } } return newNodesList; }
private static void Solve() { while (!solved) { // there is always a solution, so this should be okay. BestFirstNode node = null; while (node == null) { node = queue.Dequeue(); if (node == null) { if (solved) return; Thread.Sleep(1); } } List<BestFirstNode> newNodes = node.Expand(fixedPinTry); foreach (BestFirstNode newNode in newNodes) { if (newNode.value == 0) { solved = true; solution = newNode.data; } else { queue.Enqueue(newNode); } } } }
public List <BestFirstNode> Expand(FixedPinTry fixedPinTry) { List <BestFirstNode> newNodesList = new List <BestFirstNode>(); for (int firstTriangle = 0; firstTriangle < 20; firstTriangle++) { for (int secondTriangle = firstTriangle + 1; secondTriangle < 20; secondTriangle++) { for (int firstRotation = 0; firstRotation < 3; firstRotation++) { for (int secondRotation = 0; secondRotation < 3; secondRotation++) { IsoCoKuData newData = new IsoCoKuData(data); newData.swap(firstTriangle, secondTriangle, firstRotation, secondRotation); AddToList(newNodesList, newData, fixedPinTry); } } } } for (int triangle = 0; triangle < 20; triangle++) { for (int rotation = 1; rotation < 3; rotation++) { IsoCoKuData newData = new IsoCoKuData(data); newData.rotate(triangle, rotation); AddToList(newNodesList, newData, fixedPinTry); } } return(newNodesList); }
private static void Solve() { while (!solved) { // there is always a solution, so this should be okay. BestFirstNode node = null; while (node == null) { node = queue.Dequeue(); if (node == null) { if (solved) { return; } Thread.Sleep(1); } } List <BestFirstNode> newNodes = node.Expand(fixedPinTry); foreach (BestFirstNode newNode in newNodes) { if (newNode.value == 0) { solved = true; solution = newNode.data; } else { queue.Enqueue(newNode); } } } }
private void StartSolver() { BestFirstSolver.Solve(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }); toDisplay = BestFirstSolver.solution; this.Invalidate(); }
private void AddToList(List<BestFirstNode> newNodesList, IsoCoKuData newData, FixedPinTry fixedPinTry) { if (!fixedPinTry.Contains(newData)) { BestFirstNode newNode = new BestFirstNode(newData); newNodesList.Add(newNode); } }
private void AddToList(List <BestFirstNode> newNodesList, IsoCoKuData newData, FixedPinTry fixedPinTry) { if (!fixedPinTry.Contains(newData)) { BestFirstNode newNode = new BestFirstNode(newData); newNodesList.Add(newNode); } }
public bool Contains(IsoCoKuData data) { int[] dotArray = new int[60]; for (int n = 0; n < 60; n++) { dotArray[n] = data.triangles[n % 20].dots[n / 20]; } return root.Contains(dotArray, 0); }
public bool Contains(IsoCoKuData data) { int[] dotArray = new int[60]; for (int n = 0; n < 60; n++) { dotArray[n] = data.triangles[n % 20].dots[n / 20]; } return(root.Contains(dotArray, 0)); }
public IsoCoKuData(IsoCoKuData source) { for (int n = 0; n < 11; n++) { this.pins[n] = source.pins[n]; } for (int n = 0; n < 12; n++) { this.dotCount[n] = source.dotCount[n]; } for (int n = 0; n < 20; n++) { this.triangles[n] = source.triangles[n]; } }
public IsoCoKuData(IsoCoKuData source) { for (int n = 0; n < 11; n++) { this.pins[n] = source.pins[n]; } for (int n = 0; n < 12; n++) { this.dotCount[n] = source.dotCount[n]; } for (int n = 0; n < 20; n++) { this.triangles[n] = source.triangles[n]; } }
public static void Solve(int[] pins) { IsoCoKuData data = new IsoCoKuData(pins); BestFirstNode start = new BestFirstNode(data); queue.Enqueue(start); for (int n = 0; n < 10; n++) { new Thread(Solve).Start(); } while (!solved) { Thread.Sleep(30); } }
public static void Solve(int[] pins) { IsoCoKuData data = new IsoCoKuData(pins); BestFirstNode start = new BestFirstNode(data); queue.Enqueue(start); for (int n = 0; n < 10; n++) { new Thread(Solve).Start(); } while (!solved) { Thread.Sleep(30); } }
public BestFirstNode(IsoCoKuData data) { this.data = data; Evaluate(); }
public BestFirstNode(IsoCoKuData data) { this.data = data; Evaluate(); }
private void StartSolver() { BestFirstSolver.Solve(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }); toDisplay = BestFirstSolver.solution; this.Invalidate(); }