Exemple #1
0
        public static BinaryFeature encodeDeck(Playfield pf)
        {
            List <CardDB.Card> mDeck, eDeck;

            if (pf.isOwnTurn)
            {
                mDeck = pf.homeDeck;
                eDeck = pf.awayDeck;
            }
            else
            {
                eDeck = pf.homeDeck;
                mDeck = pf.awayDeck;
            }

            BinaryFeature ret = new TwoDBinaryFeature(FeatureConst.Instance.cardArray.Length);

            foreach (CardDB.Card card in mDeck)
            {
                int idx = FeatureConst.Instance.cardIdxDict[card.name];
                ret.data[idx]++;
            }

            foreach (CardDB.Card card in eDeck)
            {
                int idx = FeatureConst.Instance.cardIdxDict[card.name];
                ret.data[idx] += 10;
            }

            for (int i = 0; i < ret.data.Length; i++)
            {
                ret.data[i] = FeatureConst.Instance.countDict[ret.data[i]];
            }

            return(ret);
        }
Exemple #2
0
        public static BinaryFeature encodeHand(Playfield pf)
        {
            /*
             *  hand_length = 23
             *  hand = np.clip(own_hand, 0, 2) * 10 + np.clip(enemy_hand, 0, 2)
             *  hand = hand.reshape(-1, 1)
             *
             # print (np.unique(hand))
             #
             #  hand = np.select(
             #      [hand == 2,
             #       hand == 1,
             #       hand == 12,
             #       hand == 0,
             #       hand == 11,
             #       hand == 22,
             #       hand == 21,
             #       hand == 10,
             #       hand == 20],
             #      [np.array([1, 0, 0, 0, 0, 0, 0, 0, 0]),
             #       np.array([0, 1, 0, 0, 0, 0, 0, 0, 0]),
             #       np.array([0, 0, 1, 0, 0, 0, 0, 0, 0]),
             #       np.array([0, 0, 0, 1, 0, 0, 0, 0, 0]),
             #       np.array([0, 0, 0, 0, 1, 0, 0, 0, 0]),
             #       np.array([0, 0, 0, 0, 0, 1, 0, 0, 0]),
             #       np.array([0, 0, 0, 0, 0, 0, 1, 0, 0]),
             #       np.array([0, 0, 0, 0, 0, 0, 0, 1, 0]),
             #       np.array([0, 0, 0, 0, 0, 0, 0, 0, 1])
             #       ])
             #
             #  one_hot_length = 9
             #  hand_feature = hand.reshape(-1, hand_length, one_hot_length)
             #
             #  hand_feature = np.rollaxis(hand_feature, 2, 1)
             */

            Player mPlayer = pf.getCurrentPlayer(true);
            Player ePlayer = pf.getCurrentPlayer(false);

            BinaryFeature ret = new TwoDBinaryFeature(FeatureConst.Instance.cardArray.Length);

            foreach (Handmanager.Handcard hc in mPlayer.owncards)
            {
                int idx = FeatureConst.Instance.cardIdxDict[hc.card.name];
                if (ret.data[idx] < 2)
                {
                    ret.data[idx]++;
                }
            }

            foreach (Handmanager.Handcard hc in ePlayer.owncards)
            {
                int idx = FeatureConst.Instance.cardIdxDict[hc.card.name];
                if (ret.data[idx] < 20)
                {
                    ret.data[idx] += 10;
                }
            }

            for (int i = 0; i < ret.data.Length; i++)
            {
                ret.data[i] = FeatureConst.Instance.countDict[ret.data[i]];
            }

            return(ret);
        }