Implement PERCENTAGE strategy. Update readme file with a concrete example and close #9

This commit is contained in:
Alessandro Maggio
2021-01-20 13:03:21 +01:00
parent c3d068fbaf
commit 0a4f1a2728
6 changed files with 25 additions and 9 deletions

View File

@@ -9,7 +9,7 @@ I've also take some piece of code - and idea to use Selenium fo do bet from: htt
Read more here: https://help.twitch.tv/s/article/channel-points-guide?language=en_US
![Screenshot](./screenshot.png)
![Screenshot](./assets/main_screen.png)
## Main difference from the original repository:
@@ -76,8 +76,19 @@ twitch_miner.mine(["streamer1", "streamer2"], followers=True) # Mixed
- **MOST_VOTED**: Select the option most voted based on users count
- **HIGH_ODDS**: Select the option with the highest odds
- **PERCENTAGE**: Select the option with the highest percentage based on odds (It's the same that show Twitch) - Should be the same of select LOWEST_ODDS
- **SMART**: If the majority in percent chose an option then follow the other users, otherwise choose the option with the highest odds
![Screenshot](./assets/prediction_screen.png)
Here a concrete example:
- **MOST_VOTED**: 21 Users have select **'over 7.5'**, instead of 9 'under 7.5'
- **HIGH_ODDS**: The highest odds are 2.27 on **'over 7.5'** vs 1.79 on 'under 7.5'
- **PERCENTAGE**: The highest percentage is 56% for **'under 7.5'**
- **SMART**: Calculate the percentage based on the users. The percentage are: 'over 7.5': 70% and 'under 7.5': 30%. If the difference between the two percatage are lower thant `percentage_gap` select the highest percentage, else the highest odds.
In this case if percentage_gap = 20 ; 70-30 = 40 > percentage_gap, so the bot will select 'over 7.5'
## Migrating from old repository (the original one):
If you already have a `twitch-cookies.pkl` and you don't want to login again please create a `cookies/` folder in the current directory and then copy the .pkl file with a new name `your-twitch-username.pkl`
```

View File

@@ -9,6 +9,7 @@ logger = logging.getLogger(__name__)
class Strategy(Enum):
MOST_VOTED = auto()
HIGH_ODDS = auto()
PERCENTAGE = auto()
SMART = auto()
@@ -74,6 +75,13 @@ class Bet:
self.total_points / self.outcomes[1]["total_points"]
)
self.outcomes[0]["odds_percetange"] = float_round(
100 / self.outcomes[0]["odds"]
)
self.outcomes[1]["odds_percetange"] = float_round(
100 / self.outcomes[1]["odds"]
)
self.__clear_outcomes()
def __repr__(self):
@@ -103,16 +111,13 @@ class Bet:
self.decision["choice"] = self.__return_choice("total_users")
elif self.settings.strategy == Strategy.HIGH_ODDS:
self.decision["choice"] = self.__return_choice("odds")
elif self.settings.strategy == Strategy.PERCENTAGE:
self.decision["choice"] = self.__return_choice("odds_percetange")
elif self.settings.strategy == Strategy.SMART:
difference = abs(self.outcomes[0]["percentage_users"] - self.outcomes[1]["percentage_users"])
self.decision["choice"] = (
self.__return_choice("odds")
if (
abs(
self.outcomes[0]["percentage_users"]
- self.outcomes[1]["percentage_users"]
)
< self.settings.percentage_gap
)
if difference < self.settings.percentage_gap
else self.__return_choice("total_users")
)

View File

@@ -253,7 +253,7 @@ class TwitchBrowser:
draw = ImageDraw.Draw(image)
font = ImageFont.truetype(
os.path.join(Path().absolute(), "Roboto-Bold.ttf"), size=35
os.path.join(Path().absolute(), "assets", "Roboto-Bold.ttf"), size=35
)
(x, y) = (15, image.height // 3)
datetime_text = datetime.now().strftime("%d/%m %H:%M:%S.%f")

View File

Before

Width:  |  Height:  |  Size: 307 KiB

After

Width:  |  Height:  |  Size: 307 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB