def prepare_extended_data_trickplay(game_data_dic, num_samples=1): played_cards = game_data_dic['played_cards'] player_hands = game_data_dic['player_hands'] card_sequences = [] aux_input_hands = [] cards_to_predict = [] # create num_samples different sequences from one game seq_lenghts = random.sample(range(27), num_samples) for seq_len in seq_lenghts: seq = played_cards[:seq_len] seq_encoded = enc.encode_played_cards( seq, next_rel_pos=played_cards[seq_len][1]) card_sequences.append(seq_encoded) next_player = played_cards[seq_len][1] pl_hand = player_hands[next_player] hand_enc = enc.encode_one_hot_hand(pl_hand) aux_input_hands.append(hand_enc) next_card = played_cards[seq_len][0] cards_to_predict.append(enc.encode_one_hot_card(next_card)) return card_sequences, aux_input_hands, cards_to_predict
def test_one_hot_card_encoding(): card = (SEVEN, HEARTS) encoded = np.zeros(32) encoded[1] = 1 card2 = (OBER, ACORNS) encoded2 = np.zeros(32) encoded2[19] = 1 card3 = (ACE, BELLS) encoded3 = np.zeros(32) encoded3[28] = 1 card4 = (NINE, LEAVES) encoded4 = np.zeros(32) encoded4[10] = 1 assert np.array_equal(enc.encode_one_hot_card(card), encoded) assert np.array_equal(enc.encode_one_hot_card(card2), encoded2) assert np.array_equal(enc.encode_one_hot_card(card3), encoded3) assert np.array_equal(enc.encode_one_hot_card(card4), encoded4) for suit in SUITS: for rank in RANKS: card = (rank, suit) assert enc.decode_one_hot_card( enc.encode_one_hot_card(card)) == card