Ejemplo n.º 1
0
    }// Update is called once per frame

    void Update()
    {
        if (!CpuInitialized)
        {
            record = GameObject.Find("GameManager").GetComponent <RecordOnline>();
            if (record.Initialized)
            {
                get();
                List <int> gravenum = new List <int>();
                foreach (int card in record.opensource())
                {
                    gravenum.Add(card % 13);
                }
                for (int num = 0; num < 13; num++)
                {
                    if (!gravenum.Contains(num))
                    {
                        blankmods.Add(num);
                    }
                }
                for (int i = 0; i < blankmods.Count; i++)
                {
                    PairChecked.Add(false);
                    blanklist4.Add(new List <List <int> >());
                    blanklist3.Add(new List <List <int> >());
                    InitBlankChaser(record.record, i);
                }
                CpuInitialized = true;
            }
        }
    }
Ejemplo n.º 2
0
    private void BlankChaser(List <int>[] rec, int blankindex)
    {
        get();
        int blankmod = blankmods[blankindex];
        //Debug.Log(blankmod);
        List <int> knownBlanks = new List <int>();
        List <int> deadBlanks  = new List <int>();

        foreach (int card in info)
        {
            if (card % 13 == blankmod)
            {
                knownBlanks.Add(info.IndexOf(card));                                                //opensourceにカードが出ていたら。
            }
        }
        foreach (int card in record.opensource())
        {
            if (card % 13 == blankmod)
            {
                deadBlanks.Add(info.IndexOf(card));
            }
        }

        if (deadBlanks.Count == 4)
        {
            return;                         //全部出てたらいらない←めっちゃいい
        }
        if (blanklist4[blankindex].Count != 0)
        {
            if (deadBlanks.Count == 2 && !PairChecked[blankindex]) //#blankmodがそろった
            {
                List <List <int> > tmplist2 = new List <List <int> >();
                foreach (List <int> kouho in blanklist4[blankindex])
                {
                    if (kouho.Contains(previousMovedCard) && kouho.Contains(previousDeletedCard))
                    {
                        tmplist2.Add(kouho);
                    }
                }
                blanklist4[blankindex]  = new List <List <int> >(tmplist2);
                PairChecked[blankindex] = true;
            }
            else
            {
                if (previousDeletedCard != -1) //#そろった
                {
                    List <List <int> > tmplist = new List <List <int> >();
                    //Debug.Log(blanklist4[blankindex].Count);
                    foreach (List <int> kouho in blanklist4[blankindex])
                    {
                        if (kouho.Contains(previousMovedCard) || kouho.Contains(previousDeletedCard))
                        {
                            tmplist.Add(kouho);
                        }
                    }
                    foreach (List <int> kouho in tmplist)
                    {
                        blanklist4[blankindex].Remove(kouho);
                    }
                    //Debug.Log(blanklist4[blankindex].Count);
                }
                else //#そろわず、移動したカードをpreviousMovedCardとして扱い移動する直前のhanduniformsをmotomotoとした
                {
                    List <int> motomoto = handUniforms[previousTurnPlayer];
                    motomoto.Remove(previousMovedCard);
                    //Debug.Log("そろわず");
                    if (!nonsuccessturn.Contains(rec[previousMovedCard][motomoto[0]]))
                    {
                        nonsuccessturn.Add(rec[previousMovedCard][motomoto[0]]);
                    }//turn番号の取得方法が分からなかったからとりあえず棋譜から読むことにした

                    if (previousTurnPlayer == playerNumber) /////comの番のとき
                    {
                        if (info[previousMovedCard] % 13 == blankmod) //引いたカードがブランクだったら
                        {
                            List <List <int> > tmplist = new List <List <int> >();
                            foreach (List <int> kouho in blanklist4[blankindex])
                            {
                                if (!kouho.Contains(previousMovedCard))
                                {
                                    tmplist.Add(kouho);
                                }
                            }
                            foreach (List <int> kouho in tmplist)
                            {
                                blanklist4[blankindex].Remove(kouho);
                            }
                        }
                        else
                        {
                            List <List <int> > tmplist = new List <List <int> >();
                            foreach (List <int> kouho in blanklist4[blankindex])
                            {
                                if (kouho.Contains(previousMovedCard))
                                {
                                    tmplist.Add(kouho);
                                }
                            }
                            foreach (List <int> kouho in tmplist)
                            {
                                blanklist4[blankindex].Remove(kouho);
                            }
                        }
                    }
                    else
                    {
                        List <List <int> > tmplist = new List <List <int> >();
                        //Debug.Log(blanklist4[blankindex].Count);
                        foreach (List <int> kouho in blanklist4[blankindex])
                        {
                            foreach (int uniform in motomoto)
                            {
                                if (kouho.Contains(previousMovedCard) && kouho.Contains(uniform))
                                {
                                    tmplist.Add(kouho);
                                }
                            }
                        }
                        foreach (List <int> kouho in tmplist)
                        {
                            blanklist4[blankindex].Remove(kouho);
                        }
                        //Debug.Log(blanklist4[blankindex].Count);
                    }
                }
            }
        }

        if (blanklist4[blankindex].Count == 0)                         //ziziかく
        {
            if (zizinumber == -1 || blanklist3[blankindex].Count == 0) //ziziかくの瞬間、publiczizizkakuしててもこっちに入れるようにした
            {
                string debug = playerNumber + "zizi確した!(数字)";
                Debug.Log(debug);
                zizinumber  = blankmod;
                zizikakunum = true;

                blistprivate[blankindex] = Blanklister(blistpublic, blankindex);
                //List<List<int>[]> blistprivate = new List<List<int>[]>();
                //blistprivate.Add(Blanklister(blistpublic, blankindex));

                int zeroPlayer = -1;
                for (int i = 0; i < 4; i++)
                {
                    if (blistprivate[blankindex][i].Count == 0)
                    {
                        zeroPlayer = i;                                                                 //ここちょっと怪しかったけどたぶんあってる
                    }
                }
                if (zeroPlayer != -1)
                {
                    Debug.Log("誰かのオリジナルすべて見てブランクなし");
                    List <int> playersTmp = new List <int> {
                        0, 1, 2, 3
                    };
                    playersTmp.Remove(zeroPlayer);
                    foreach (int j in blistprivate[blankindex][playersTmp[0]])
                    {
                        foreach (int k in blistprivate[blankindex][playersTmp[1]])
                        {
                            foreach (int l in blistprivate[blankindex][playersTmp[2]])
                            {
                                blanklist3[blankindex].Add(new List <int> {
                                    j, k, l
                                });
                            }
                        }
                    }
                    //Debug.Log(blanklist3[blankindex].Count + 1000);
                }
                else
                {
                    //4つから3つをえらばないといけない
                    Debug.Log("誰かのオリジナルをすべて見てはいない");
                    List <List <int> > playersTmp = new List <List <int> >();
                    for (int i = 0; i < 4; i++)
                    {
                        if (i != playerNumber)
                        {
                            List <int> tmp = new List <int> {
                                0, 1, 2, 3
                            };
                            tmp.Remove(i);
                            playersTmp.Add(tmp);
                        }
                    }
                    foreach (List <int> vs in playersTmp)
                    {
                        foreach (int j in blistprivate[blankindex][vs[0]])
                        {
                            foreach (int k in blistprivate[blankindex][vs[1]])
                            {
                                foreach (int l in blistprivate[blankindex][vs[2]])
                                {
                                    blanklist3[blankindex].Add(new List <int> {
                                        j, k, l
                                    });
                                }
                            }
                        }
                    }
                }

                Debug.Log(nonsuccessturn.Count + 0.1);
                //foreach (int b in nonsuccessturn) Debug.Log(b);
                //Debug.Log(nonsuccessturn[0]);

                List <List <int> > tmplist = new List <List <int> >();  //以下うまく消せてない模様....
                foreach (List <int> kouho in blanklist3[blankindex])
                {
                                                                    //下記のコメントアウトのようにではなく、共存したら(かつ揃わなかったら)消去するようにした
                    {
                        if (nonsuccessturn.Contains(rec[kouho[0]][kouho[1]]))
                        {
                            tmplist.Add(kouho); continue;
                        }
                        if (nonsuccessturn.Contains(rec[kouho[0]][kouho[2]]))
                        {
                            tmplist.Add(kouho); continue;
                        }
                        if (nonsuccessturn.Contains(rec[kouho[1]][kouho[2]]))
                        {
                            tmplist.Add(kouho); continue;
                        }
                    }
                }
                foreach (List <int> kouho in tmplist)
                {
                    blanklist3[blankindex].Remove(kouho);
                }
                //List<List<int>> tmplist = new List<List<int>>();
                //foreach (List<int> kouho in blanklist3[blankindex]) //////たぶん間違ってる
                //{
                //    if (rec[kouho[0]][kouho[1]] != -1) if (!knownBlanks.Contains(kouho[0]) || !knownBlanks.Contains(kouho[1])) { tmplist.Add(kouho); continue; }
                //    if (rec[kouho[0]][kouho[2]] != -1) if (!knownBlanks.Contains(kouho[0]) || !knownBlanks.Contains(kouho[2])) { tmplist.Add(kouho); continue; }
                //    if (rec[kouho[1]][kouho[2]] != -1) if (!knownBlanks.Contains(kouho[1]) || !knownBlanks.Contains(kouho[2])) { tmplist.Add(kouho); continue; }
                //}
                //foreach (List<int> kouho in tmplist) blanklist3[blankindex].Remove(kouho);


                //以下は雑に作った、もしかすると不要なものがあるかもしれない
                if (knownBlanks.Count == 1)
                {
                    Debug.Log("knownBlanks.Countが1");
                    List <List <int> > tmplist2 = new List <List <int> >();
                    foreach (List <int> kouho in blanklist3[blankindex])
                    {
                        if (!kouho.Contains(knownBlanks[0]))
                        {
                            tmplist2.Add(kouho); continue;
                        }
                    }
                    foreach (List <int> kouho in tmplist2)
                    {
                        blanklist3[blankindex].Remove(kouho);
                    }
                }
                if (knownBlanks.Count == 2)
                {
                    Debug.Log("knownBlanks.Countが2");
                    List <List <int> > tmplist2 = new List <List <int> >();
                    foreach (List <int> kouho in blanklist3[blankindex])
                    {
                        if (!kouho.Contains(knownBlanks[0]) || !kouho.Contains(knownBlanks[1]))
                        {
                            tmplist2.Add(kouho); continue;
                        }
                    }
                    foreach (List <int> kouho in tmplist2)
                    {
                        blanklist3[blankindex].Remove(kouho);
                    }
                }
                if (knownBlanks.Count == 3) //knownblanksで置き換えてしまった
                {
                    Debug.Log("knownBlanks.Countが3");
                    blanklist3[blankindex] = new List <List <int> > {
                        knownBlanks
                    };
                }
            }
            else
            {
                //Debug.Log("すでにzizi確");
                if (deadBlanks.Count == 2 && !PairChecked[blankindex]) //#blankmodがそろった
                {
                    List <List <int> > tmplist2 = new List <List <int> >();
                    foreach (List <int> kouho in blanklist3[blankindex])
                    {
                        if (kouho.Contains(previousMovedCard) && kouho.Contains(previousDeletedCard))
                        {
                            tmplist2.Add(kouho);
                        }
                    }
                    blanklist3[blankindex]  = new List <List <int> >(tmplist2);
                    PairChecked[blankindex] = true;
                }
                else
                {
                    if (previousDeletedCard != -1) //#そろった
                    {
                        List <List <int> > tmplist3 = new List <List <int> >();
                        //Debug.Log(blanklist3[blankindex].Count);
                        foreach (List <int> kouho in blanklist3[blankindex])
                        {
                            if (kouho.Contains(previousMovedCard) || kouho.Contains(previousDeletedCard))
                            {
                                tmplist3.Add(kouho);
                            }
                        }
                        foreach (List <int> kouho in tmplist3)
                        {
                            blanklist3[blankindex].Remove(kouho);
                        }
                        //Debug.Log(blanklist3[blankindex].Count);
                    }
                    else //#そろわず、移動したカードをpreviousMovedCardとして扱い移動する直前のhanduniformsをmotomotoとした
                    {
                        if (previousTurnPlayer == playerNumber) /////comの番のとき
                        {
                            if (info[previousMovedCard] % 13 == blankmod) //引いたカードがブランクだったら
                            {
                                List <List <int> > tmplist = new List <List <int> >();
                                foreach (List <int> kouho in blanklist3[blankindex])
                                {
                                    if (!kouho.Contains(previousMovedCard))
                                    {
                                        tmplist.Add(kouho);
                                    }
                                }
                                foreach (List <int> kouho in tmplist)
                                {
                                    blanklist3[blankindex].Remove(kouho);
                                }
                            }
                            else
                            {
                                List <List <int> > tmplist = new List <List <int> >();
                                foreach (List <int> kouho in blanklist3[blankindex])
                                {
                                    if (kouho.Contains(previousMovedCard))
                                    {
                                        tmplist.Add(kouho);
                                    }
                                }
                                foreach (List <int> kouho in tmplist)
                                {
                                    blanklist3[blankindex].Remove(kouho);
                                }
                            }
                        }
                        else
                        {
                            List <int> motomoto = handUniforms[previousTurnPlayer];
                            motomoto.Remove(previousMovedCard);
                            List <List <int> > tmplist3 = new List <List <int> >();
                            //Debug.Log(blanklist3[blankindex].Count);
                            foreach (List <int> kouho in blanklist3[blankindex])
                            {
                                foreach (int uniform in motomoto)
                                {
                                    if (kouho.Contains(previousMovedCard) && kouho.Contains(uniform))
                                    {
                                        tmplist3.Add(kouho);
                                    }
                                }
                            }
                            foreach (List <int> kouho in tmplist3)
                            {
                                blanklist3[blankindex].Remove(kouho);
                            }
                            //Debug.Log(blanklist3.Count);
                        }
                    }
                }
            }
        }

        if (blanklist4[blankindex].Count != 0)
        {
            Debug.Log(blanklist4[blankindex].Count + blankindex * 0.1 + playerNumber * 0.01 + 0.004);
        }
        else
        {
            Debug.Log(blanklist3[blankindex].Count + blankindex * 0.1 + playerNumber * 0.01 + 0.003);
            //if (blanklist3[blankindex].Count<5)
            //{
            //    foreach (List<int> a in blanklist3[blankindex])
            //    {
            //        foreach (int b in a) Debug.Log(b);
            //        Debug.Log("\n");
            //    }
            //}
        }
        //if (blanklist4[blankindex].Count<11)
        //{
        //foreach (List<int> a in blanklist4[blankindex])
        //{
        //foreach (int b in a) Debug.Log(b);
        //Debug.Log("\n");
        //}
        //}
    }
