public PyList getHandFeature(PlayerKeyInfo ownInfo, PlayerKeyInfo enemyInfo) { int[] featureArray = new int[cardArray.Length * 2]; foreach (PlayerKeyInfo.CardKeyInfo hc in ownInfo.handcardJsonList) { int idx = cardIdxDict[CardDB.Instance.cardNamestringToEnum(hc.cardName)]; featureArray[idx] = featureArray[idx] + 1; } foreach (PlayerKeyInfo.CardKeyInfo hc in enemyInfo.handcardJsonList) { int idx = cardIdxDict[CardDB.Instance.cardNamestringToEnum(hc.cardName)] + cardArray.Length; featureArray[idx] = featureArray[idx] + 1; } PyList hand_feature = new PyList(); foreach (int ft in featureArray) { PyInt num = new PyInt(ft); hand_feature.Append(num); num.Dispose(); } return(hand_feature); }
public PyList getHandFeature(Playfield p, bool own) { Player mPlayer, ePlayer; if (own) { mPlayer = p.playerFirst; ePlayer = p.playerSecond; } else { mPlayer = p.playerSecond; ePlayer = p.playerFirst; } int[] featureArray = new int[cardArray.Length * 2]; foreach (Handmanager.Handcard hc in mPlayer.owncards) { int idx = cardIdxDict[hc.card.name]; featureArray[idx] = featureArray[idx] + 1; } foreach (Handmanager.Handcard hc in ePlayer.owncards) { int idx = cardIdxDict[hc.card.name] + cardArray.Length; featureArray[idx] = featureArray[idx] + 1; } PyList hand_feature = new PyList(); foreach (int ft in featureArray) { PyInt num = new PyInt(ft); hand_feature.Append(num); num.Dispose(); } return(hand_feature); }
public dynamic parsePlayfieldCNN(Playfield p, bool own) { Player mPlayer, ePlayer; List <CardDB.Card> mDeck, eDeck; if (own) { mPlayer = p.playerFirst; ePlayer = p.playerSecond; mDeck = p.homeDeck; eDeck = p.awayDeck; } else { ePlayer = p.playerFirst; mPlayer = p.playerSecond; eDeck = p.homeDeck; mDeck = p.awayDeck; } PyInt ownMana = FeatureConst.Instance.pyIntMap[mPlayer.ownMaxMana]; PyInt ownHp = FeatureConst.Instance.pyIntMap[mPlayer.ownHero.Hp + mPlayer.ownHero.armor]; PyInt enemyMana = FeatureConst.Instance.pyIntMap[ePlayer.ownMaxMana]; PyInt enemyHp = FeatureConst.Instance.pyIntMap[ePlayer.ownHero.Hp + ePlayer.ownHero.armor]; PyList hero_feature = new PyList(new PyObject[] { ownMana, ownHp, enemyMana, enemyHp }); ownMana.Dispose(); ownHp.Dispose(); enemyMana.Dispose(); enemyHp.Dispose(); PyList own_hand_list = new PyList(); foreach (Handmanager.Handcard hc in mPlayer.owncards) { PyDict hand_card = new PyDict(); hand_card["cardName"] = new PyString(hc.card.name.ToString()); PythonUtils.AppendRecycle(own_hand_list, hand_card); } PyList enemy_hand_list = new PyList(); foreach (Handmanager.Handcard hc in ePlayer.owncards) { PyDict hand_card = new PyDict(); hand_card["cardName"] = new PyString(hc.card.name.ToString()); PythonUtils.AppendRecycle(enemy_hand_list, hand_card); } PyList own_minion_list = new PyList(); foreach (Minion m in mPlayer.ownMinions) { PyDict minion = new PyDict(); minion["Hp"] = FeatureConst.Instance.pyIntMap[m.Hp]; minion["Angr"] = FeatureConst.Instance.pyIntMap[m.Angr]; minion["name"] = new PyString(m.name.ToString()); PythonUtils.AppendRecycle(own_minion_list, minion); } PyList enemy_minion_list = new PyList(); foreach (Minion m in ePlayer.ownMinions) { PyDict minion = new PyDict(); minion["Hp"] = FeatureConst.Instance.pyIntMap[m.Hp]; minion["Angr"] = FeatureConst.Instance.pyIntMap[m.Angr]; minion["name"] = new PyString(m.name.ToString()); PythonUtils.AppendRecycle(enemy_minion_list, minion); } PyList own_deck_list = new PyList(); foreach (CardDB.Card c in mDeck) { PyString card_name = new PyString(c.name.ToString()); PythonUtils.AppendRecycle(own_deck_list, card_name); } PyList enemy_deck_list = new PyList(); foreach (CardDB.Card c in eDeck) { PyString card_name = new PyString(c.name.ToString()); PythonUtils.AppendRecycle(enemy_deck_list, card_name); } dynamic own_play_list = new PyList(); foreach (Action action in mPlayer.playactions) { if (action.actionType == actionEnum.playcard) { PyString card_name = new PyString(action.card.card.name.ToString()); PythonUtils.AppendRecycle(own_play_list, card_name); } } dynamic res_list = board_encoder.encode_for_cnn_phase(hero_feature, own_hand_list, own_minion_list, enemy_hand_list, enemy_minion_list, own_deck_list, enemy_deck_list, own_play_list); hero_feature.Dispose(); own_hand_list.Dispose(); own_minion_list.Dispose(); enemy_hand_list.Dispose(); enemy_minion_list.Dispose(); own_deck_list.Dispose(); enemy_deck_list.Dispose(); own_play_list.Dispose(); return(res_list); }