7 min read AI / Baseball 2026

BaseHit's AI: Pitching Intelligence That Adapts

Baseball is a game of chess at 90mph. BaseHit's AI pitcher doesn't throw randomly — it watches your timing, learns your habits, and adjusts pitch selection with remarkable precision. No machine learning required.

What Makes Our AI Different

The BaseHit AI pitcher creates an intelligent opponent through elegant rule-based design. It watches your timing patterns in real-time and adapts pitch selection strategically—all without machine learning.

Timing Bias Detection

AI analyzes your last 5 swings to detect if you're consistently early, late, or balanced. Then it selects pitches that exploit those patterns.

Adaptive Speed Adjustment

Pitch velocities adjust based on your swing timing. Early swings get slower pitches, late swings get faster ones. It feels like the pitcher is reading you.

Smart Zone Targeting

Five pitch zones (center, inside, outside, high, low) with varying home run multipliers. Difficulty-based zone distribution means harder opponents pitch to tougher locations.

Pitch Variety Prevention

The AI never throws the same pitch 3 times consecutively. Strategic sequencing keeps you honest without requiring complex models.

The AI Systems Under the Hood

BaseHit's AI pitcher is powered by three interconnected systems that work together to create a cohesive, intelligent opponent:

Timing Bias Detector

Tracks your last 5 swing timings and classifies you as 'early', 'late', or 'balanced'. Automatically selects pitch distributions that exploit this bias.

Pitch Selection Engine

Rule-based decision-making that considers difficulty level, pitch variety prevention, and timing bias to choose the next pitch type and zone.

Adaptive Speed Calculator

Adjusts pitch velocity based on your swing timing patterns. Early swings trigger slower pitches; late swings get speed boosts. Perfect swings trigger penalty speeds.

Reactive Fielding

Simple reactive fielders (3 outfielders) that chase hits and play animated reactions. No shift AI or spray chart analysis—pure reactive animation.

Technical Deep Dive

For the technically curious, here's how the timing bias detection system creates genuine adaptive AI without complex machine learning:

Timing Bias Detection Algorithm

The core innovation: analyzing swing timing to detect and exploit patterns. The system tracks the last 5 swing events:

// Calculate swing timing relative to perfect window
const timingBias = analyzeLastFiveSwings([
  { swing_time: 245, perfect_window: [250, 318] },  // 5ms EARLY
  { swing_time: 260, perfect_window: [250, 318] },  // 10ms EARLY
  { swing_time: 255, perfect_window: [250, 318] },  // BALANCED
  { swing_time: 248, perfect_window: [250, 318] },  // 2ms EARLY
  { swing_time: 330, perfect_window: [250, 318] },  // 12ms LATE
]);

// Result: Player classified as 'early' bias
const classification = classifyBias(timingBias);
// Returns: 'early' | 'late' | 'balanced'

Pitch Selection Based on Timing Bias

Once bias is detected, the AI selects pitch distributions that exploit it:

function decidePitch(timingBias, difficulty) {
  let pitchDistribution;

  if (timingBias === 'early') {
    // Throw more breaking balls (slower)
    // 35% curveball, 20% changeup, 45% fastball
    pitchDistribution = {
      curveball: 0.35,
      changeup: 0.20,
      fastball: 0.45
    };
  }
  else if (timingBias === 'late') {
    // Throw more fastballs (faster)
    // Exploit late timing with velocity
    pitchDistribution = {
      fastball: 0.60,
      curveball: 0.20,
      changeup: 0.20
    };
  }
  else {
    // Balanced: use difficulty-based distribution
    pitchDistribution = getDifficultyPitchDistribution(difficulty);
  }

  // Prevent same pitch 3x consecutively
  if (lastThreePitches.allSame()) {
    return selectDifferentPitch(pitchDistribution);
  }

  return selectRandomFromDistribution(pitchDistribution);
}

Adaptive Speed Calculation

Pitch speed adjusts in real-time based on swing patterns. This creates the illusion of an opponent that reads you:

function getAdaptiveSpeed(basePitchSpeed, timingBias) {
  let speedMultiplier = 1.0;

  if (timingBias === 'early') {
    // 20% slower for early swings
    speedMultiplier = 0.80;
  }
  else if (timingBias === 'late') {
    // 4-12% faster for late swings
    speedMultiplier = 1.04 + Math.random() * 0.08;
  }

  // Penalty speed boost for recent perfect swings
  if (recentPerfectSwings >= 2) {
    // Boost 10% if pitcher "responds" to perfect contact
    speedMultiplier *= 1.10;
  }

  const finalSpeed = basePitchSpeed * speedMultiplier;

  // Clamp to valid range: 150-800 px/sec
  return Math.max(150, Math.min(800, finalSpeed));
}

Five Pitch Zones & Home Run Multipliers

Pitch zones vary in difficulty and home run potential. Harder difficulties favor tougher zones:

Pitch Zones & HR Multipliers
HIGH (0.8x HR) | INSIDE CENTER OUTSIDE (1.3x) (1.0x) (0.7x) | LOW (0.6x HR) Zone Selection by Difficulty: - Easy: 70% CENTER, 10% each corner - Medium: 50% CENTER, 15% each side, 10% high/low - Hard: 30% CENTER, 20% INSIDE, 20% OUTSIDE, 15% HIGH, 15% LOW (toughest zones) - Legend: 10% CENTER, 25% INSIDE, 25% OUTSIDE, 20% HIGH, 20% LOW (nearly unplayable)

Pitch Types

Four pitch types with different characteristics:

Difficulty Tiers

Difficulty scales four key variables: pitch speed, perfect window size, curve percentage, and zone difficulty:

Game Mechanics: Player as Batter Only

BaseHit is fundamentally about batting strategy. The player controls one action: swinging with two stances:

5 at-bats per game (7 for boss levels). The 100-level campaign includes combo multipliers and power-ups that boost scoring without changing pitch selection.

Key Design Insight: This timing bias system is elegant game design that feels intelligent without requiring neural networks. By adapting pitch selection and speed based on observable swing timing, the AI creates the perception of machine learning while remaining fully rule-based and transparent to the player.

What About mlDataStore?

You'll notice BaseHit has an mlDataStore that logs swing events: timing, pitch type, and result. This is for analytics and future reference only. The AI never reads from this data. Pitch decisions are made purely from the current game's last 5 swings, not historical patterns across sessions.

This separation is intentional: it keeps the AI transparent and ensures every game is fair, without hidden training from your past mistakes.

Why Rule-Based > Machine Learning (for Baseball)

BaseHit deliberately avoids neural networks and complex ML models. Here's why this rule-based approach is superior for baseball game design:

Core Philosophy: Baseball is about reading the pitcher. BaseHit's AI is designed to be read—it has consistent, learnable patterns. That's good game design.

Future Enhancements

The rule-based foundation is solid and extensible. Future updates might include:

Experience AI Baseball

Ready to face an opponent that adapts to your strengths and exposes your weaknesses? Step into the batter's box today.

Back to ExaFabs