Esempio n. 1
0
        public void PropertyChangedCpuMode(object sender, PropertyChangedEventArgs e)
        {
            // UIを中断ボタン以外無効化
            SetControlEnable(false);
            // ゲームスレッドにCPU処理リクエスト送信
            GameThread gmt = new GameThread();
            object[] args = new object[] { GameThread.CMD_CPU, boardclass, cpuClass[nowColor], this };
            //MessageBox.Show("ゲームスレッドにCPU処理リクエスト送信", "情報", MessageBoxButtons.OK, MessageBoxIcon.Information);
            gmt.m_recvcmdProperty = args;

            toolStripStatusLabel1.Text = "";
            m_sw.Restart();
        }
Esempio n. 2
0
 public void PropertyChangedHint(object sender, PropertyChangedEventArgs e)
 {
     // UIを中断ボタン以外無効化
     SetControlEnable(false);
     // ゲームスレッドにヒント処理リクエストを送信
     GameThread gmt = new GameThread();
     object[] args = new object[] { GameThread.CMD_HINT, boardclass, cpuClass[nowColor], this, m_hintLevel };
     gmt.m_recvcmdProperty = args;
 }
Esempio n. 3
0
        public void PropertyChangedCpuMove(object sender, PropertyChangedEventArgs e)
        {
            bool bootRet;
            // CPUの算出した評価値を取得
            int eval = cppWrapper.GetLastEvaluation();
            // 評価値の表示
            toolStripStatusLabel2.Text = ConvertEvaltoString(eval, cpuClass[nowColor]);

            if (m_cpuMoveProperty == MOVE_PASS)
            {
                // CPUはパス
                m_passCount++;

                // ゲーム終了?
                if (m_passCount == 2 || cppWrapper.CountBit(~(boardclass.GetBlack() | boardclass.GetWhite())) == 0)
                {
                    // ゲーム終了
                    m_mode = ON_NOTHING;
                    m_cpuFlagProperty = false;
                    m_passCount = 0;
                    m_sw.Stop();
                    SetControlEnable(true);
                    // 結果表示
                    PrintResult();
                    // 画面描画
                    panel1.Invalidate(false);
                    panel1.Update();

                    return;
                }

                MessageBox.Show("プレイヤー" + (nowColor + 1) + "はパスです", "情報",
                   MessageBoxButtons.OK, MessageBoxIcon.Information);

                // CPUがパスなのでプレイヤー変更
                ChangePlayerReasonPass();
            }
            else
            {
                // CPUが打てたのでパスカウントをリセット
                m_passCount = 0;
                // 盤面情報更新
                bootRet = boardclass.move(cppWrapper.ConvertMoveBit(m_cpuMoveProperty));
                if (bootRet == false)
                {
                    MessageBox.Show("内部エラーが発生しました", "エラー",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                // CPUが打ったのでプレイヤー変更
                ChangePlayer();
                SetControlEnable(true);
            }

            GameThread gmt;
            // プレイヤー変更後もCPUなら再度ゲームスレッドにリクエスト送信(双方がCPUの場合)
            if (m_mode == ON_GAME && nowPlayer.playerInfo == Player.PLAYER_CPU)
            {
                // 画面再描画(前のCPUの手を画面に反映しておく)
                panel1.Invalidate(false);
                panel1.Update();

                gmt = new GameThread();
                object[] args = new object[] { GameThread.CMD_CPU, boardclass, cpuClass[nowColor], this };
                gmt.m_recvcmdProperty = args;
                m_sw.Restart();

                return;
            }

            // 人間がパスだった場合は通知して再度ゲームスレッドにリクエスト送信
            if (nowPlayer.playerInfo == Player.PLAYER_HUMAN && cppWrapper.GetEnumMove(boardclass) == 0)
            {
                // 画面再描画(前のCPUの手を画面に反映しておく)
                panel1.Invalidate(false);
                panel1.Update();

                m_sw.Stop();

                m_passCount++;

                if (m_passCount == 2 || cppWrapper.CountBit(~(boardclass.GetBlack() | boardclass.GetWhite())) == 0)
                {
                    // ゲーム終了
                    m_mode = ON_NOTHING;
                    m_cpuFlagProperty = false;
                    m_passCount = 0;
                    SetControlEnable(true);
                    // 結果表示
                    PrintResult();
                    // 画面描画
                    panel1.Invalidate(false);
                    panel1.Update();

                    return;
                }

                MessageBox.Show("プレイヤー" + (nowColor + 1) + "はパスです", "情報",
                MessageBoxButtons.OK, MessageBoxIcon.Information);
                m_sw.Start();

                // プレイヤー変更
                ChangePlayerReasonPass();
                // ゲームスレッドにCPU処理リクエスト送信
                gmt = new GameThread();
                object[] args = new object[] { GameThread.CMD_CPU, boardclass, cpuClass[nowColor], this };
                gmt.m_recvcmdProperty = args;
                m_sw.Restart();
                // 画面再描画
                panel1.Invalidate(false);
                panel1.Update();
                return;

            }

            // ここに来るのは次のプレイヤーが人間でかつ手を打てる状態
            m_cpuFlagProperty = false;
            m_passCount = 0;
            SetControlEnable(true);
            // 画面再描画
            panel1.Invalidate(false);
            panel1.Update();

        }