Exemplo n.º 1
0
def choice_11(g, p):
    if g.info_tokens >= 1:
        for next_turn in range(4, len(g.players)):
            next_player = g.players[(g.players.index(p) + next_turn) %
                                    len(g.players)]
            next_player_deck = next_player.deck
            for c in next_player_deck:
                if (c.value == g.fireworks[c.color] +
                        1) and (c.color_info == "") and (c.value_info == 10):
                    info = info_to_give(next_player_deck, c)
                    if info == "color":
                        if unseen_information(g, next_player, c, 'color'):
                            give_info(g, next_player, 'color', c.color)
                            return True
                    elif info == "value":
                        if unseen_information(g, next_player, c, 'value'):
                            give_info(g, next_player, 'value', c.value)
                            return True
    return False
Exemplo n.º 2
0
def choice_3(g, p):
    if g.info_tokens >= 1:
        next_turn = 2
        next_player = g.players[(g.players.index(p) + next_turn) %
                                len(g.players)]
        next_player_deck = next_player.deck
        recurrent_value = several_playable_cards(g, next_player_deck)
        if recurrent_value != 0:
            good_info = True
            for c in next_player_deck:
                if (c.value == recurrent_value) and (c.color_info
                                                     == "") and (c.value_info
                                                                 == 10):
                    if (not (unseen_information(g, next_player, c, 'value'))
                        ) or (not (unseen_information(
                            g, next_player, c,
                            'color'))) or (c.value < g.fireworks[c.color] + 1):
                        good_info = False
            if good_info:
                give_info(g, next_player, 'value', recurrent_value)
                return True
    return False
Exemplo n.º 3
0
def choice_7(g, p):
    if g.info_tokens >= 1:
        next_turn = 3
        player_before_next = g.players[(g.players.index(p) + next_turn - 1) %
                                       len(g.players)]
        next_player = g.players[(g.players.index(p) + next_turn) %
                                len(g.players)]
        next_player_deck = next_player.deck
        for c in next_player_deck:
            if (c.value == g.fireworks[c.color] + 2) and (
                    c.color_info
                    == "") and (c.value_info == 10) and info_given_to_player(
                        player_before_next, c.color, g.fireworks[c.color] + 1):
                info = info_to_give(next_player_deck, c)
                if info == "color":
                    if unseen_information(g, next_player, c, 'color'):
                        give_info(g, next_player, 'color', c.color)
                        return True
                elif info == "value":
                    if unseen_information(g, next_player, c, 'value'):
                        give_info(g, next_player, 'value', c.value)
                        return True
    return False
