예제 #1
0
        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);
                    }
                }
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
 private void AddToList(List<BestFirstNode> newNodesList, IsoCoKuData newData, FixedPinTry fixedPinTry)
 {
     if (!fixedPinTry.Contains(newData))
     {
         BestFirstNode newNode = new BestFirstNode(newData);
         newNodesList.Add(newNode);
     }
 }
예제 #4
0
 private void AddToList(List <BestFirstNode> newNodesList, IsoCoKuData newData, FixedPinTry fixedPinTry)
 {
     if (!fixedPinTry.Contains(newData))
     {
         BestFirstNode newNode = new BestFirstNode(newData);
         newNodesList.Add(newNode);
     }
 }
예제 #5
0
        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);
            }
        }
예제 #6
0
        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);
            }
        }
예제 #7
0
 public void Enqueue(BestFirstNode node)
 {
     queues[node.value].Enqueue(node);
     Interlocked.Increment(ref length);
 }
예제 #8
0
 public void Enqueue(BestFirstNode node)
 {
     queues[node.value].Enqueue(node);
     Interlocked.Increment(ref length);
 }