コード例 #1
0
ファイル: Featurization.cs プロジェクト: shuyi3/AIPJ
        public static string FeaturizationToStringFlatten(Playfield pf)
        {
            BinaryFeature globalFeature = EncodeGlobal(pf);
            string        globalStr     = globalFeature.EncodeToStringFlatten();

            BinaryFeature boardFeature = encodeBoard(pf);
            string        boardStr     = boardFeature.EncodeToStringFlatten();

            BinaryFeature handFeature = encodeHand(pf);
            string        handStr     = handFeature.EncodeToStringFlatten();

            BinaryFeature playableFeature = encodePlay(pf);
            string        playStr         = playableFeature.EncodeToStringFlatten();

            return(globalStr + "|" + boardStr + "|" + handStr + "|" + playStr);
        }
コード例 #2
0
ファイル: Featurization.cs プロジェクト: shuyi3/AIPJ
        public static void NumpyFeaturization(Playfield pf, dynamic globalIdxArr, dynamic boardIdxArr, dynamic handIdxArr, dynamic playIdxArr)
        {
            Player mPlayer   = pf.getCurrentPlayer(true);
            Player ePlayer   = pf.getCurrentPlayer(false);
            int    ownMana   = mPlayer.ownMaxMana;
            int    enemyMana = ePlayer.ownMaxMana;
            int    ownHp     = mPlayer.ownHero.getHeroHpValue();
            int    enemyHp   = ePlayer.ownHero.getHeroHpValue();
            int    glbIdx    = 0;

            glbIdx += ownMana - 1;
            //globalIdxArr.itemset(glbIdx, 1);
            globalIdxArr.Append(FeatureConst.Instance.pyIntMap[glbIdx]);
            glbIdx = 10;
            if (!pf.isOwnTurn)
            {
                globalIdxArr.Append(FeatureConst.Instance.pyIntMap[glbIdx]);
            }
            int heroIdx = FeatureConst.Instance.heroHpDict[ownHp + enemyHp * 10];

            glbIdx += heroIdx;
            globalIdxArr.Append(FeatureConst.Instance.pyIntMap[glbIdx]);

            BinaryFeature boardFeature = encodeBoard(pf);

            boardFeature.FillIdxArr(boardIdxArr, 0);

            BinaryFeature handFeature = encodeHand(pf);
            //BinaryFeature DeckFeature = encodeDeck(pf);

            PyList dim1 = new PyList();
            PyList dim2 = new PyList();

            for (int i = 0; i < handFeature.data.Length; i++)
            {
                dim1.Append(FeatureConst.Instance.pyIntMap[handFeature.data[i]]);
                dim2.Append(FeatureConst.Instance.pyIntMap[i]);
            }

            //for (int i = 0; i < DeckFeature.data.Length; i++)
            //{
            //    dim1.Append(FeatureConst.Instance.pyIntMap[DeckFeature.data[i] + 9]);
            //    dim2.Append(FeatureConst.Instance.pyIntMap[i]);
            //}

            PythonUtils.AppendRecycle(handIdxArr, dim1);
            PythonUtils.AppendRecycle(handIdxArr, dim2);

            BinaryFeature playableFeature = encodePlay(pf);

            dim1 = new PyList();
            dim2 = new PyList();

            for (int i = 0; i < playableFeature.data.Length; i++)
            {
                if (playableFeature.data[i] > 0)
                {
                    dim1.Append(FeatureConst.Instance.pyIntMap[0]);
                    dim2.Append(FeatureConst.Instance.pyIntMap[i]);
                }
            }

            BinaryFeature playedFeature = encodePlayed(pf);

            for (int i = 0; i < playedFeature.data.Length; i++)
            {
                if (playedFeature.data[i] > 0)
                {
                    dim1.Append(FeatureConst.Instance.pyIntMap[1]);
                    dim2.Append(FeatureConst.Instance.pyIntMap[i]);
                }
            }
            PythonUtils.AppendRecycle(playIdxArr, dim1);
            PythonUtils.AppendRecycle(playIdxArr, dim2);
        }