class RouletteBot:
    def __init__(self):
        self.history = []
        self.terminals = {
            0: [0, 10, 20, 30],
            1: [1, 11, 21, 31],
            2: [2, 12, 22],
            3: [3, 13, 23],
            4: [4, 14, 24],
            5: [5, 15, 25],
            6: [6, 16, 26],
            7: [7, 17, 27],
            8: [8, 18, 28],
            9: [9, 19, 29]
        }
        self.neighbors = {
            0: [26, 32],
            10: [5, 23],
            20: [1, 14],
            30: [8, 11],
            1: [20, 33],
            11: [36, 30],
            21: [2, 4],
            31: [9, 22],
            2: [21, 25],
            12: [28, 35],
            22: [9, 31],
            3: [26, 35],
            13: [27, 36],
            23: [8, 10],
            4: [15, 19],
            14: [9, 31],
            24: [5, 16],
            5: [10, 24],
            15: [19, 32],
            25: [17, 34],
            6: [27, 34],
            16: [33, 24],
            26: [0, 3],
            7: [28, 29],
            17: [25, 34],
            27: [13, 6],
            8: [30, 23],
            18: [6, 29],
            28: [7, 12],
            9: [22, 31],
            19: [4, 15],
            29: [18, 7]
        }
        self.current_trend = None

    def initialize_history(self):
        print("Por favor, insira os 6 últimos números que caíram, do mais velho para o mais novo.")
        temp_history = []
        for i in range(6):
            while True:
                try:
                    number = int(input(f"Insira o número {i+1}: "))
                    if number < 0 or number > 36:
                        print("Número inválido. Insira um número entre 0 e 36.")
                    else:
                        temp_history.append(number)
                        break
                except ValueError:
                    print("Entrada inválida. Por favor, insira um número válido.")
        self.history = temp_history[::-1]  # Inverte a lista para garantir que o mais velho esteja no início
        print("Histórico inicial registrado com sucesso.")
        self.update_terminal_counts()

    def add_number(self, number):
        self.history.insert(0, number)  # Adiciona o novo número na frente da lista (como o mais recente)
        if len(self.history) > 6:
            self.history.pop()  # Remove o número mais antigo (o último da lista)
        self.update_terminal_counts()

    def update_terminal_counts(self):
        # Reiniciar contagem dos terminais
        terminal_counts = {i: 0 for i in range(10)}

        for number in self.history:
            terminal = number % 10
            terminal_counts[terminal] += 1
            # Incluir os vizinhos na contagem do terminal
            for neighbor in self.neighbors.get(number, []):
                neighbor_terminal = neighbor % 10
                terminal_counts[neighbor_terminal] += 1

        # Verificar nova tendência
        max_count = max(terminal_counts.values())
        trending_terminals = [k for k, v in terminal_counts.items() if v == max_count]

        if len(trending_terminals) == 1:
            trending_terminal = trending_terminals[0]
            if self.current_trend is None or self.current_trend != trending_terminal:
                self.current_trend = trending_terminal
                print(f"Nova tendência detectada: Terminal {trending_terminal} com {max_count} ocorrências")
            else:
                print(f"Terminal {trending_terminal} continua a tendência com {max_count} ocorrências")
        else:
            self.current_trend = None

    def notify_break_sequence(self, number):
        terminal = number % 10
        if self.current_trend and terminal != self.current_trend:
            neighbors = self.get_neighbors(number)
            if len(neighbors) > 1:
                if neighbors[0] > neighbors[1]:
                    print(f"O número {number} quebrou a sequência da tendência atual (Terminal {self.current_trend}).")
                    print(f"Recomenda-se apostar no vizinho mais baixo: {neighbors[1]}")
                else:
                    print(f"O número {number} quebrou a sequência da tendência atual (Terminal {self.current_trend}).")
                    print(f"Recomenda-se apostar no vizinho mais alto: {neighbors[0]}")
            self.current_trend = None

    def get_neighbors(self, number):
        # Retorna os 2 vizinhos físicos do número na roda da roleta
        return self.neighbors.get(number, [])

    def remove_last_number(self):
        if self.history:
            removed = self.history.pop(0)
            print(f"Número {removed} removido do histórico.")
        else:
            print("Não há números para remover.")
        self.update_terminal_counts()

    def print_history(self):
        print("---------------------------------")
        print(f"Histórico: {self.history}")

    def run(self):
        print("Iniciando o bot de roleta...")
        try:
            self.initialize_history()
            while True:
                try:
                    input_number = input("Insira o próximo número, 'R' para reiniciar, 'A' para apagar o último número ou 'SAIR' para terminar: ")
                    if input_number.upper() == 'SAIR':
                        print("Finalizando o bot.")
                        break
                    elif input_number.upper() == 'R':
                        self.initialize_history()
                    elif input_number.upper() == 'A':
                        self.remove_last_number()
                    else:
                        number = int(input_number)
                        if number < 0 or number > 36:
                            print("Número inválido. Insira um número entre 0 e 36.")
                            continue
                        self.add_number(number)
                        self.notify_break_sequence(number)
                    self.print_history()
                except ValueError:
                    print("Entrada inválida. Por favor, insira um número válido ou 'SAIR'.")
        except Exception as e:
            print(f"Ocorreu um erro: {e}")

if __name__ == "__main__":
    bot = RouletteBot()
    bot.run()

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: