Example #1
0
        /// <summary>
        /// 电脑开新进程进行搜索
        /// </summary>
        private void NewThreadComputerPlayChess()
        {
            int i = 2;

            if (i == 2)
            {//老方法
                ComputerPlayer.SearchBestPoint(arrchessboard, -1, Const.Xmin, Const.Ymin, Const.Xmax, Const.Ymax);
            }
            else
            {//新方法,在老方法的基础上判断是否形成特殊的局,如 五连,活四,冲四,双连三,在此基础上再判断权值
                ComputerPlayer.SearchBestPointStr(arrchessboard, -1, Const.Xmin, Const.Ymin, Const.Xmax, Const.Ymax);
            }
            PlayChess(ComputerPlayer.X, ComputerPlayer.Y, m_mmDisplayStep, m_mmGraphics);

            if (Const.bGameOver)
            {
                return;
            }

            Const.bCurrPlayer = Player.Person;
            PlayerChangeEventArgs thePlayer = new PlayerChangeEventArgs();

            thePlayer.CurrPlayer = Const.bCurrPlayer;
            this.OnPlayerChange(null, thePlayer);
        }
Example #2
0
 private void ChessBoard_OnPlayerChange(object sender, PlayerChangeEventArgs e)
 {
     if (Const.bGameOver)
     {
         return;
     }
     if (e.CurrPlayer == Player.Person)
     {
         this.labSetPlayer.Text = "玩家正在下棋";
     }
     else
     {
         this.labSetPlayer.Text = "电脑正在下棋";
     }
     this.Refresh();
 }
Example #3
0
        /// <summary>
        /// 电脑开始下棋
        /// </summary>
        public void ComputerPlayChess(bool DisplayStep, Graphics mGraphics)
        {
            Const.bCurrPlayer = Player.Computer;
            PlayerChangeEventArgs thePlayer = new PlayerChangeEventArgs();

            thePlayer.CurrPlayer = Const.bCurrPlayer;
            this.OnPlayerChange(null, thePlayer);

            System.Windows.Forms.ProgressBar.CheckForIllegalCrossThreadCalls = false;
            System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(NewThreadComputerPlayChess));
            thread.Priority     = System.Threading.ThreadPriority.Normal;
            thread.IsBackground = true;
            thread.Start();
            //NewThreadComputerPlayChess(DisplayStep, mGraphics);
            m_mmDisplayStep = DisplayStep;
            m_mmGraphics    = mGraphics;
        }