BASEBALL_GAME_LOGIC.TXT

Baseball Game Rules & Inning Flow

Game Setup

Pre-Game Selection

  1. Player Assignment
    • Player 1: HOME team
    • Player 2: AWAY team (VISITOR)
  2. Game Initialization
    • Starting inning: 1
    • Home team score: 0
    • Away team score: 0
    • All bases empty (1st, 2nd, 3rd)
    • Outs: 0
    • Balls: 0
    • Strikes: 0

Inning Structure

Each inning consists of two half-innings:

  1. TOP of inning - Away team (Player 2) bats
  2. BOTTOM of inning - Home team (Player 1) bats

Half-Inning Flow (One Team Batting)

Before First Batter

Each At-Bat (One Batter's Turn)

Step 1: Roll Dice

Step 2: Look Up Outcome

Step 3: Process Result Based on Outcome Type

IF OUTCOME = SINGLE:

IF OUTCOME = DOUBLE:

IF OUTCOME = TRIPLE:

IF OUTCOME = HOME RUN:

IF OUTCOME = WALK:

IF OUTCOME = SACRIFICE FLY:

IF OUTCOME = FLY OUT, GROUND OUT, or POP OUT:

IF OUTCOME = STRIKE OUT:

Step 4: Update Score Display

Step 5: Check for End of Half-Inning


Half-Inning Transitions

After Top of Inning (Away team finishes batting):

After Bottom of Inning (Home team finishes batting):


Game End Conditions

End of Regulation (9 Innings)

After Bottom of Inning 9 completes:

  1. Compare scores:
    • If HOME score > AWAY score: HOME team wins → Display final score and winner
    • If AWAY score > HOME score: AWAY team wins → Display final score and winner
    • If scores are tied: Continue to Extra Innings (proceed to Inning 10, 11, etc.)

Extra Innings (Inning 10+)

Extra innings follow the same rules as innings 1-9:

Game ends when:

  1. Display final score, winning team, and inning in which game ended
  2. Offer option to start new game

Data to Track Throughout Game


Key Rules Summary

  1. Three outs per half-inning - batting team switches when 3 outs occur
  2. Runners advance based on hit type - see above for each outcome
  3. Runners do NOT advance on outs (except sacrifice fly doesn't make them advance either)
  4. Runs score when runner reaches home plate - happens via advancing on hits
  5. Forced advances on walks - if bases loaded, runner on 3rd must score
  6. Game is 9 innings - (can be configured)
  7. Home team bats last - Top half = Away, Bottom half = Home (Away gets last chance to score)

Rules Confirmed

  1. No ties: Game continues into extra innings if tied after 9 innings
  2. Generic runner names: Use generic identifiers (Runner A, Runner B, etc.) rather than tracking individual player names
  3. Sacrifice fly: Batter is out, but all other runners advance by 1 base (runner on 3rd scores)
← Return to Baseball Game