예제 #1
0
        /**
         * 盤面の着手処理を行います
         */
        public bool move(int pos)
        {
            UInt64 rev;
            CppWrapper cppWrapper = new CppWrapper();

            black = GetBlack();
            white = GetWhite();

            if (nowColor == BoardClass.BLACK)
            {
                rev = cppWrapper.GetBoardChangeInfo(black, white, pos);

                if (rev == 0)
                {
                    return false;
                }

                black ^= ((1UL << pos) | rev);
                white ^= rev;
            }
            else
            {
                rev = cppWrapper.GetBoardChangeInfo(white, black, pos);

                if (rev == 0)
                {
                    return false;
                }

                white ^= ((1UL << pos) | rev);
                black ^= rev;
            }

            // 着手リスト更新
            boardList.Add(new ulong[] { black, white });
            moveList.Add(new int[] { (int)nowColor, pos });

            nowTurn++;
            nowColor ^= 1;

            return true;

        }
예제 #2
0
 public GameThread()
 {
     cpw = new CppWrapper();
     m_abort = false;
 }
예제 #3
0
        private void HintThreadFunc(object args)
        {
            object[] argsarray = (object[])args;
            BoardClass board = (BoardClass)argsarray[1];
            CpuClass cpuClass = (CpuClass)argsarray[2];
            Form1 formobj = (Form1)argsarray[3];
            uint level = (uint)argsarray[4];
            int ret = 0;

            CppWrapper cpw = new CppWrapper();

            // 着手可能リスト取得
            ulong moves = cpw.GetEnumMove(board);
            // 現在のCPUの設定を取得
            CpuConfig cpuConfig = SetCpuConfig(cpuClass);
            // BOOK禁止
            cpuConfig.bookFlag = false;

            ulong bk = board.GetBlack();
            ulong wh = board.GetWhite();

            HintClass hintData = new HintClass();

            // 空きマス数
            int empty = cpw.CountBit(~(bk | wh));

            // CPU設定
            cpuConfig.color = board.GetColor();
            cpuConfig.winLossDepth = dcTable[level - 1];
            cpuConfig.exactDepth = dcTable[level - 1] - 2;

            if (cpuConfig.exactDepth >= empty)
            {
                // WLDとEXACTの前にある程度の探索を行うため0で初期化
                cpuConfig.exactDepth = 0;
                cpuConfig.winLossDepth = 0;
                hintData.SetAttr(HintClass.SOLVE_MIDDLE);
                // 反復深化探索(level - 8)
                for (int i = 0; i < level / 2; i++)
                {
                    cpuConfig.searchDepth = (uint)i * 2 + 2;
                    // 着手可能マスに対してそれぞれ評価値を計算
                    ret = doSearch(bk, wh, cpuConfig, moves, formobj, hintData);
                    if (ret == -1) break;
                    // UIに反復x回目終了を通知
                    hintData.SetPos(64);
                    ((Form1)formobj).Invoke(((Form1)formobj).hintDelegate, new object[] { hintData });
                }

                if (ret == 0)
                {
                    hintData.SetAttr(HintClass.SOLVE_EXCAT);
                    cpuConfig.exactDepth = dcTable[level - 1] - 2;
                    // 着手可能マスに対してそれぞれ評価値を計算
                    ret = doSearch(bk, wh, cpuConfig, moves, formobj, hintData);
                }
            }
            else if (cpuConfig.winLossDepth >= empty)
            {
                cpuConfig.exactDepth = 0;
                cpuConfig.winLossDepth = 0;
                hintData.SetAttr(HintClass.SOLVE_MIDDLE);
                // 反復深化探索(level - 8)
                for (int i = 0; i < level / 2; i++)
                {
                    cpuConfig.searchDepth = (uint)i * 2 + 2;
                    // 着手可能マスに対してそれぞれ評価値を計算
                    ret = doSearch(bk, wh, cpuConfig, moves, formobj, hintData);
                    if (ret == -1) break;
                    // UIに反復x回目終了を通知
                    hintData.SetPos(64);
                    ((Form1)formobj).Invoke(((Form1)formobj).hintDelegate, new object[] { hintData });
                }
                if (ret == 0)
                {
                    hintData.SetAttr(HintClass.SOLVE_WLD);
                    cpuConfig.winLossDepth = dcTable[level - 1];
                    // 着手可能マスに対してそれぞれ評価値を計算
                    ret = doSearch(bk, wh, cpuConfig, moves, formobj, hintData);
                }
            }
            else
            {
                hintData.SetAttr(HintClass.SOLVE_MIDDLE);
                // 反復深化探索
                for (int i = 0; i < level && i <= empty; i++)
                {
                    cpuConfig.searchDepth = (uint)i * 2 + 2;
                    // 着手可能マスに対してそれぞれ評価値を計算
                    ret = doSearch(bk, wh, cpuConfig, moves, formobj, hintData);
                    if (ret == -1) break;
                    // UIに反復x回目終了を通知
                    hintData.SetPos(64);
                    ((Form1)formobj).Invoke(((Form1)formobj).hintDelegate, new object[] { hintData });
                }
            }

            // UIに探索終了を通知
            ((Form1)formobj).Invoke(((Form1)formobj).hintDelegate, new object[] { null });
        }