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 BestFirstNode Dequeue() { BestFirstNode node = null; while (node == null) { if (length > 0) { for (int n = 0; n < queues.Length; n++) { if (queues[n].IsEmpty) { continue; } else { queues[n].TryDequeue(out node); break; } } } else { return(null); } } return(node); }
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 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 void Enqueue(BestFirstNode node) { queues[node.value].Enqueue(node); Interlocked.Increment(ref length); }