-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbetting_strategies.py
112 lines (88 loc) · 4.25 KB
/
betting_strategies.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
"""Betting strategies to be used in expected value."""
from utils import get_hilo_running_count
class BaseBetter:
"""Base better. The parent class of all betters."""
@staticmethod
def get_bet(cards_seen: list[int], deck_number: int) -> int:
"""
Raise `NotImplementedError`. To be overridden in the other classes.
:param cards_seen: The cards we have already seen from the shoe. Used when card counting.
:param deck_number: The number of decks in the starting shoe.
:return: How much money to bet.
"""
raise NotImplementedError("The `get_bet` method hasn't been overridden.")
class SimpleBetter(BaseBetter):
"""Simple better. Bets the same amount every time."""
@staticmethod
def get_bet(cards_seen: list[int], deck_number: int) -> int:
"""
Bet 1 every time. The bet doesn't change.
:param cards_seen: The cards we have already seen from the shoe. Used when card counting.
:param deck_number: The number of decks in the starting shoe.
:return: How much money to bet.
"""
return 1
class CardCountBetter(BaseBetter):
"""Change the bet according to the true count."""
@staticmethod
def get_bet(cards_seen: list[int], deck_number: int) -> int:
"""
Bet true_count ^ 2 / 2 if true_count >= +1 else 1. Cap at 15 (using a 1-15 spread).
:param cards_seen: The cards we have already seen from the shoe. Used when card counting.
:param deck_number: The number of decks in the starting shoe.
:return: How much money to bet.
"""
running_count = get_hilo_running_count(cards_seen)
cards_left = deck_number * 52 - len(cards_seen) - 1
true_count = running_count / (cards_left / 52)
if true_count >= 1:
return max(min(int(true_count ** 2 / 2), 15), 1)
return 1
class ConservativeCardCountBetter(BaseBetter):
"""Change the bet according to the true count conservatively."""
@staticmethod
def get_bet(cards_seen: list[int], deck_number: int) -> int:
"""
Bet true_count if true_count >= +1 else 1. Cap at 5 (using a 1-5 spread).
:param cards_seen: The cards we have already seen from the shoe. Used when card counting.
:param deck_number: The number of decks in the starting shoe.
:return: How much money to bet.
"""
running_count = get_hilo_running_count(cards_seen)
cards_left = deck_number * 52 - len(cards_seen) - 1
true_count = running_count / (cards_left / 52)
if true_count >= 1:
return max(min(int(true_count), 5), 1)
return 1
class WongingCardCountBetter(BaseBetter):
"""Change the bet according to the true count and use wonging (don't play if TC < 1)."""
@staticmethod
def get_bet(cards_seen: list[int], deck_number: int) -> int:
"""
Bet true_count ^ 2 / 2 if true_count >= +1 else 0. Cap at 15 (using a 1-15 spread).
:param cards_seen: The cards we have already seen from the shoe. Used when card counting.
:param deck_number: The number of decks in the starting shoe.
:return: How much money to bet.
"""
running_count = get_hilo_running_count(cards_seen)
cards_left = deck_number * 52 - len(cards_seen) - 1
true_count = running_count / (cards_left / 52)
if true_count >= 1:
return max(min(int(true_count ** 2 / 2), 15), 1)
return 0
class WongingConservativeCardCountBetter(BaseBetter):
"""Change the bet according to the true count conservatively and use wonging (don't play if TC < 1)."""
@staticmethod
def get_bet(cards_seen: list[int], deck_number: int) -> int:
"""
Bet true_count if true_count >= +1 else 0. Cap at 5 (using a 1-5 spread).
:param cards_seen: The cards we have already seen from the shoe. Used when card counting.
:param deck_number: The number of decks in the starting shoe.
:return: How much money to bet.
"""
running_count = get_hilo_running_count(cards_seen)
cards_left = deck_number * 52 - len(cards_seen) - 1
true_count = running_count / (cards_left / 52)
if true_count >= 1:
return max(min(int(true_count), 5), 1)
return 0