Ejemplo n.º 3
0
    private void BlankChaser(List <int>[] rec, int blankindex)
    {
        get();
        int        blankmod    = blankmods[blankindex];
        List <int> knownBlanks = new List <int>();
        List <int> deadBlanks  = new List <int>();

        foreach (int card in info)
        {
            if (card % 13 == blankmod)
            {
                knownBlanks.Add(info.IndexOf(card));                                                //opensourceにカードが出ていたら。
            }
        }
        foreach (int card in record.opensource())
        {
            if (card % 13 == blankmod)
            {
                deadBlanks.Add(info.IndexOf(card));
            }
        }
        //Debug.Log(knownBlanks.Count);
        if (deadBlanks.Count == 4)
        {
            return;                                                //全部出てたらいらない←めっちゃいい
        }
        if (blanklist4.Count != 0)                                 ////直感的にはこの部分特にRemoveで失敗してる気がする(blanklist4がうまく消せてない)
        {
            if (deadBlanks.Count == 2 && !PairChecked[blankindex]) //#blankmodがそろった(背番号match1とmatch2がそろった)
            {
                List <List <int> > tmplist2 = new List <List <int> >();
                foreach (List <int> kouho in blanklist4[blankindex])
                {
                    if (kouho.Contains(previousMovedCard) && kouho.Contains(previousDeletedCard))
                    {
                        tmplist2.Add(kouho);
                    }
                }
                blanklist4[blankindex]  = new List <List <int> >(tmplist2);
                PairChecked[blankindex] = true;
            }
            else
            {
                if (previousDeletedCard != -1) //#そろった
                {
                    List <List <int> > tmplist = new List <List <int> >();
                    //Debug.Log(blanklist4[blankindex].Count);
                    foreach (List <int> kouho in blanklist4[blankindex])
                    {
                        if (kouho.Contains(previousMovedCard) && kouho.Contains(previousDeletedCard))
                        {
                            tmplist.Add(kouho);
                        }
                    }
                    foreach (List <int> kouho in tmplist)
                    {
                        blanklist4[blankindex].Remove(kouho);
                    }
                    //Debug.Log(blanklist4[blankindex].Count);
                }
                else //#そろわず、移動したカードをmatch1として扱いmatch1が移動する直前のhanduniformsをmotomotとした→直前ではなく直後にした。→直前に直した
                {
                    List <int> motomoto = handUniforms[previousTurnPlayer];
                    motomoto.Remove(previousMovedCard);
                    List <List <int> > tmplist = new List <List <int> >();
                    //Debug.Log(blanklist4[blankindex].Count);
                    foreach (List <int> kouho in blanklist4[blankindex])
                    {
                        foreach (int uniform in motomoto)
                        {
                            if (kouho.Contains(previousMovedCard) && kouho.Contains(uniform))
                            {
                                tmplist.Add(kouho);
                            }
                        }
                    }
                    foreach (List <int> kouho in tmplist)
                    {
                        blanklist4[blankindex].Remove(kouho);
                    }
                    //Debug.Log(blanklist4[blankindex].Count);
                }
            }
        }

        if (blanklist4.Count == 0) //ziziかく
        {
            if (zizinumber == -1)  //ziziかくの瞬間
            {
                string debug = playerNumber + "じじ書く(2ターン目以降)";
                Debug.Log(debug);
                zizinumber  = blankmod;
                zizikakunum = true;
                blistprivate[blankindex] = Blanklister(blistpublic, blankindex);

                int zeroPlayer = -1;
                for (int i = 0; i < 4; i++)
                {
                    if (blistprivate[blankindex][i].Count == 0)
                    {
                        zeroPlayer = i;
                    }
                }
                if (zeroPlayer != -1)
                {
                    //以下は仮で1,2,3としている
                    List <int> playersTmp = new List <int> {
                        0, 1, 2, 3
                    };
                    playersTmp.Remove(zeroPlayer);
                    foreach (int j in blistprivate[blankindex][playersTmp[0]])
                    {
                        foreach (int k in blistprivate[blankindex][playersTmp[1]])
                        {
                            foreach (int l in blistprivate[blankindex][playersTmp[2]])
                            {
                                blanklist3[blankindex].Add(new List <int> {
                                    j, k, l
                                });
                            }
                        }
                    }
                }
                else
                {
                    //4つから3つをえらばないといけない仮で1,2,3としている、、かなり面倒
                    List <List <int> > playersTmp = new List <List <int> >();
                    for (int i = 0; i < 4; i++)
                    {
                        if (i != playerNumber)
                        {
                            List <int> tmp = new List <int> {
                                0, 1, 2, 3
                            };
                            tmp.Remove(i);
                            playersTmp.Add(tmp);
                        }
                    }
                    foreach (List <int> vs in playersTmp)
                    {
                        foreach (int j in blistprivate[blankindex][vs[0]])
                        {
                            foreach (int k in blistprivate[blankindex][vs[1]])
                            {
                                foreach (int l in blistprivate[blankindex][vs[2]])
                                {
                                    blanklist3[blankindex].Add(new List <int> {
                                        j, k, l
                                    });
                                }
                            }
                        }
                    }
                }

                List <List <int> > tmplist = new List <List <int> >();
                foreach (List <int> kouho in blanklist3[blankindex])
                {
                    if (rec[kouho[0]][kouho[1]] != -1)
                    {
                        if (!knownBlanks.Contains(kouho[0]) || !knownBlanks.Contains(kouho[1]))
                        {
                            tmplist.Add(kouho); continue;
                        }
                    }
                    if (rec[kouho[0]][kouho[2]] != -1)
                    {
                        if (!knownBlanks.Contains(kouho[0]) || !knownBlanks.Contains(kouho[2]))
                        {
                            tmplist.Add(kouho); continue;
                        }
                    }
                    if (rec[kouho[1]][kouho[2]] != -1)
                    {
                        if (!knownBlanks.Contains(kouho[1]) || !knownBlanks.Contains(kouho[2]))
                        {
                            tmplist.Add(kouho); continue;
                        }
                    }
                }
                foreach (List <int> kouho in tmplist)
                {
                    blanklist3[blankindex].Remove(kouho);
                }
            }
            else                                                       //#以前にziziかくしてた場合
            {
                if (deadBlanks.Count == 2 && !PairChecked[blankindex]) //#blankmodがそろった(背番号match1とmatch2がそろった)
                {
                    List <List <int> > tmplist2 = new List <List <int> >();
                    foreach (List <int> kouho in blanklist3[blankindex])
                    {
                        if (kouho.Contains(previousMovedCard) && kouho.Contains(previousDeletedCard))
                        {
                            tmplist2.Add(kouho);
                        }
                    }
                    blanklist3[blankindex]  = new List <List <int> >(tmplist2);
                    PairChecked[blankindex] = true;
                }
                else
                {
                    if (previousDeletedCard != -1) //#そろった
                    {
                        List <List <int> > tmplist3 = new List <List <int> >();
                        //Debug.Log(blanklist3[blankindex].Count);
                        foreach (List <int> kouho in blanklist3[blankindex])
                        {
                            if (kouho.Contains(previousMovedCard) && kouho.Contains(previousDeletedCard))
                            {
                                tmplist3.Add(kouho);
                            }
                        }
                        foreach (List <int> kouho in tmplist3)
                        {
                            blanklist3[blankindex].Remove(kouho);
                        }
                        //Debug.Log(blanklist3[blankindex].Count);
                    }
                    else //#そろわず、移動したカードをmatch1として扱いmatch1が移動する直前のhanduniformsをmotomotとした→直前ではなく直後にした。
                    {
                        List <int> motomoto = handUniforms[previousTurnPlayer];
                        motomoto.Remove(previousMovedCard);
                        List <List <int> > tmplist4 = new List <List <int> >();
                        //Debug.Log(blanklist3[blankindex].Count);
                        foreach (List <int> kouho in blanklist3[blankindex])
                        {
                            foreach (int uniform in motomoto)
                            {
                                if (kouho.Contains(previousMovedCard) && kouho.Contains(uniform))
                                {
                                    tmplist4.Add(kouho);
                                }
                            }
                        }
                        foreach (List <int> kouho in tmplist4)
                        {
                            blanklist3[blankindex].Remove(kouho);
                        }
                        //Debug.Log(blanklist3.Count);
                    }
                }
            }
        }
        //Debug.Log(blanklist4[blankindex].Count);
        //return; //どうする?
    }