示例#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);
            }
        }
 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);
 }