Beispiel #1
0
        //*****************************************************
        void ThreadBFS()
        {
            List <int> temp;

            label3_Info.ForeColor = Color.DarkTurquoise;
            label3_Info.Text      = "Searching ...";
            sw.Start();
            label3_Info.Text = bfs.BfsSearchFunction();
            sw.Stop();

            lbl_time_ans.Text = sw.Elapsed.TotalMilliseconds.ToString() + "  ms";
            sw.Reset();
            temp = bfs.PathFinder(bfs.i);
            foreach (var item in temp)
            {
                listBox1.Items.Add(item.ToString());
            }
            foreach (int item in temp)
            {
                listBox2.Items.Add(bfs.queueArray.ElementAt(item).ActionStruct);
                path.Add(bfs.queueArray.ElementAt(item).ActionStruct);
            }

            lbl_Snodes_ans.Text = bfs.i.ToString();
            lbl_Gnodes_ans.Text = bfs.queueArray.Count.ToString();
            lbl_depth_ans.Text  = bfs.DepthFinder().ToString();

            MachineMove.path = path.ToArray();
            path.Clear();
            temp.Clear();

            label3_Info.ForeColor = Color.LightPink;
            label3_Info.Text      = "Puzzle Solved!";
            Thread.Sleep(300);
            label3_Info.Text = "";
            Thread.Sleep(300);
            label3_Info.Text = "Puzzle Solved!";
            Thread.Sleep(300);
            label3_Info.Text = "";
            Thread.Sleep(300);
            label3_Info.Text      = "Puzzle Solved!";
            label3_Info.ForeColor = Color.Cyan;
            label3_Info.Text      = "Showing Solution .";
            Thread.Sleep(300);
            label3_Info.Text = "Showing Solution ..";
            Thread.Sleep(300);
            label3_Info.Text = "Showing Solution ...";

            MachineMove.Action(button1, button2, button3, button4, button5, button6, button7, button8, button9, panel1.BackColor);
            label3_Info.ForeColor = Color.YellowGreen;
            label3_Info.Text      = "Machine Win !";
            bfs.queueArray.Clear();
            bfs.PathList.Clear();
            bfs.i = 0;
            bfs.j = 0;

            trReset = new Thread(new ThreadStart(ThreadReset));
            trReset.Start();
        }
Beispiel #2
0
        //*****************************************************
        void ThreadAStar()
        {
            List <string> temp;
            NodeAStar     nodeResult;

            label3_Info.ForeColor = Color.DarkTurquoise;
            label3_Info.Text      = "Searching ...";
            sw.Start();
            nodeResult       = astar.AstarSearch();
            label3_Info.Text = "Puzzle Solved!";
            sw.Stop();

            lbl_time_ans.Text = sw.Elapsed.TotalMilliseconds.ToString() + "  ms";
            sw.Reset();

            temp = astar.PathFinder(nodeResult);
            foreach (UInt64 item in astar.NodeNumber)
            {
                listBox1.Items.Add(item);
            }

            foreach (string item in temp)
            {
                listBox2.Items.Add(item);
            }



            lbl_Snodes_ans.Text = astar.i.ToString();
            lbl_Gnodes_ans.Text = PQueue.count.ToString();
            lbl_depth_ans.Text  = temp.Count.ToString();

            MachineMove.path = temp.ToArray();
            temp.Clear();

            label3_Info.ForeColor = Color.LightPink;
            label3_Info.Text      = "Puzzle Solved!";
            Thread.Sleep(300);
            label3_Info.Text = "";
            Thread.Sleep(300);
            label3_Info.Text = "Puzzle Solved!";
            Thread.Sleep(300);
            label3_Info.Text = "";
            Thread.Sleep(300);
            label3_Info.Text = "Puzzle Solved!";

            label3_Info.ForeColor = Color.Cyan;
            label3_Info.Text      = "Showing Solution .";
            Thread.Sleep(300);
            label3_Info.Text = "Showing Solution ..";
            Thread.Sleep(300);
            label3_Info.Text = "Showing Solution ...";

            MachineMove.Action(button1, button2, button3, button4, button5, button6, button7, button8, button9, panel1.BackColor);
            label3_Info.ForeColor = Color.YellowGreen;
            label3_Info.Text      = "Machine Win !";
            astar.NodeNumber.Clear();

            Pqueue.Clear();
            astar.i      = 0;
            astar.j      = 0;
            PQueue.count = 0;
            trReset      = new Thread(new ThreadStart(ThreadReset));
            trReset.Start();
        }