Skip to content

Add formulae for advancement and for double plays - #39

Open
beiju wants to merge 6 commits into
mainfrom
advance-on-hit
Open

Add formulae for advancement and for double plays#39
beiju wants to merge 6 commits into
mainfrom
advance-on-hit

Conversation

@beiju

@beiju beiju commented Mar 4, 2025

Copy link
Copy Markdown
Collaborator

Adds formulae for:

  • Advancement on hits
  • Advancement on ground outs
  • Advancement on flyouts
  • Whether a double play happened

Currently completely unverified, and looking for help verifying it.

Also includes some small improvements to fix warnings and (sigh) make it nicer to use with uv.

@beiju beiju changed the title Add formula for advancement on hits Add formulae for advancement and for double plays Aug 22, 2026

@alefeld alefeld left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main thing is I think we should include hype anywhere vibes are used. Groundout/flyout formulas were determined in pre-hype seasons. Also a couple of discrepancies in use of multipliers in a couple spots.

Comment thread formulas.py
)

# No mods or vibes here -- not sure if I need to use .multiplied at all
runner_cont = runner.multiplied("continuation", 1.0)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this does need multipliers? See hit_advance.ipynb:
df["threshold_rounded"] = 0.70 - 1.0*df["fielder_tenaciousness_scaled"] + 0.60*df['runner_continuation_scaled']

Comment thread formulas.py
fielder_vibes = fielder.vibes(meta.day)

# no mods
runner_ind = runner.multiplied("indulgence", 1.0) * (1 + 0.2 * runner_vibes)

@alefeld alefeld Aug 23, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to groundout_advance.ipynb it should include mods:

df["threshold_rounded"] = 0.50 \
                        + 0.35 * df["runner_indulgence_with_vibe"] \
                        - 0.10 * df["fielder_tenaciousness_with_vibe"] \
                        - 0.10 * (df["ballpark_inconvenience"] - 0.50) \
                        - 0.10 * (df["ballpark_elongation"] - 0.50)
    df[attr + "_scaled"] = df[attr] * df["batter_multiplier"]
    df[attr + "_with_vibe"] = df[attr + "_scaled"] * (1 + 0.2 * df["batter_vibes"])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I never got to seasons with hype... but I would guess anywhere we have vibes we should also have hype?

Comment thread formulas.py

fielder_tenac = fielder.multiplied(
"tenaciousness", get_multiplier(fielder, pitching_team, "fielder", "tenaciousness", meta, stadium)
) * (1 + 0.2 * fielder_vibes)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hype?

Comment thread formulas.py
runner_ind = runner.multiplied(
"indulgence", get_multiplier(runner, batting_team, "batter", "indulgence", meta, stadium)
)
runner_ind = runner_ind * (1 + 0.2 * runner_vibes)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hype?

Comment thread formulas.py
return 0.045 + 0.065 * runner_ind + 0.30 * runner_ind_sq - park_factor
elif advancing_from == 2:
return 0.45 + 0.35 * runner_ind - park_factor
else:

@alefeld alefeld Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error gets thrown 94% of the way through running resim.py because the 5th base leads to advancing_from == 3. We don't have a formula afaik, so maybe add a special case for the 5th base that just prints a warning for now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants