fork download
  1. class CardCounter:
  2. def __init__(self, num_mazzi=6):
  3. self.num_mazzi = num_mazzi # Numero totale di mazzi
  4. self.running_count = 0 # Running Count Hi-Lo
  5. self.carte_viste = 0 # Numero di carte conteggiate
  6. self.carte_totali = num_mazzi * 52 # Carte totali nel sabot
  7.  
  8. def aggiorna_conteggio(self, carta):
  9. valori = {'2': 1, '3': 1, '4': 1, '5': 1, '6': 1,
  10. '7': 0, '8': 0, '9': 0,
  11. '10': -1, 'J': -1, 'Q': -1, 'K': -1, 'A': -1}
  12.  
  13. if carta.upper() in valori:
  14. self.running_count += valori[carta.upper()] # Aggiorna il running count
  15. self.carte_viste += 1 # Aggiorna il numero di carte viste
  16.  
  17. def get_true_count(self):
  18. mazzi_rimasti = max(1, (self.carte_totali - self.carte_viste) / 52) # Stima mazzi rimasti
  19. return round(self.running_count / mazzi_rimasti, 2) # Calcola il True Count
  20.  
  21. def suggerisci_scommessa(self, puntata_base=10):
  22. true_count = self.get_true_count()
  23. if true_count <= 1:
  24. return f"Punta la base: ${puntata_base}"
  25. elif 2 <= true_count <= 3:
  26. return f"Aumenta la puntata: ${puntata_base * 2}"
  27. elif 4 <= true_count <= 5:
  28. return f"Punta più alto: ${puntata_base * 4}"
  29. else:
  30. return f"Punta aggressivo: ${puntata_base * 6} o più"
  31.  
  32. def mostra_conteggio(self):
  33. true_count = self.get_true_count()
  34. print(f"\nRunning Count: {self.running_count}")
  35. print(f"True Count: {true_count}")
  36. print(f"Carte viste: {self.carte_viste} su {self.carte_totali}")
  37. print(f"Suggerimento: {self.suggerisci_scommessa()}")
Success #stdin #stdout 0.11s 14064KB
stdin
Standard input is empty
stdout
Standard output is empty