Twitch-Channel-Points-Miner-v2 icon indicating copy to clipboard operation
Twitch-Channel-Points-Miner-v2 copied to clipboard

Support for 2+ outcomes

Open Chanka0 opened this issue 2 years ago • 3 comments

Description

Implements basic support for predictions with more than two potential outcomes. Part of the fix included modifying how choices were interpreted by changing decision["choice"] to be the index rather than a letter being used as intermediary.

Basic safeguards for the divide by zero error were added in as well.

Fixes #497 Limited support for predictions with more than 2 outcomes.

Type of change

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)

How Has This Been Tested?

This has been tested 4-5 times on predictions with more than 2 outcomes, most of which utilizing 10 (the new limit).

Checklist:

  • [x] My code follows the style guidelines of this project
  • [x] I have performed a self-review of my code
  • [ ] I have commented on my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation (README.md)
  • [x] My changes generate no new warnings
  • [x] Any dependent changes have been updated in requirements.txt

Chanka0 avatar May 04 '22 21:05 Chanka0

One note to be added: The SMART strategy has not been converted to support more than 2 strategies.

Chanka0 avatar May 04 '22 21:05 Chanka0

IMO the smart strategy should probably take the 2 outcomes with the most people rather than the 2 first (which is obviously random).

Based on most people is a decision to make but I think that it makes sense. Smart used to take the choice with most people but if these are too close (~ almost same chances) it takes the one with most potential gain. With multiple choices it'd do basically the same. The 2 choices with most people are the 2 that stands out the most and seem the most likely. If they're close, then pick with best gain.

That's what I did in my fork, if I have some time to spare I'll try to gather stats on how it behaves.

Rakambda avatar May 09 '22 10:05 Rakambda

Currently I changed line 158~ in .\classes\entities\Bet.py like this: self.total_users = ( sum(map(lambda x:x[OutcomeKeys.TOTAL_USERS],self.outcomes)) #self.outcomes[0][OutcomeKeys.TOTAL_USERS] #+ self.outcomes[1][OutcomeKeys.TOTAL_USERS] ) self.total_points = ( sum(map(lambda x:x[OutcomeKeys.TOTAL_POINTS],self.outcomes)) #reduce(lambda x,y:x[OutcomeKeys.TOTAL_POINTS]+y[OutcomeKeys.TOTAL_POINTS],self.outcomes) #self.outcomes[0][OutcomeKeys.TOTAL_POINTS] #+ self.outcomes[1][OutcomeKeys.TOTAL_POINTS] ) if ( self.total_users > 0 and all(map(lambda x:x[OutcomeKeys.TOTAL_POINTS]>0, self.outcomes)) #and self.outcomes[0][OutcomeKeys.TOTAL_POINTS] > 0 #and self.outcomes[1][OutcomeKeys.TOTAL_POINTS] > 0 ): And I think it seems to work maybe there's some other codes that only counts 2 selections but I can't find it now

lazinism avatar May 27 '22 15:05 lazinism

@lazinism by removing comments and formatting your code, we get:

self.total_users = ( sum(map(lambda x:x[OutcomeKeys.TOTAL_USERS],self.outcomes))
self.total_points = ( sum(map(lambda x:x[OutcomeKeys.TOTAL_POINTS],self.outcomes))
if ( self.total_users > 0 and all(map(lambda x:x[OutcomeKeys.TOTAL_POINTS]>0, self.outcomes)) ):

Right?

rdavydov avatar Nov 30 '22 18:11 rdavydov

@lazinism Do we really need to use all(map()) in the condition? Can't we just use:

if ( self.total_users > 0 and self.total_points > 0 ):

?

rdavydov avatar Nov 30 '22 18:11 rdavydov

@lazinism Your solution with sum(), map() and lambda-functions is just an elegant way of doing:

        #inefficient but otherwise outcomekeys are represented wrong.
        self.total_points = 0
        self.total_users = 0
        for index in range(0, len(self.outcomes)):
            self.total_users += self.outcomes[index][OutcomeKeys.TOTAL_USERS]
            self.total_points += self.outcomes[index][OutcomeKeys.TOTAL_POINTS]

right? It is basically the same thing, or am I missing something?

rdavydov avatar Nov 30 '22 18:11 rdavydov

Yes I think it's same I just prefer shorter code, so that i used sum, map, lambda.

lazinism avatar Nov 30 '22 19:11 lazinism

@lazinism Do we really need to use:

if ( self.total_users > 0 and all(map(lambda x:x[OutcomeKeys.TOTAL_POINTS]>0, self.outcomes)) ):

Can't we just use:

if ( self.total_users > 0 and self.total_points > 0 ):

?

rdavydov avatar Nov 30 '22 19:11 rdavydov

I wrote it like that because Original code was

self.total_users > 0 and self.outcomes[0][OutcomeKeys.TOTAL_POINTS] > 0 and self.outcomes[1][OutcomeKeys.TOTAL_POINTS] > 0

and I can't predict what would happen if I change code to self.total_points > 0 If that works fine, I think we can change it, maybe

lazinism avatar Nov 30 '22 19:11 lazinism

so the purpose of the changed code I wrote was to preserve as many original code as i can, but change it from considering only 2 options to multiple options. In that view, you can understand why I wrote code like that 👍

lazinism avatar Nov 30 '22 19:11 lazinism