Exemplo n.º 4
0
def simple_rules(g, p):
    # play a card if the information on it is known and can be played
    # discard it if the card is useless
    for c in p.deck:
        if (c.color_info != "") and (c.value_info != 10):
            if c.value == g.fireworks[c.color_info] + 1:
                play_card(g, p, c)
                return
    for c in p.deck:
        if (c.color_info != "") and (c.value_info != 10):
            if c.value_info <= g.fireworks[c.color_info]:
                discard(g, p, c)
                return
            elif c.value_info == g.fireworks[c.color_info] + 1:
                play_card(g, p, c)
                return
        elif c.color_info != "":
            if (g.fireworks[c.color_info] == 5) or (color_lost(g, c.color)):
                discard(g, p, c)
                return
            else:
                play_card(g, p, c)
                return
        elif c.value_info != 10:
            if (c.value_info < 5) and (c.value_info <= min(
                    g.fireworks.values())):
                discard(g, p, c)
                return
            elif (c.value_info < 5) and (c.value_info <=
                                         max(g.fireworks.values()) + 1):
                play_card(g, p, c)
                return

    # give the information if a player among the 2 nexts has 2 playable cards
    if g.info_tokens >= 1:
        for next_turn in [1, 2]:
            next_player = g.players[(g.players.index(p) + next_turn) %
                                    len(g.players)]
            next_player_deck = next_player.deck
            if not (too_much_information(next_player_deck)):
                recurrent_value = several_playable_cards(g, next_player_deck)
                if recurrent_value != 0:
                    good_info = True
                    for c in next_player_deck:
                        if (c.value == recurrent_value) and (
                                c.color_info == "") and (c.value_info == 10):
                            if (not (unseen_information(
                                    g, next_player, c, 'value'))
                                ) or (not (unseen_information(
                                    g, next_player, c, 'color'))) or (
                                        c.value < g.fireworks[c.color] + 1):
                                good_info = False
                    if good_info:
                        give_info(g, next_player, 'value', recurrent_value)
                        return

    # complete the information about a "5" of the 2 next players if it is playable
    if g.info_tokens >= 1:
        for next_turn in range(1, len(g.players)):
            next_player = g.players[(g.players.index(p) + next_turn) %
                                    len(g.players)]
            next_player_deck = next_player.deck
            for c in next_player_deck:
                if (c.value_info == 5) and (c.color_info
                                            == "") and (g.fireworks[c.color]
                                                        == 4):
                    same_color_cards = 0
                    for cards in next_player_deck:
                        if cards.color == c.color:
                            same_color_cards += 1
                    if same_color_cards <= 1:
                        give_info(g, next_player, 'color', c.color)
                        return

    # give an information if the 2 next players have nice cards with not any info on it
    # and if there is at least an info token left
    if g.info_tokens >= 1:
        for next_turn in [1, 2]:
            next_player = g.players[(g.players.index(p) + next_turn) %
                                    len(g.players)]
            next_player_deck = next_player.deck
            if not (too_much_information(next_player_deck)):
                for c in next_player_deck:
                    if (c.value == g.fireworks[c.color] + 1) and (
                            c.color_info == "") and (c.value_info == 10):
                        info = info_to_give(next_player_deck, c)
                        if info == "color":
                            if unseen_information(g, next_player, c, 'color'):
                                give_info(g, next_player, 'color', c.color)
                                return
                        elif info == "value":
                            if unseen_information(g, next_player, c, 'value'):
                                give_info(g, next_player, 'value', c.value)
                                return

    # give an information to a player if the previous player has an information so the second one
    # will be able to play a card just after (second and third next players)
    if g.info_tokens >= 1:
        for next_turn in [2, 3]:
            player_before_next = g.players[(g.players.index(p) + next_turn - 1)
                                           % len(g.players)]
            next_player = g.players[(g.players.index(p) + next_turn) %
                                    len(g.players)]
            next_player_deck = next_player.deck
            if not (too_much_information(next_player_deck)):
                for c in next_player_deck:
                    if (c.value == g.fireworks[c.color] +
                            2) and (c.color_info == "") and (
                                c.value_info == 10) and info_given_to_player(
                                    player_before_next, c.color,
                                    g.fireworks[c.color] +
                                    1) and not (info_on_the_left(
                                        player_before_next.deck, c)):
                        info = info_to_give(next_player_deck, c)
                        if info == "color":
                            if unseen_information(g, next_player, c, 'color'):
                                give_info(g, next_player, 'color', c.color)
                                return
                        elif info == "value":
                            if unseen_information(g, next_player, c, 'value'):
                                give_info(g, next_player, 'value', c.value)
                                return

    # give an information about a "5" or a useless card in the 2 next players' deck
    if g.info_tokens >= 1:
        for next_turn in [1, 2]:
            next_player = g.players[(g.players.index(p) + next_turn) %
                                    len(g.players)]
            next_player_deck = next_player.deck
            if not (too_much_information(next_player_deck)):
                for c in next_player_deck:
                    if (c.value == 5) and (c.color_info
                                           == "") and (c.value_info == 10):
                        give_info(g, next_player, 'value', 5)
                        return
                    elif (min(g.fireworks.values()) >=
                          c.value) and (c.value_info == 10):
                        give_info(g, next_player, 'value', c.value)
                        return
                    elif (g.fireworks[c.color] == 5) and (c.color_info == ""):
                        give_info(g, next_player, 'color', c.color)
                        return

    # give an information if the next players have nice cards with not any info on it
    # and if there is at least an info token left (from the third next player)
    if g.info_tokens >= 1:
        for next_turn in range(3, len(g.players)):
            next_player = g.players[(g.players.index(p) + next_turn) %
                                    len(g.players)]
            next_player_deck = next_player.deck
            if not (too_much_information(next_player_deck)):
                for c in next_player_deck:
                    if (c.value == g.fireworks[c.color] + 1) and (
                            c.color_info == "") and (c.value_info == 10):
                        info = info_to_give(next_player_deck, c)
                        if info == "color":
                            if unseen_information(g, next_player, c, 'color'):
                                give_info(g, next_player, 'color', c.color)
                                return
                        elif info == "value":
                            if unseen_information(g, next_player, c, 'value'):
                                give_info(g, next_player, 'value', c.value)
                                return

    # give an information about a "5" or a useless card in the next players' deck (from the third next player)
    if g.info_tokens >= 1:
        for next_turn in range(3, len(g.players)):
            next_player = g.players[(g.players.index(p) + next_turn) %
                                    len(g.players)]
            next_player_deck = next_player.deck
            if not (too_much_information(next_player_deck)):
                for c in next_player_deck:
                    if (c.value == 5) and (c.color_info
                                           == "") and (c.value_info == 10):
                        give_info(g, next_player, 'value', 5)
                        return
                    elif (min(g.fireworks.values()) >=
                          c.value) and (c.value_info == 10):
                        give_info(g, next_player, 'value', c.value)
                        return
                    elif (g.fireworks[c.color] == 5) and (c.color_info == ""):
                        give_info(g, next_player, 'color', c.color)
                        return

    # complete the information about a "5" of the next players
    if g.info_tokens >= 1:
        for next_turn in [1, 2]:
            next_player = g.players[(g.players.index(p) + next_turn) %
                                    len(g.players)]
            next_player_deck = next_player.deck
            for c in next_player_deck:
                if (c.value_info == 5) and (c.color_info == "") and (
                        g.fireworks[c.color]
                        == 4) and not (same_value_or_color_cards(
                            next_player_deck, c)):
                    give_info(g, next_player, 'color', c.color)
                    return

    # complete the information about an unplayable informed card
    if g.info_tokens >= 1:
        for next_turn in [1, 2]:
            next_player = g.players[(g.players.index(p) + next_turn) %
                                    len(g.players)]
            next_player_deck = next_player.deck
            for c in next_player_deck:
                if (c.value_info == 10) and (c.color_info != ""):
                    if c.value != g.fireworks[c.color] + 1:
                        info = info_to_give(next_player_deck, c)
                        if info == "value":
                            give_info(g, next_player, 'value', c.color)
                            return
                if (c.value_info != 10) and (c.color_info == ""):
                    if c.value != g.fireworks[c.color] + 1:
                        info = info_to_give(next_player_deck, c)
                        if info == "color":
                            give_info(g, next_player, 'color', c.color)
                            return

    # throw a card (not a "5") if it is not useful in a near future
    if g.info_tokens < 8:
        for c in p.deck:
            if (c.value_info != 10) and (c.value != 5):
                if c.value_info > max(g.fireworks.values()) + 1:
                    discard(g, p, c)
                    return

    # throw a random card (not a useful "5") if no information about the deck
    if g.info_tokens < 6:
        for c in p.deck:
            if c.value_info != 5:
                discard(g, p, c)
                return

    # complete the information about a "5" with no cards with the same color in the deck to not discard randomly
    if g.info_tokens >= 1:
        for next_turn in range(1, len(g.players)):
            next_player = g.players[(g.players.index(p) + next_turn) %
                                    len(g.players)]
            next_player_deck = next_player.deck
            for c in next_player_deck:
                if (c.value_info == 5) and (c.color_info == ""):
                    if not (same_value_or_color_cards(next_player_deck, c)):
                        give_info(g, next_player, 'color', c.color)
                        return

    # complete the color information about cards that are the same and with the value only as information
    if g.info_tokens >= 1:
        for next_turn in range(1, len(g.players)):
            next_player = g.players[(g.players.index(p) + next_turn) %
                                    len(g.players)]
            next_player_deck = next_player.deck
            for c in next_player_deck:
                if (duplicated_card(g, next_player_deck, c)
                    ) and (c.value <= g.fireworks[c.color]) and (
                        c.value_info != 10) and (c.color_info == "") and not (
                            same_value_or_color_cards(next_player_deck, c)):
                    give_info(g, next_player, 'color', c.color)
                    return

    # give an information about a playable card which appears twice in the deck of one of the next players
    if g.info_tokens >= 1:
        for next_turn in range(1, len(g.players)):
            next_player = g.players[(g.players.index(p) + next_turn) %
                                    len(g.players)]
            next_player_deck = next_player.deck
            if not (too_much_information(next_player_deck)):
                for c in next_player_deck:
                    if (duplicated_card(
                            g, next_player_deck,
                            c)) and (c.value == g.fireworks[c.color] + 1) and (
                                c.value_info == 10) and (c.color_info == ""):
                        give_info(g, next_player, 'value', c.value)
                        return

    # give an information about a playable card but with cards with same color and same value in the deck
    # can not be given to the player just after
    if g.info_tokens >= 1:
        for next_turn in range(2, len(g.players)):
            next_player = g.players[(g.players.index(p) + next_turn) %
                                    len(g.players)]
            next_player_deck = next_player.deck
            if not (too_much_information(next_player_deck)):
                for c in next_player_deck:
                    if (c.value_info == 10) and (c.color_info == "") and (
                            c.value == g.fireworks[c.color] + 1):
                        give_info(g, next_player, 'value', c.value)
                        return

    # give a random information if there are a lot of info tokens instead of playing a random card
    # priority for the "4" when the game is near of its start
    if g.info_tokens >= 6:
        for next_turn in range(3, len(g.players)):
            next_player = g.players[(g.players.index(p) + next_turn) %
                                    len(g.players)]
            next_player_deck = next_player.deck
            for c in next_player_deck:
                if (c.value_info != 10) and (c.color_info == "") and (
                        c.value == 4) and (max(g.fireworks.values()) < 3):
                    give_info(g, next_player, 'value', 4)
                    return
            for c in next_player_deck:
                info = info_to_give(next_player_deck, c)
                if (c.value_info != 10) and (c.color_info
                                             == "") and (info == 'color'):
                    give_info(g, next_player, 'color', c.color)
                    return
                if (c.value_info
                        == 10) and (c.color_info != "") and (info == 'value'):
                    give_info(g, next_player, 'value', c.value)
                    return

    # try to put a random card if the game is almost done and there are still error tokens
    if (len(g.draw_pile) < 4) and g.error_tokens >= 2:
        for c in p.deck:
            if (c.color_info == "") and (c.value_info == 10):
                play_card(g, p, c)
                return

    # throw a random card (not a known useful "5") if no information about the deck
    if g.info_tokens < 8:
        for c in p.deck:
            if c.value_info != 5:
                discard(g, p, c)
                return

    # play a random card (rarely happens)
    for c in p.deck:
        if (c.color_info == "") and (c.value_info == 10):
            play_card(g, p, c)
            return
    for c in p.deck:
        if (c.color_info == "") and (c.value_info != 5):
            play_card(g, p, c)
            return
    for c in p.deck:
        if (c.color_info == "") or (c.value_info != 10):
            play_card(g, p, c)
            return
