DimaKudosh / pydfs-lineup-optimizer

Daily Fantasy Sports lineup optimzer for all popular daily fantasy sports sites
MIT License
424 stars 157 forks source link

problems with restrict opposing team #172

Open faithhealer opened 4 years ago

faithhealer commented 4 years ago

Hi,

I am trying to create some restrictions but I have a feeling that those opposing team rules overwrite each other . I always end up with the opposing sup for the ADC which I really dont want. Can I only use this rule once?

here is my code that I use atm, thanks for the feedback.

`from pydfs_lineup_optimizer import Site, Sport, get_optimizer, CSVLineupExporter, TeamStack

optimizer = get_optimizer(Site.DRAFTKINGS_CAPTAIN_MODE, Sport.LEAGUE_OF_LEGENDS) optimizer.load_players_from_csv("loltest.csv") optimizer.restrict_positions_for_opposing_team(['ADC'],['SUP']) optimizer.restrict_positions_for_opposing_team(['SUP'],['ADC']) optimizer.restrict_positions_for_opposing_team(['TOP'],['TOP']) optimizer.restrict_positions_for_opposing_team(['SUP'],['SUP']) optimizer.restrict_positions_for_opposing_team(['CPT'],['TEAM','SUP','TOP','JNG','ADC','MID']) optimizer.add_stack(TeamStack(4, for_teams=['EDG'])) lineups = list(optimizer.optimize(n=150, max_exposure=0.2)) for lineup in lineups: print(lineup) exporter = CSVLineupExporter(lineups) exporter.export('result.csv')`

If anyone has a working file for lol that I could just tweak for my needs, I would appreciate the help.

Denwen12 commented 4 years ago

`from pydfs_lineup_optimizer import Site, Sport, get_optimizer, CSVLineupExporter, TeamStack

optimizer = get_optimizer(Site.DRAFTKINGS_CAPTAIN_MODE, Sport.LEAGUE_OF_LEGENDS) optimizer.load_players_from_csv("loltest.csv") optimizer.restrict_positions_for_opposing_team(['CPT','TEAM','SUP','TOP','JNG','ADC','MID'],['CPT','TEAM','SUP','TOP','JNG','ADC','MID'], 1) optimizer.add_stack(TeamStack(4, for_teams=['EDG'])) lineups = list(optimizer.optimize(n=150, max_exposure=0.2)) for lineup in lineups: print(lineup) exporter = CSVLineupExporter(lineups) exporter.export('result.csv')`

try that

faithhealer commented 4 years ago

Thanks but does the 1 not allow for one of the positions to be placed in the lineups? I never want the opposing SUP playing against my chosen ADC. Can you clarify on this @Denwen12 please?

I am a bit of a code noob and doing my best with copy paste and trial and error but this one kills me :D

mbencho commented 4 years ago

you can't 'stack' that code like you have it in your original post. i'm not an expert by any means but i believe it will just use your last entry of: optimizer.restrict_positions_for_opposing_team(['CPT'],['TEAM','SUP','TOP','JNG','ADC','MID'])

you are correct that the 1 in Denwen's code would allow that. if you remove the one it will stop all players from opposing teams from being in a lineup. optimizer.restrict_positions_for_opposing_team(['CPT','TEAM','SUP','TOP','JNG','ADC','MID'],'CPT','TEAM','SUP','TOP','JNG','ADC','MID'])

if you just want no SUP/ADC i think just using this will work:

optimizer.restrict_positions_for_opposing_team(['ADC','CPT'],['SUP'])

Denwen12 commented 4 years ago

My example will restrict all positions but only allow 1 position in your lineup from opp team.

Denwen12 commented 4 years ago

i got another idea but im on vacation so it will be a bit till i can figure it out for you

faithhealer commented 4 years ago

i got another idea but im on vacation so it will be a bit till i can figure it out for you

heya, cool. I will test around a bit meanwhile. I could probably go with these restrictions and filter out some lines manually.

faithhealer commented 4 years ago

you can't 'stack' that code like you have it in your original post. i'm not an expert by any means but i believe it will just use your last entry of: optimizer.restrict_positions_for_opposing_team(['CPT'],['TEAM','SUP','TOP','JNG','ADC','MID'])

you are correct that the 1 in Denwen's code would allow that. if you remove the one it will stop all players from opposing teams from being in a lineup. optimizer.restrict_positions_for_opposing_team(['CPT','TEAM','SUP','TOP','JNG','ADC','MID'],'CPT','TEAM','SUP','TOP','JNG','ADC','MID'])

if you just want no SUP/ADC i think just using this will work:

optimizer.restrict_positions_for_opposing_team(['ADC','CPT'],['SUP'])

Yeah, I thought so but if I can put "stacks" on both sides like you wrote: optimizer.restrict_positions_for_opposing_team(['ADC','CPT'],['SUP'])

Then I should be fine.

I will test this, thank you for your input.

DimaKudosh commented 4 years ago

Right now you can call restrict_positions_for_opposing_team method only once if you call it the second time it overrides your previous call so you actually restrict positions only for (['CPT'],['TEAM','SUP','TOP','JNG','ADC','MID'])

faithhealer commented 4 years ago

Right now you can call restrict_positions_for_opposing_team method only once if you call it the second time it overrides your previous call so you actually restrict positions only for (['CPT'],['TEAM','SUP','TOP','JNG','ADC','MID'])

Thank you man and great work on this. donation incoming!