コード例 #1
0
        public void reset_stat(board a)
        {
            Board = a.tosimple();
            tree temp = boardtree.clone();

            temp.pieceidx   = boardtree.pieceidx;
            boardtree       = temp;
            boardtree.Board = Board.clone();
            extend_node();
        }
コード例 #2
0
        public void findalladd(Juraknifecore bot)
        {
            // 攻击力判定 + t旋只改场地分
            if (pieceidx >= bot.nextcnt)
            {
                return;
            }
            Tuple <int, int> res;

            this.nowpiece = bot.nextqueue[pieceidx % 30];
            isextend      = true;
            inplan        = false;
            Board.piece   = defaultop.demino.getmino(nowpiece);
            Board.piece.setpos(19, 3);
            List <mino> allpos   = seacher.findallplace(Board);
            int         chirdidx = pieceidx + 1;

            if (allpos == null)
            {
                tree chird = clone(); chird.isdead = true; chird.pieceidx = chirdidx; chird.inplan = false; chird.isextend = true; treenode.Add(chird); return;
            }
            ;
            foreach (mino m in allpos)
            {
                // 场外死亡判断
                tree chird = clone();
                chird.Board.piece = m;

                res                = lock_piece_calc(ref chird.Board);
                chird.attack       = chird.maxattack = res.Item1;
                chird.def          = chird.maxdef = res.Item1 + res.Item2; // 已经消除了 还能叫防御吗
                chird.finmino      = m;
                chird.father       = this;
                chird.ishold       = false;
                chird.isdead       = false;
                chird.holdpiece    = holdpiece;
                chird.pieceidx     = chirdidx;
                chird.depth        = depth + 1;
                chird.maxdepth     = chird.depth;
                chird.maxdepth     = chird.pieceidx;
                chird.inplan       = true;
                chird.res          = bot.evalweight.evalfield(chird);
                chird.fieldscore   = (int)chird.res.score;
                chird.battlescore += bot.evalweight.evalbattle(chird); // 相同的不要反复判了
                chird.movescore    = bot.evalweight.evalmove(chird);   // 相同的不要反复判了
                chird.atkscore     = bot.evalweight.evalatkdef(chird); // 相同的不要反复判了
                if (true || chird.holdT || hasnextT(bot, chirdidx))    // 当前块是t的时候
                {
                    tree Tchird1 = chird.clone();
                    Tchird1.Board.piece = defaultop.demino.getmino(2);
                    Tchird1.Board.piece.setpos(19, 3);
                    List <mino> Alltslot = search_tspin.findalltslot(Tchird1.Board); // 修改  /// 我是把tspin后的状态 提前压回该节点
                    if (Alltslot.Count != 0)
                    {
                        //List<mino> Alltslot = search_tspin.findalltslot(chird.Board);
                        tree bestT;
                        long minscore = chird.fieldscore;

                        foreach (mino t in Alltslot) // 超过一个 干掉
                        {
                            if (!t.Tspin)
                            {
                                continue;
                            }
                            tree Tchird = chird.clone();
                            Tchird.Board.piece = t;
                            Tchird.finmino     = t;
                            res = lock_piece_calc(ref Tchird.Board);

                            if (!t.mini)
                            {
                                Tchird.fieldscore  = bot.evalweight.evalfield(Tchird).score;
                                Tchird.fieldscore += bot.evalweight.W.tslot[res.Item2];
                            }
                            else
                            {
                                Tchird.fieldscore = chird.fieldscore + bot.evalweight.W.tslot[4];
                            }
                            //Tchird.score += bot.evalweight.evalbattle(Tchird); // 是否要battle也加上 // 其他节点借用了这个t的分值? 需不需要加入t坑评分
                            // 攻击也需要
                            if (Tchird.fieldscore > minscore && Tchird.Board.piece.Tspin)
                            {
                                minscore = Tchird.fieldscore;
                                bestT    = Tchird;
                            }
                        }
                        chird.fieldscore = minscore;
                    }
                }

                // 回传父节点

                chird.updatefather(); // check update
                treenode.Add(chird);
            }

            if (holdpiece == -1)
            {
                int holdidx = pieceidx + 1, nextnext = pieceidx + 2;

                if (holdidx < bot.nextcnt)
                {
                    // 保持连击的加分 // 防御是否应该削去
                    // 防御是给没打出攻击时才有的
                    // combo应该是个可延续状态

                    // 问题 特别喜欢打t1
                    // 不喜欢留防御

                    // todo T比较近的时候就可以开搜
                    // 优化

                    // 多next看t
                    // 为什么不喜欢堆防御

                    // keepcombo的 def
                    // 子节点也要前面的攻击
                    // 软降优化

                    // 扩展被选中的节点的所有子节点

                    // 需要参与排序的有 自身场地状态 从根到该节点所打出的攻击总数 该点的攻击,该点开始保持连击打出的最大防御数 路径总数(? 浪费t总数(这个不确定
                    //

                    Board.piece = defaultop.demino.getmino(bot.nextqueue[holdidx % 30]);
                    Board.piece.setpos(19, 3);
                    List <mino> allpos2 = seacher.findallplace(Board);
                    foreach (mino m in allpos2)
                    {
                        tree chird = clone();
                        chird.Board.piece = m;
                        res                = lock_piece_calc(ref chird.Board);
                        chird.attack       = chird.maxattack = res.Item1;
                        chird.def          = chird.maxdef = res.Item1 + res.Item2; // 已经消除了 还能叫防御吗
                        chird.finmino      = m;
                        chird.isdead       = false;
                        chird.ishold       = true;
                        chird.holdpiece    = nowpiece;
                        chird.father       = this;
                        chird.pieceidx     = nextnext;
                        chird.depth        = depth + 1;
                        chird.maxdepth     = chird.pieceidx;
                        chird.inplan       = true;
                        chird.res          = bot.evalweight.evalfield(chird);
                        chird.fieldscore   = (int)chird.res.score;
                        chird.battlescore += bot.evalweight.evalbattle(chird); // 作为攻击回传
                        chird.movescore    = bot.evalweight.evalmove(chird);   // 相同的不要反复判了
                        chird.atkscore     = bot.evalweight.evalatkdef(chird); // 相同的不要反复判了
                        if (true || chird.holdT || hasnextT(bot, nextnext))
                        {
                            tree Tchird1 = chird.clone();
                            Tchird1.Board.piece = defaultop.demino.getmino(2);
                            Tchird1.Board.piece.setpos(19, 3);
                            List <mino> Alltslot = search_tspin.findalltslot(Tchird1.Board);
                            //List<mino> Alltslot = search_tspin.findalltslot(chird.Board);
                            if (Alltslot.Count != 0)
                            {
                                tree bestT;
                                long minscore = chird.fieldscore;
                                foreach (mino t in Alltslot)
                                {
                                    if (!t.Tspin)
                                    {
                                        continue;
                                    }
                                    tree Tchird = chird.clone();
                                    Tchird.Board.piece = t;
                                    Tchird.finmino     = t;
                                    res = lock_piece_calc(ref Tchird.Board); // 作为防御回传

                                    Tchird.fieldscore = bot.evalweight.evalfield(Tchird).score;

                                    //Tchird.score += bot.evalweight.evalbattle(Tchird); // 是否要battle也加上
                                    if (!t.mini)
                                    {
                                        Tchird.fieldscore  = bot.evalweight.evalfield(Tchird).score;
                                        Tchird.fieldscore += bot.evalweight.W.tslot[res.Item2];
                                    }
                                    else
                                    {
                                        Tchird.fieldscore = chird.fieldscore + bot.evalweight.W.tslot[4];
                                    }
                                    if (Tchird.fieldscore > minscore && Tchird.Board.piece.Tspin)
                                    {
                                        minscore = Tchird.fieldscore;
                                        bestT    = Tchird;
                                    }
                                }
                                chird.fieldscore = minscore;
                            }
                        }
                        chird.updatefather();
                        // 回传父节点
                        treenode.Add(chird);
                    }
                    // 回传父节点
                }
            }
            else
            {
                int temp = nowpiece;
                nowpiece    = holdpiece;
                Board.piece = defaultop.demino.getmino(nowpiece);
                Board.piece.setpos(19, 3);
                List <mino> allpos1 = seacher.findallplace(Board);
                // 先对相对有用的节点更新
                foreach (mino m in allpos1)
                {
                    tree chird = clone();
                    chird.Board.piece = m;
                    res                = lock_piece_calc(ref chird.Board);
                    chird.attack       = chird.maxattack = res.Item1;
                    chird.def          = chird.maxdef = res.Item1 + res.Item2; // 已经消除了 还能叫防御吗
                    chird.finmino      = m;
                    chird.isdead       = false;
                    chird.ishold       = true;
                    chird.holdpiece    = temp; // oops
                    chird.pieceidx     = chirdidx;
                    chird.father       = this;
                    chird.depth        = depth + 1;
                    chird.maxdepth     = chird.depth;
                    chird.maxdepth     = chird.pieceidx;
                    chird.inplan       = true;
                    chird.res          = bot.evalweight.evalfield(chird);
                    chird.fieldscore   = (int)chird.res.score;
                    chird.battlescore += bot.evalweight.evalbattle(chird);
                    chird.movescore    = bot.evalweight.evalmove(chird);   // 相同的不要反复判了
                    chird.atkscore     = bot.evalweight.evalatkdef(chird); // 相同的不要反复判了
                    if (true || chird.holdT || hasnextT(bot, chirdidx))
                    {
                        tree Tchird1 = chird.clone();
                        Tchird1.Board.piece = defaultop.demino.getmino(2);
                        Tchird1.Board.piece.setpos(19, 3);
                        List <mino> Alltslot = search_tspin.findalltslot(Tchird1.Board);
                        //List<mino> Alltslot = search_tspin.findalltslot(chird.Board);
                        if (Alltslot.Count != 0)
                        {
                            tree bestT;
                            long minscore = chird.fieldscore;
                            foreach (mino t in Alltslot)
                            {
                                if (!t.Tspin)
                                {
                                    continue;           // 相同场地不要去 有些无用场地需要吗
                                }
                                tree Tchird = chird.clone();
                                Tchird.Board.piece = t;
                                Tchird.finmino     = t;
                                res = lock_piece_calc(ref Tchird.Board);
                                Tchird.fieldscore = bot.evalweight.evalfield(Tchird).score;
                                //Tchird.battlescore += bot.evalweight.evalbattle(Tchird); // 是否要battle也加上
                                if (!t.mini)
                                {
                                    Tchird.fieldscore  = bot.evalweight.evalfield(Tchird).score;
                                    Tchird.fieldscore += bot.evalweight.W.tslot[res.Item2];
                                }
                                else
                                {
                                    Tchird.fieldscore = chird.fieldscore + bot.evalweight.W.tslot[4];
                                }
                                if (Tchird.fieldscore > minscore && Tchird.Board.piece.Tspin) // 可以优化计算顺序
                                {
                                    minscore = Tchird.fieldscore;
                                    bestT    = Tchird;
                                }
                            }
                            chird.fieldscore = minscore;
                        }
                    }
                    chird.updatefather();
                    // 回传父节点
                    treenode.Add(chird);
                }
            }
        }