Exemplo n.º 5
0
def turn_player_data_neural_network(g, players_number, p, data, turn_type,
                                    index):

    if turn_type == 'first':
        data = data_game_initialization(data, g, g.players.index(p), index)
    else:
        ## update the game information

        # cards
        for next_player in range(players_number - 2):
            data.iloc[index,
                      72 + 40 * next_player:111 + 40 * next_player] = np.array(
                          data.iloc[index - 1,
                                    72 + 40 * (next_player + 1):111 + 40 *
                                    (next_player + 1)])
        last_next_player_deck = g.players[(g.players.index(p) +
                                           players_number - 1) %
                                          players_number].deck
        card_index = 0
        for c in last_next_player_deck:
            data.loc[index, 'player ' + str(players_number - 1) +
                     ' turn(s) after : card ' + str(card_index) + ' is ' +
                     str(c.color)] = 1
            data.loc[index, 'player ' + str(players_number - 1) +
                     ' turn(s) after : card ' + str(card_index) + ' is ' +
                     str(c.value)] = 1
            card_index += 1

        # cards info
        for c in p.deck:
            if c.color_info != "":
                data.loc[index, 'info : card ' + str(p.deck.index(c)) +
                         ' is ' + str(c.color_info)] = 1
            if c.value_info != 10:
                data.loc[index, 'info : card ' + str(p.deck.index(c)) +
                         ' is ' + str(c.value_info)] = 1

        for next_player in range(1, players_number):
            next_player_deck = g.players[((g.players.index(p)) + next_player) %
                                         players_number].deck
            for c in next_player_deck:
                if c.color_info != "":
                    data.loc[index, 'player ' + str(next_player) +
                             ' turn(s) after : info : card ' +
                             str(next_player_deck.index(c)) + ' is ' +
                             str(c.color_info)] = 1
                if c.value_info != 10:
                    data.loc[index, 'player ' + str(next_player) +
                             ' turn(s) after : info : card ' +
                             str(next_player_deck.index(c)) + ' is ' +
                             str(c.value_info)] = 1

    # play a card if the information on it is known and can be played
    # discard it if the card is useless
    for c in p.deck:
        if (c.color_info != "") and (c.value_info != 10):
            if c.value_info <= g.fireworks[c.color_info]:
                data = discard_neural_network(g, p, players_number, c, data,
                                              index)
                return data
            else:
                data = play_card_neural_network(g, p, players_number, c, data,
                                                index)
                return data
        elif c.color_info != "":
            if (g.fireworks[c.color_info] == 5) or (color_lost(g, c.color)):
                data = discard_neural_network(g, p, players_number, c, data,
                                              index)
                return data
            else:
                data = play_card_neural_network(g, p, players_number, c, data,
                                                index)
                return data
        elif c.value_info != 10:
            if (c.value_info < 5) and (c.value_info <= min(
                    g.fireworks.values())):
                data = discard_neural_network(g, p, players_number, c, data,
                                              index)
                return data
            elif c.value_info < 5:
                data = play_card_neural_network(g, p, players_number, c, data,
                                                index)
                return data

    # give the information if a player among the 2 nexts has 2 playable cards
    if g.info_tokens >= 1:
        for next_turn in [1, 2]:
            next_player = g.players[(g.players.index(p) + next_turn) %
                                    players_number]
            next_player_deck = next_player.deck
            recurrent_value = several_playable_cards(g, next_player_deck)
            if recurrent_value != 0:
                good_info = True
                for c in next_player_deck:
                    if (c.value == recurrent_value) and (
                            c.color_info == "") and (c.value_info == 10):
                        if (not (unseen_information(
                                g, next_player, c,
                                'value'))) or (not (unseen_information(
                                    g, next_player, c, 'color'))) or (
                                        c.value < g.fireworks[c.color] + 1):
                            good_info = False
                if good_info:
                    data = give_info_neural_network(g, g.players.index(p),
                                                    players_number,
                                                    next_player, 'value',
                                                    recurrent_value, data,
                                                    index)
                    return data

    # give an information if the 2 next players have nice cards with not any info on it
    # and if there is at least an info token left
    if g.info_tokens >= 1:
        for next_turn in [1, 2]:
            next_player = g.players[(g.players.index(p) + next_turn) %
                                    players_number]
            next_player_deck = next_player.deck
            for c in next_player_deck:
                if (c.value == g.fireworks[c.color] +
                        1) and (c.color_info == "") and (c.value_info == 10):
                    info = info_to_give(next_player_deck, c)
                    if info == "color":
                        if unseen_information(g, next_player, c, 'color'):
                            data = give_info_neural_network(
                                g, g.players.index(p), players_number,
                                next_player, 'color', c.color, data, index)
                            return data
                    elif info == "value":
                        if unseen_information(g, next_player, c, 'value'):
                            data = give_info_neural_network(
                                g, g.players.index(p), players_number,
                                next_player, 'value', c.value, data, index)
                            return data

    # give an information to a player if the previous player has an information so the second one
    # will be able to play a card just after (second and third next players)
    if g.info_tokens >= 1:
        for next_turn in [2, 3]:
            player_before_next = g.players[(g.players.index(p) + next_turn - 1)
                                           % players_number]
            next_player = g.players[(g.players.index(p) + next_turn) %
                                    players_number]
            next_player_deck = next_player.deck
            for c in next_player_deck:
                if (c.value == g.fireworks[c.color] +
                        2) and (c.color_info
                                == "") and (c.value_info
                                            == 10) and info_given_to_player(
                                                player_before_next, c.color,
                                                g.fireworks[c.color] + 1):
                    info = info_to_give(next_player_deck, c)
                    if info == "color":
                        if unseen_information(g, next_player, c, 'color'):
                            data = give_info_neural_network(
                                g, g.players.index(p), players_number,
                                next_player, 'color', c.color, data, index)
                            return data
                    elif info == "value":
                        if unseen_information(g, next_player, c, 'value'):
                            data = give_info_neural_network(
                                g, g.players.index(p), players_number,
                                next_player, 'value', c.value, data, index)
                            return data

    # give an information about a "5" or a useless card in the 2 next players' deck
    if g.info_tokens >= 1:
        for next_turn in [1, 2]:
            next_player = g.players[(g.players.index(p) + next_turn) %
                                    players_number]
            next_player_deck = next_player.deck
            for c in next_player_deck:
                if (c.value == 5) and (c.color_info == "") and (c.value_info
                                                                == 10):
                    data = give_info_neural_network(g, g.players.index(p),
                                                    players_number,
                                                    next_player, 'value', 5,
                                                    data, index)
                    return data
                elif (min(g.fireworks.values()) >= c.value) and (c.value_info
                                                                 == 10):
                    data = give_info_neural_network(g, g.players.index(p),
                                                    players_number,
                                                    next_player, 'value',
                                                    c.value, data, index)
                    return data
                elif (g.fireworks[c.color] == 5) and (c.color_info == ""):
                    data = give_info_neural_network(g, g.players.index(p),
                                                    players_number,
                                                    next_player, 'color',
                                                    c.color, data, index)
                    return data

    # give an information if the next players have nice cards with not any info on it
    # and if there is at least an info token left (from the third next player)
    if g.info_tokens >= 1:
        for next_turn in range(3, players_number):
            next_player = g.players[(g.players.index(p) + next_turn) %
                                    players_number]
            next_player_deck = next_player.deck
            for c in next_player_deck:
                if (c.value == g.fireworks[c.color] +
                        1) and (c.color_info == "") and (c.value_info == 10):
                    info = info_to_give(next_player_deck, c)
                    if info == "color":
                        if unseen_information(g, next_player, c, 'color'):
                            data = give_info_neural_network(
                                g, g.players.index(p), players_number,
                                next_player, 'color', c.color, data, index)
                            return data
                    elif info == "value":
                        if unseen_information(g, next_player, c, 'value'):
                            data = give_info_neural_network(
                                g, g.players.index(p), players_number,
                                next_player, 'value', c.value, data, index)
                            return data

    # give an information about a "5" or a useless card in the next players' deck (from the third next player)
    if g.info_tokens >= 1:
        for next_turn in range(3, players_number):
            next_player = g.players[(g.players.index(p) + next_turn) %
                                    players_number]
            next_player_deck = next_player.deck
            for c in next_player_deck:
                if (c.value == 5) and (c.color_info == "") and (c.value_info
                                                                == 10):
                    data = give_info_neural_network(g, g.players.index(p),
                                                    players_number,
                                                    next_player, 'value', 5,
                                                    data, index)
                    return data
                elif (min(g.fireworks.values()) >= c.value) and (c.value_info
                                                                 == 10):
                    data = give_info_neural_network(g, g.players.index(p),
                                                    players_number,
                                                    next_player, 'value',
                                                    c.value, data, index)
                    return data
                elif (g.fireworks[c.color] == 5) and (c.color_info == ""):
                    data = give_info_neural_network(g, g.players.index(p),
                                                    players_number,
                                                    next_player, 'color',
                                                    c.color, data, index)
                    return data

    # complete the information about a "5" of the next players
    if g.info_tokens >= 1:
        for next_turn in [1, 2]:
            next_player = g.players[(g.players.index(p) + next_turn) %
                                    players_number]
            next_player_deck = next_player.deck
            for c in next_player_deck:
                if (c.value_info == 5) and (c.color_info
                                            == "") and (g.fireworks[c.color]
                                                        == 4):
                    data = give_info_neural_network(g, g.players.index(p),
                                                    players_number,
                                                    next_player, 'color',
                                                    c.color, data, index)
                    return data

    # try to put a random card if the game is almost done and there are still error tokens
    if (len(g.draw_pile) < 4) and g.error_tokens >= 2:
        for c in p.deck:
            if (c.color_info == "") and (c.value_info == 10):
                data = play_card_neural_network(g, p, players_number, c, data,
                                                index)
                return data

    # throw a card (not a useful 5) if no information about the deck
    if g.info_tokens < 8:
        for c in p.deck:
            if c.value_info != 5:
                data = discard_neural_network(g, p, players_number, c, data,
                                              index)
                return data

    # complete the information about a "5" to not discard randomly
    # favor the "5" with no cards with the same color in the deck
    if g.info_tokens >= 1:
        for next_turn in range(1, players_number):
            next_player = g.players[(g.players.index(p) + next_turn) %
                                    players_number]
            next_player_deck = next_player.deck
            for c in next_player_deck:
                if (c.value_info == 5) and (c.color_info == ""):
                    if info_to_give(next_player_deck, c) == 'color':
                        data = give_info_neural_network(
                            g, g.players.index(p), players_number, next_player,
                            'color', c.color, data, index)
                        return data

        for next_turn in range(1, players_number):
            next_player = g.players[(g.players.index(p) + next_turn) %
                                    players_number]
            next_player_deck = next_player.deck
            for c in next_player_deck:
                if (c.value_info == 5) and (c.color_info == ""):
                    data = give_info_neural_network(g, g.players.index(p),
                                                    players_number,
                                                    next_player, 'color',
                                                    c.color, data, index)
                    return data

    # play a random card (rarely happens)
    for c in p.deck:
        if (c.color_info == "") and (c.value_info == 10):
            data = play_card_neural_network(g, p, players_number, c, data,
                                            index)
            return data
    for c in p.deck:
        if (c.color_info == "") and (c.value_info != 5):
            data = play_card_neural_network(g, p, players_number, c, data,
                                            index)
            return data
    for c in p.deck:
        if (c.color_info == "") or (c.value_info != 10):
            data = play_card_neural_network(g, p, players_number, c, data,
                                            index)
            return data