-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Parent Issue: #180
Objective
Replace fixed safety buffer (75% of pot width) with dynamic calculation based on current conditions.
Current Problem
Static safety margin of 0.75 * potRimWidth doesn't account for:
- Chef's current speed (faster = need more margin)
- Egg's horizontal velocity (faster eggs = harder to catch)
- Remaining reaction time (less time = need more margin)
Proposed Solution
function calculateDynamicSafetyMargin(
chef: ChefData,
egg: EggData,
timeToCatch: number
): number {
const baseMargin = chef.potRimWidth * 0.5; // Start at 50%
// Adjust for chef speed (0-1 normalized)
const speedFactor = Math.abs(chef.speed) / chef.speedLimit;
// Adjust for egg horizontal velocity
const eggSpeedFactor = Math.abs(egg.henCurrentTweenSpeed) / 10; // normalize
// Adjust for urgency (less time = more margin needed)
const urgencyFactor = Math.max(0, 1 - timeToCatch / 5); // 5 seconds as baseline
return baseMargin * (1 + speedFactor * 0.3 + eggSpeedFactor * 0.2 + urgencyFactor * 0.25);
}Implementation Details
- Add
calculateDynamicSafetyMargin()intests/machines/helpers.ts - Replace hardcoded
0.75 * potRimWidthinisEggReachable() - Tune weight factors through testing
- Add visualization option for debugging margin sizes
Impact
- More accurate reachability calculations
- Fewer edge-of-pot misses
- Better performance with fast-moving eggs
Success Metrics
- Reduced "almost caught it" misses
- Maintained catch rate with tighter margins
- Better performance at higher game speeds
Reactions are currently unavailable