예제 #1
0
        private int Play(int numReceived)
        {
            NextStateGet = true;
            int AssumeChild = 0;
            int nextMove    = 0;
            int total       = numReceived;
            int x           = total / 8;
            int y           = total % 8;

            //int y = Int32.Parse(textBox2.Text);
            Steps += 2;

            if (Steps != 4)
            {
                EnemyMatch(x, y);//global "Current" is the enemy's state now, update enemy state's board;
            }

            Current.GenerateChild();//Initialzie the states which self may put, the available position is also calculated

            if (Current.AvailablePosition[0].Count != 0)
            {
                for (int i = 1; i < Current.AvailablePosition[0].Count + 1; i++)
                {
                    Current.Child[i].GenerateChild();//Initialize all the enemy's state after each self state;
                }

                AssumeChild = Alg_1.NextStep(Current);
                nextMove    = Current.AvailablePosition[0][AssumeChild - 1] * 8 + Current.AvailablePosition[1][AssumeChild - 1];
            }
            else
            {
                Current.Child[0].GenerateChild();
                AssumeChild = 0;
                nextMove    = 64;
            }
            Current = Current.Child[AssumeChild];

            NextStateGet = false;

            UpdateChessBoard(Current);

            return(nextMove);
        }
예제 #2
0
        private void ProcessNext()
        {
            int total = Int32.Parse(textBox1.Text);
            int x     = total / 8;
            int y     = total % 8;

            //int y = Int32.Parse(textBox2.Text);
            Steps += 2;
            int AssumeChild = 0;
            int nextMove    = 0;

            if (Steps != 4)
            {
                EnemyMatch(x, y);//global "Current" is the enemy's state now, update enemy state's board;
            }

            Current.GenerateChild();//Initialzie the states which self may put, the available position is also calculated

            if (Current.AvailablePosition[0].Count != 0)
            {
                for (int i = 1; i < Current.AvailablePosition[0].Count + 1; i++)
                {
                    Current.Child[i].GenerateChild();//Initialize all the enemy's state after each self state;
                }

                AssumeChild = Alg_1.NextStep(Current);
                nextMove    = Current.AvailablePosition[0][AssumeChild - 1] * 8 + Current.AvailablePosition[1][AssumeChild - 1];
            }
            else
            {
                Current.Child[0].GenerateChild();
                AssumeChild = 0;
                nextMove    = 64;
                MessageBox.Show("I have no way to go");
                //Do not need to update the state;
            }
            Current = Current.Child[AssumeChild];

            NextStateGet = false;

            UpdateChessBoard(Current);
        }