diff --git a/pyroulette/__init__.py b/pyroulette/__init__.py index eea53bb..e502eee 100644 --- a/pyroulette/__init__.py +++ b/pyroulette/__init__.py @@ -1 +1 @@ -from .roulette import * # noqa: F401, F403 \ No newline at end of file +from .roulette import * # noqa: F401, F403 diff --git a/pyroulette/roulette.py b/pyroulette/roulette.py index 4a6d532..9f0b5d5 100644 --- a/pyroulette/roulette.py +++ b/pyroulette/roulette.py @@ -24,7 +24,6 @@ def init_spread() -> Dict[int, float]: return D - # for two bets of structure Dict[int, float], iterate through all the keys and add up the values, returning a new dict. def combine_bets(bet_1: Bet, bet_2: Bet) -> Bet: """ @@ -46,10 +45,10 @@ def combine_bets(bet_1: Bet, bet_2: Bet) -> Bet: return Bet({k: bet_1[k] + bet_2[k] for k in set(bet_1) | set(bet_2)}) - @dataclass class Bet: - """A class for representing a bet.""" + """A class for representing a bet.""" + spread: Dict[int, float] = field(default_factory=init_spread) @property @@ -90,7 +89,7 @@ class Bet: def __iter__(self): return iter(self.spread.keys()) - + def get(self, __name: int) -> float: return self.spread.get(__name, 0) @@ -316,6 +315,7 @@ class Placement: """ return interpret_bet(self.on, self.num * self.amt, bet) + # for a list of Placements, call the place_bet method on each one and combine the results using reduce and combine_bets, starting with an empty dictionary as the initial argument diff --git a/strategy.py b/strategy.py index fb83576..5f8e89d 100644 --- a/strategy.py +++ b/strategy.py @@ -2,11 +2,15 @@ from pyroulette.roulette import Placement, Strategy, Bet if __name__ == "__main__": print(Bet({-1: 1}).__repr__()) # this should print with 00 - print('get test') + print("get test") print(Bet({0: 1})[21]) print(Bet({21: 1})[21]) - print('sum test') + print("sum test") print(Bet({0: 1}) + Bet({0: 1})) print(Bet({0: 1}) + Bet()) # this should return 1's in everything but 0 and -1. - print(Strategy(placements=[Placement(18, 1, "red"), Placement(18, 1, "black")]).get_bet()) \ No newline at end of file + print( + Strategy( + placements=[Placement(18, 1, "red"), Placement(18, 1, "black")] + ).get_bet() + )