bump version, reorder functions and simplify code.
This commit is contained in:
parent
6c16d2986b
commit
c32569f3c1
@ -7,6 +7,35 @@ from random import choice, randint
|
|||||||
from statistics import mean, stdev
|
from statistics import mean, stdev
|
||||||
from typing import Dict, List, Optional
|
from typing import Dict, List, Optional
|
||||||
|
|
||||||
|
SINGLE_BETS = {str(i) for i in range(-1, 37)}
|
||||||
|
|
||||||
|
FEASIBLE_MOVES = sorted(
|
||||||
|
{
|
||||||
|
*[f"street-{i}" for i in range(1, 14)],
|
||||||
|
*[f"col-{i}" for i in range(1, 4)],
|
||||||
|
*[f"corner-{i}-{i+1}-{i+3}-{i+4}" for i in range(1, 33) if (i - 1) % 3 < 2],
|
||||||
|
*["1-12", "13-24", "25-36", "1-18", "19-36", "even", "odd", "red", "black"],
|
||||||
|
*["triple-0", "triple-00"],
|
||||||
|
*SINGLE_BETS,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
ALIASES = {
|
||||||
|
"reds",
|
||||||
|
"blacks",
|
||||||
|
"evens",
|
||||||
|
"odds",
|
||||||
|
"first-half",
|
||||||
|
"last-half",
|
||||||
|
"second-half",
|
||||||
|
"first-18",
|
||||||
|
"last-18",
|
||||||
|
"second-18",
|
||||||
|
}
|
||||||
|
|
||||||
|
CHIP_VALUES = {0.25, 0.5, 1, 5, 10, 25, 50, 100}
|
||||||
|
|
||||||
|
|
||||||
def init_spread() -> Dict[int, float]:
|
def init_spread() -> Dict[int, float]:
|
||||||
"""
|
"""
|
||||||
@ -21,26 +50,6 @@ def init_spread() -> Dict[int, float]:
|
|||||||
return D
|
return D
|
||||||
|
|
||||||
|
|
||||||
def combine_bets(bet_1: Bet, bet_2: Bet) -> Bet:
|
|
||||||
"""
|
|
||||||
Combines two bets into a single bet.
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
bet_1 : Bet
|
|
||||||
The first bet to combine.
|
|
||||||
bet_2 : Bet
|
|
||||||
The second bet to combine.
|
|
||||||
|
|
||||||
Returns
|
|
||||||
-------
|
|
||||||
Bet
|
|
||||||
The combined bet.
|
|
||||||
"""
|
|
||||||
# TODO: can remove the default 0.
|
|
||||||
return Bet({k: bet_1[k] + bet_2[k] for k in set(bet_1) | set(bet_2)})
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Bet:
|
class Bet:
|
||||||
"""A class for representing a bet."""
|
"""A class for representing a bet."""
|
||||||
@ -69,7 +78,7 @@ class Bet:
|
|||||||
|
|
||||||
def __add__(self, other: Bet) -> Bet:
|
def __add__(self, other: Bet) -> Bet:
|
||||||
"""Combine two bets."""
|
"""Combine two bets."""
|
||||||
return combine_bets(self, other)
|
return Bet({k: self[k] + other[k] for k in set(self) | set(other)})
|
||||||
|
|
||||||
def __setitem__(self, __name: int, __value: float) -> None:
|
def __setitem__(self, __name: int, __value: float) -> None:
|
||||||
"""Set the value of a placement."""
|
"""Set the value of a placement."""
|
||||||
@ -90,36 +99,6 @@ class Bet:
|
|||||||
return self.spread.get(__name, 0)
|
return self.spread.get(__name, 0)
|
||||||
|
|
||||||
|
|
||||||
SINGLE_BETS = {str(i) for i in range(-1, 37)}
|
|
||||||
|
|
||||||
FEASIBLE_MOVES = sorted(
|
|
||||||
{
|
|
||||||
*[f"street-{i}" for i in range(1, 14)],
|
|
||||||
*[f"col-{i}" for i in range(1, 4)],
|
|
||||||
*[f"corner-{i}-{i+1}-{i+3}-{i+4}" for i in range(1, 33) if (i - 1) % 3 < 2],
|
|
||||||
*["1-12", "13-24", "25-36", "1-18", "19-36", "even", "odd", "red", "black"],
|
|
||||||
*["triple-0", "triple-00"],
|
|
||||||
*SINGLE_BETS,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
ALIASES = {
|
|
||||||
"reds",
|
|
||||||
"blacks",
|
|
||||||
"evens",
|
|
||||||
"odds",
|
|
||||||
"first-half",
|
|
||||||
"last-half",
|
|
||||||
"second-half",
|
|
||||||
"first-18",
|
|
||||||
"last-18",
|
|
||||||
"second-18",
|
|
||||||
}
|
|
||||||
|
|
||||||
CHIP_VALUES = {0.25, 0.5, 1, 5, 10, 25, 50, 100}
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Placement:
|
class Placement:
|
||||||
"""
|
"""
|
||||||
@ -269,11 +248,7 @@ class Strategy:
|
|||||||
Bet
|
Bet
|
||||||
A dictionary representing the bet.
|
A dictionary representing the bet.
|
||||||
"""
|
"""
|
||||||
return reduce(
|
return sum([p.bet() for p in placements], Bet())
|
||||||
lambda bet, placement: combine_bets(bet, placement.bet()),
|
|
||||||
placements,
|
|
||||||
Bet(),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
2
setup.py
2
setup.py
@ -10,7 +10,7 @@ with open(BASEDIR.joinpath("README.md"), "r") as fp:
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="pyroulette",
|
name="pyroulette",
|
||||||
version="0.0.1rc5",
|
version="0.0.1rc6",
|
||||||
description="A package for exploring roulette strategies.",
|
description="A package for exploring roulette strategies.",
|
||||||
long_description=LONG_DESCRIPTION,
|
long_description=LONG_DESCRIPTION,
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
|
Loading…
Reference in New Issue
Block a user