feat(09-01): add dynamic time buffers for same-day game transitions

Implements conditional time buffer logic in canTransition():
- Same-day games (doubleheaders): 2hr post-game, 0.5hr pre-game
- Multi-day games: 3hr post-game, 1hr pre-game

Enables feasible same-day combinations (LA→SD) while preventing
infeasible distant pairings (LA→SF same day).

Makes tests pass:
- plan_SameDayGamesCloseCities_BothIncluded
- plan_ThreeSameDayGames_PicksFeasibleCombinations
This commit is contained in:
Trey t
2026-01-10 12:57:33 -06:00
parent 1c20d54b8b
commit 6e4a54e6dd

View File

@@ -511,12 +511,7 @@ enum GameDAGRouter {
let drivingHours = distanceMiles / 60.0
// Calculate available time
let departureTime = from.startTime.addingTimeInterval(gameEndBufferHours * 3600)
let deadline = to.startTime.addingTimeInterval(-3600) // 1 hour buffer before game
let availableHours = deadline.timeIntervalSince(departureTime) / 3600.0
// Calculate driving days available
// Check if same calendar day
let calendar = Calendar.current
let daysBetween = calendar.dateComponents(
[.day],
@@ -524,6 +519,27 @@ enum GameDAGRouter {
to: calendar.startOfDay(for: to.startTime)
).day ?? 0
// For same-day games (doubleheaders), use shorter buffers
// People leave earlier and arrive closer to game time
let postGameBuffer: Double
let preGameBuffer: Double
if daysBetween == 0 {
// Same-day doubleheader: leave during game, arrive at game time
postGameBuffer = 2.0 // Leave during/right after game
preGameBuffer = 0.5 // Arrive closer to start time
} else {
// Different days: use standard buffers
postGameBuffer = gameEndBufferHours // 3.0 hours
preGameBuffer = 1.0 // 1 hour before game
}
// Calculate available time
let departureTime = from.startTime.addingTimeInterval(postGameBuffer * 3600)
let deadline = to.startTime.addingTimeInterval(-preGameBuffer * 3600)
let availableHours = deadline.timeIntervalSince(departureTime) / 3600.0
// Calculate driving hours available
let maxDrivingHoursAvailable = daysBetween == 0
? max(0, availableHours)
: Double(daysBetween) * constraints.maxDailyDrivingHours