Update ai_manager.py
This commit is contained in:
parent
2a00e9d6da
commit
cf92090fab
@ -700,7 +700,7 @@ async def check_pitching_sub(this_play: StratPlay, ai_team: dict):
|
|||||||
logging.info(f'ai_manager - check_pitching_sub: no stats recorded yet, returning None')
|
logging.info(f'ai_manager - check_pitching_sub: no stats recorded yet, returning None')
|
||||||
return False
|
return False
|
||||||
ps = p_stats[0]
|
ps = p_stats[0]
|
||||||
logging.info(f'ai_manager - check_pitching_sub: beyond point of weakness')
|
logging.info(f'ai_manager - check_pitching_sub: pitcher does have stats')
|
||||||
|
|
||||||
this_ai = get_manager(this_play.game)
|
this_ai = get_manager(this_play.game)
|
||||||
this_pc = await data_cache.get_pd_pitchingcard(this_play.pitcher.player_id, variant=this_play.pitcher.variant)
|
this_pc = await data_cache.get_pd_pitchingcard(this_play.pitcher.player_id, variant=this_play.pitcher.variant)
|
||||||
@ -713,8 +713,14 @@ async def check_pitching_sub(this_play: StratPlay, ai_team: dict):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (this_play.game.short_game or gtr or innof_work > pof_weakness + 3) and len(used_pitchers) < 8:
|
if (this_play.game.short_game or gtr or innof_work > pof_weakness + 3) and len(used_pitchers) < 8:
|
||||||
make_sub(await get_relief_pitcher(this_play, ai_team, this_play.game.game_type))
|
rp_lineup = make_sub(await get_relief_pitcher(this_play, ai_team, this_play.game.game_type))
|
||||||
return await get_player(this_play.game, get_pitcher(this_play.game, this_play))
|
try:
|
||||||
|
rp_pitcard = await data_cache.get_pd_pitchingcard(rp_lineup.player_id, rp_lineup.variant)
|
||||||
|
if rp_pitcard.card.relief_rating == 1:
|
||||||
|
patch_play(this_play.id, in_pow=True)
|
||||||
|
except Exception as e:
|
||||||
|
logging.info(f'ai_manager - check_pitching_sub - could not pull card for {rp_lineup.player_id}')
|
||||||
|
return await get_player(this_play.game, rp_lineup)
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -736,32 +742,38 @@ async def is_pitcher_fatigued(this_play: StratPlay) -> bool:
|
|||||||
if this_play.game.short_game:
|
if this_play.game.short_game:
|
||||||
pof_weakness = 1
|
pof_weakness = 1
|
||||||
else:
|
else:
|
||||||
this_pc = await data_cache.get_pd_pitchingcard(this_play.pitcher.player_id, variant=this_play.pitcher.variant)
|
try:
|
||||||
|
this_pc = await data_cache.get_pd_pitchingcard(this_play.pitcher.player_id, variant=this_play.pitcher.variant)
|
||||||
|
except:
|
||||||
|
logging.info(
|
||||||
|
f'ai_manager - is_pitcher_fatigued: could not pull pitching card for {this_play.pitcher.player_id}, '
|
||||||
|
f'returning False')
|
||||||
|
return False
|
||||||
pof_weakness = this_pc.card.starter_rating if len(used_pitchers) == 1 else this_pc.card.relief_rating
|
pof_weakness = this_pc.card.starter_rating if len(used_pitchers) == 1 else this_pc.card.relief_rating
|
||||||
|
|
||||||
# Check starter fatigue
|
# Check starter fatigue
|
||||||
if len(p_stats) == 1:
|
if len(used_pitchers) == 1:
|
||||||
if ps['pl_eruns'] >= 7:
|
if ps['pl_eruns'] >= 7:
|
||||||
logging.info(f'ai_manager - is_pitcher_fatigued: starter allowed 7+, returning True')
|
logging.info(f'ai_manager - is_pitcher_fatigued: starter allowed 7+, returning True')
|
||||||
return True
|
return True
|
||||||
if ps['pl_eruns'] >= 6:
|
elif ps['pl_eruns'] >= 6:
|
||||||
logging.info(f'ai_manager - is_pitcher_fatigued: starter allowed 6+, checking for fatigue')
|
logging.info(f'ai_manager - is_pitcher_fatigued: starter allowed 6+, checking for fatigue')
|
||||||
f_query = get_pitching_stats(
|
f_query = get_pitching_stats(
|
||||||
this_play.game.id,
|
this_play.game.id,
|
||||||
lineup_id=this_play.pitcher.id,
|
lineup_id=this_play.pitcher.id,
|
||||||
in_innings=[this_play.inning_num, this_play.inning_num - 1]
|
in_innings=[this_play.inning_num, this_play.inning_num - 1]
|
||||||
)
|
)
|
||||||
if f_query[0]['pl_eruns'] >= 6:
|
if f_query[0]['pl_in_runs'] >= 6:
|
||||||
logging.info(f'ai_manager - is_pitcher_fatigued: starter allowed 6 in 2, returning True')
|
logging.info(f'ai_manager - is_pitcher_fatigued: starter allowed 6 in 2, returning True')
|
||||||
return True
|
return True
|
||||||
if ps['pl_eruns'] >= 5:
|
elif ps['pl_eruns'] >= 5:
|
||||||
logging.info(f'ai_manager - is_pitcher_fatigued: starter allowed 5+, checking for fatigue')
|
logging.info(f'ai_manager - is_pitcher_fatigued: starter allowed 5+, checking for fatigue')
|
||||||
f_query = get_pitching_stats(
|
f_query = get_pitching_stats(
|
||||||
this_play.game.id,
|
this_play.game.id,
|
||||||
lineup_id=this_play.pitcher.id,
|
lineup_id=this_play.pitcher.id,
|
||||||
in_innings=[this_play.inning_num]
|
in_innings=[this_play.inning_num]
|
||||||
)
|
)
|
||||||
if f_query[0]['pl_eruns'] >= 5:
|
if f_query[0]['pl_in_runs'] >= 5:
|
||||||
logging.info(f'ai_manager - is_pitcher_fatigued: starter allowed 5 in 1, returning True')
|
logging.info(f'ai_manager - is_pitcher_fatigued: starter allowed 5 in 1, returning True')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -781,6 +793,10 @@ async def is_pitcher_fatigued(this_play: StratPlay) -> bool:
|
|||||||
logging.info(f'ai_manager - is_pitcher_fatigued: in point of weakness, not fatigued, returning False')
|
logging.info(f'ai_manager - is_pitcher_fatigued: in point of weakness, not fatigued, returning False')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
elif innof_work > pof_weakness:
|
||||||
|
patch_play(this_play.id, in_pow=True)
|
||||||
|
return True
|
||||||
|
|
||||||
logging.info(f'ai_manager - is_pitcher_fatigued: beyond point of weakness, fatigued, returning True')
|
logging.info(f'ai_manager - is_pitcher_fatigued: beyond point of weakness, fatigued, returning True')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user