예제 #1
0
        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;
        }
예제 #2
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);
                    }
                }
            }
        }
예제 #3
0
        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);
        }
예제 #4
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);
                    }
                }
            }
        }
예제 #5
0
파일: Form1.cs 프로젝트: genveir/IsoCoKu
        private void StartSolver()
        {
            BestFirstSolver.Solve(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 });

            toDisplay = BestFirstSolver.solution;

            this.Invalidate();
        }
예제 #6
0
 private void AddToList(List<BestFirstNode> newNodesList, IsoCoKuData newData, FixedPinTry fixedPinTry)
 {
     if (!fixedPinTry.Contains(newData))
     {
         BestFirstNode newNode = new BestFirstNode(newData);
         newNodesList.Add(newNode);
     }
 }
예제 #7
0
 private void AddToList(List <BestFirstNode> newNodesList, IsoCoKuData newData, FixedPinTry fixedPinTry)
 {
     if (!fixedPinTry.Contains(newData))
     {
         BestFirstNode newNode = new BestFirstNode(newData);
         newNodesList.Add(newNode);
     }
 }
예제 #8
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);
        }
예제 #9
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));
        }
예제 #10
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];
            }
        }
예제 #11
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];
            }
        }
예제 #12
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);
            }
        }
예제 #13
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);
            }
        }
예제 #14
0
 public BestFirstNode(IsoCoKuData data)
 {
     this.data = data;
     Evaluate();
 }
예제 #15
0
 public BestFirstNode(IsoCoKuData data)
 {
     this.data = data;
     Evaluate();
 }
예제 #16
0
파일: Form1.cs 프로젝트: genveir/IsoCoKu
        private void StartSolver()
        {
            BestFirstSolver.Solve(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 });

            toDisplay = BestFirstSolver.solution;

            this.Invalidate();
        }