Exemplo n.º 1
0
 def play(self, game_knowledge):
     plate_ = extract_current_plate(game_knowledge)
     hand_ = extract_current_hand(game_knowledge)
     if has_chopsticks_in_plate(plate_) and len(hand_) >= 2:
         return [0, 1]
     first_chopsticks_index = find_first_chopsticks_index(hand_)
     if first_chopsticks_index is not None:
         return [first_chopsticks_index]
     return [0]
Exemplo n.º 2
0
 def play(self, game_knowledge) -> list:
     evaluations_list = self.evaluate_hand(extract_current_hand(game_knowledge))
     best_card_index = int(argmax(evaluations_list))
     if has_chopsticks_in_plate(extract_current_plate(game_knowledge)) and len(evaluations_list) >= 2:
         second_best_index = int(argmax(
             evaluations_list[0:best_card_index] + evaluations_list[best_card_index + 1: len(evaluations_list)]))
         if second_best_index >= best_card_index:
             second_best_index += 1
         return [best_card_index, second_best_index]
     return [best_card_index]
Exemplo n.º 3
0
def estimate_card_in_other_hands(game_knowledge, desired_card: Cards):
    unseen_cards_in_deck = count_unseen_cards_in_deck(game_knowledge)
    unseen_cards_in_round = count_unseen_cards_in_round(game_knowledge)
    amount_in_hand = count_card_occurrences(
        extract_current_hand(game_knowledge), desired_card)
    observed_instances = count_observed_instances(game_knowledge, desired_card)
    chance_of_single_appearance = (card_quantities[desired_card] -
                                   observed_instances) / unseen_cards_in_deck
    return max(0, amount_in_hand - observed_instances \
                  + (unseen_cards_in_round * chance_of_single_appearance))
Exemplo n.º 4
0
def calculate_future_nigiri_expectancy(game_knowledge):
    nigiri_expectations = []
    for nigiri in [Cards.Nigiri1, Cards.Nigiri2, Cards.Nigiri3]:
        estimation_for_other_hands = estimate_card_in_other_hands(
            game_knowledge, nigiri)
        amount_in_hand = count_card_occurrences(
            extract_current_hand(game_knowledge), nigiri)
        chance_of_reciving = min(
            (estimation_for_other_hands + amount_in_hand) *
            calculate_chances_of_revisiting(game_knowledge, nigiri), 1)
        nigiri_expectations += [
            3 * card_apriori_values[nigiri] * chance_of_reciving
        ]
    return max(nigiri_expectations)
Exemplo n.º 5
0
def chances_of_completing_set(game_knowledge, card_of_set: Cards):
    estimation_for_other_hands = estimate_card_in_other_hands(
        game_knowledge, card_of_set)
    amount_in_hand = count_card_occurrences(
        extract_current_hand(game_knowledge), card_of_set)
    amount_taken_right_now = (1 if amount_in_hand >= 1 else 0)
    card_set_size = 3 if card_of_set == Cards.Sashimi else 2
    missing_picks = card_set_size \
                    - count_card_occurrences(extract_current_plate(game_knowledge), card_of_set) % card_set_size \
                    - amount_taken_right_now
    future_occurances = (amount_in_hand - amount_taken_right_now) \
                        + estimation_for_other_hands * (
                            calculate_chances_of_revisiting(game_knowledge, card_of_set))
    return 1 if missing_picks == 0 \
        else 0 if future_occurances < missing_picks \
        else future_occurances / missing_picks
Exemplo n.º 6
0
def evaluate_dumplings(game_knowledge):
    estimation_for_other_hands = estimate_card_in_other_hands(
        game_knowledge, Cards.Dumpling)
    amount_in_hand = count_card_occurrences(
        extract_current_hand(game_knowledge), Cards.Dumpling)
    dumpling_taken_now = 1 if amount_in_hand > 0 else 0
    estimated_dumpling_grab = max(
        1,
        int(dumpling_taken_now + (estimation_for_other_hands + amount_in_hand -
                                  dumpling_taken_now) *
            chance_of_opponent_to_spare[Cards.Dumpling]))
    expected_plate = extract_current_plate(game_knowledge) + \
                     ([Cards.Dumpling] * estimated_dumpling_grab)
    return min(
        3.0,
        get_player_score_from_dumplings(expected_plate) /
        estimated_dumpling_grab) + 0.1
Exemplo n.º 7
0
def count_observed_instances(game_knowledge, desired_card: Cards):
    return sum([isCardOfType(card, desired_card) for card in extract_current_hand(game_knowledge)]) \
           + sum(
        [sum([isCardOfType(card, desired_card) for card in plate]
        ) for plate in extract_latest_plates(game_knowledge)])