Esempio n. 1
0
        private void nextmove_Click(object sender, EventArgs e)
        {
            line_clear();
            calc.Text = "计算";

            IntPtr ptrmove = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CCMove)));

            if (nexttab.Count > 0)
            {
                coldclearcore.cc_request_next_move(ptrBot, 0);
                Thread.Sleep(500);
                int limit = 0;
                int nowb  = nexttab.Dequeue();
                while (coldclearcore.cc_poll_next_move(ptrBot, ptrmove) != 0 && limit < 40)
                {
                    Thread.Sleep(100);
                    limit++;
                }
                nodes.Text = limit.ToString();
                if (limit == 40)
                {
                    //char[] f = new char[400];
                    //for (int i = 0; i < 220; ++i)
                    //{
                    //    if ((int)(Field[i].Tag) != 0)
                    //    {
                    //        f[i] = (char)(1);
                    //    }
                    //}
                    //coldclearcore.cc_reset_async(ptrBot, f, (char)(0), combo);
                    return;
                }
                ;
                CCMove cCMove = (CCMove)Marshal.PtrToStructure(ptrmove, typeof(CCMove));


                nodes.Text = "nodes: " + cCMove.nodes;
                if (cCMove.hold == 1)
                {
                    if (hold == -1)
                    {
                        hold       = nowb;
                        holdb.Text = "hold: " + block[hold];
                        if (nexttab.Count <= 0)
                        {
                            return;
                        }
                        nowb = nexttab.Dequeue();
                    }
                    else
                    {
                        int temp;
                        temp       = nowb;
                        nowb       = hold;
                        hold       = temp;
                        holdb.Text = "hold: " + block[hold];
                    }
                }
                unsafe
                {
                    for (int i = 0; i < 4; ++i)
                    {
                        Field[(cCMove.expected_x[i]) + cCMove.expected_y[i] * 10].Tag       = nowb + 2;
                        Field[(cCMove.expected_x[i]) + cCMove.expected_y[i] * 10].BackColor = minocolor[nowb + 2];
                        //Field[0].BackColor = Color.Purple;
                    }
                }
                string a = "";
                foreach (int i in nexttab)
                {
                    a += block[i];
                }
                Nexttt.Text = "Next: " + a;
                //Field[0].Tag = 1;
                //Field[0].BackColor = Color.Purple;
                //nexttab.Dequeue();
                //Thread.Sleep(2000);
                //break;
            }
        }
Esempio n. 2
0
        private void print_npiece()
        {
            line_clear();

            calc.Text = "计算";
            char[] clearflag = new char[23];
            bool[] cleartrue = new bool[23];

            IntPtr ptrmove = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CCMove)));

            while (nexttab.Count > 0)
            {
                coldclearcore.cc_request_next_move(ptrBot, 0);
                Thread.Sleep(500);
                int nowb  = nexttab.Dequeue();
                int limit = 0;
                while (coldclearcore.cc_poll_next_move(ptrBot, ptrmove) != 0 && limit < 40)
                {
                    Thread.Sleep(100);
                    limit++;
                }
                if (limit == 40)
                {
                    //char[] f = new char[400];
                    //for (int i = 0; i < 220; ++i)
                    //{
                    //    if ((int)(Field[i].Tag) != 0)
                    //    {
                    //        f[i] = (char)(1);
                    //    }
                    //}
                    //coldclearcore.cc_reset_async(ptrBot, f, (char)(0), combo);
                    return;
                }
                CCMove cCMove = (CCMove)Marshal.PtrToStructure(ptrmove, typeof(CCMove));


                nodes.Text = "nodes: " + cCMove.nodes;
                if (cCMove.hold == 1)
                {
                    if (hold == -1)
                    {
                        hold       = nowb;
                        holdb.Text = "hold: " + block[hold];
                        if (nexttab.Count <= 0)
                        {
                            return;
                        }
                        nowb = nexttab.Dequeue();
                    }
                    else
                    {
                        int temp;
                        temp       = nowb;
                        nowb       = hold;
                        hold       = temp;
                        holdb.Text = "hold: " + block[hold];
                    }
                }
                unsafe
                {
                    for (int i = 0; i < 4; ++i)
                    {
                        int cnt = 0;
                        for (int _ = 0; _ < 22; ++_)
                        {
                            if (!cleartrue[_])
                            {
                                cnt++;
                            }

                            if (cnt == cCMove.expected_y[i] + 1)
                            {
                                cCMove.expected_y[i] = (char)_;
                                break;
                            }
                        }

                        Field[(cCMove.expected_x[i]) + (cCMove.expected_y[i]) * 10].Tag       = nowb + 2;
                        Field[(cCMove.expected_x[i]) + (cCMove.expected_y[i]) * 10].BackColor = minocolor[nowb + 2];
                        //Field[0].BackColor = Color.Purple
                    }
                }
                for (int q = 0; q < 22; ++q)
                {
                    bool flag = true;
                    for (int j = 0; j < 10; ++j)
                    {
                        if ((int)Field[j + q * 10].Tag == 0)
                        {
                            flag = false;
                            break;
                        }
                    }

                    //if (flag && !cleartrue[q])
                    //{

                    //    for (int zqd = q; zqd < 22; ++zqd)
                    //        clearflag[zqd] += (char)1;
                    //}
                    if (flag)
                    {
                        cleartrue[q] = true;
                    }
                }
                string a = "";
                foreach (int i in nexttab)
                {
                    a += block[i];
                }
                Nexttt.Text = "Next: " + a;
                //Field[0].Tag = 1;
                //Field[0].BackColor = Color.Purple;
                //nexttab.Dequeue();
                //Thread.Sleep(2000);
                //break;
            }
        }