예제 #1
0
def suit_permutations_hands_sw(declaring_player, game_mode, player_hands):
    data_list = []
    # augment by getting all suit permutations via three transpositions
    # first cycle through all possible game_suits
    for new_game_suit in SUITS:
        new_player_hands = switch_suits_player_hands(player_hands,
                                                     game_mode[1],
                                                     new_game_suit)
        new_game_mode = (PARTNER_MODE, new_game_suit)
        other_suits = [s for s in SUITS if s != new_game_suit]
        first_suit = other_suits[0]
        # then permutations of 3 remaining elements again by two permutations
        for sec_suit in other_suits:
            new_player_hands = switch_suits_player_hands(
                new_player_hands, sec_suit, first_suit)
            remaining_suits = [s for s in other_suits if s != first_suit]
            for third_suit in remaining_suits:
                new_player_hands = switch_suits_player_hands(
                    new_player_hands, sec_suit, third_suit)
                # now create trainings examples from switched hands
                for hand, player_pos in zip(new_player_hands,
                                            range(len(player_hands))):
                    x, y = create_bidding_example(declaring_player,
                                                  new_game_mode, hand,
                                                  player_pos)
                    data_list.append((x, y))
    return data_list
def transform_solo(data_dic):
    declaring_player = data_dic['declaring_player']
    game_suit = data_dic['game_mode'][1]
    # switch suits to HEARTS if necessary
    if game_suit != HEARTS:
        played_cards = switch_suits_played_cards(data_dic['played_cards'],
                                                 game_suit, HEARTS)
        player_hands = switch_suits_player_hands(data_dic['player_hands'],
                                                 game_suit, HEARTS)
    else:
        played_cards = data_dic['played_cards']
        player_hands = data_dic['player_hands']
    # set offensive player as player 0, and all relative positions accordingly
    played_cards = [(card, (player - declaring_player) % 4)
                    for card, player in played_cards]
    # change player hand cards accordingly

    player_hands = [
        player_hands[(index + declaring_player) % 4] for index in range(4)
    ]
    transformed_dic = {
        'player_hands': player_hands,
        'played_cards': played_cards
    }
    return transformed_dic
예제 #3
0
def suit_permutations_hands_partner(declaring_player, game_mode, player_hands):
    data_list = []
    # augment by getting all suit permutations via two transpositions
    # first cycle through all possible game_suits
    for new_game_suit in [BELLS, LEAVES, ACORNS]:
        new_player_hands = switch_suits_player_hands(player_hands,
                                                     game_mode[1],
                                                     new_game_suit)
        new_game_mode = (PARTNER_MODE, new_game_suit)
        other_suits = [
            s for s in [BELLS, LEAVES, ACORNS] if s != new_game_suit
        ]
        first_suit = other_suits[0]
        # then both permutations of the remaining two suits
        for sec_suit in other_suits:
            new_player_hands = switch_suits_player_hands(
                new_player_hands, first_suit, sec_suit)
            # now create trainingsexamples from switched hands
            for hand, player_pos in zip(new_player_hands,
                                        range(len(player_hands))):
                x, y = create_bidding_example(declaring_player, new_game_mode,
                                              hand, player_pos)
                data_list.append((x, y))
    return data_list