feat(complement-race): enable adaptive AI difficulty in arcade

Implemented adaptive AI speed adjustment based on player performance:
- Added UPDATE_AI_SPEEDS handler to update clientAIRacers speeds
- Added UPDATE_DIFFICULTY_TRACKER handler to update local state
- Now matches solo game behavior where AI speeds adapt to challenge

AI speeds adjust based on:
- Player success rate (0.5x to 1.6x multiplier)
- Average response time (faster players get faster AI)
- Current streak (hot streaks increase challenge)
- Learning mode (no adaptation until sufficient data)

This provides dynamic difficulty balancing, making the game
engaging for both beginners and advanced players.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Thomas Hallock
2025-10-18 09:24:49 -05:00
parent f735e5d3ba
commit 55010d2bcd

View File

@@ -842,12 +842,34 @@ export function ComplementRaceProvider({ children }: { children: ReactNode }) {
}
break
}
case 'UPDATE_AI_SPEEDS': {
// Update client-side AI speeds (adaptive difficulty)
if (action.racers && Array.isArray(action.racers)) {
setClientAIRacers((prevRacers) =>
prevRacers.map((racer) => {
const update = action.racers.find(
(r: { id: string; speed: number }) => r.id === racer.id
)
return update
? {
...racer,
speed: update.speed,
}
: racer
})
)
}
break
}
case 'UPDATE_DIFFICULTY_TRACKER': {
// Update local difficulty tracker state
setLocalUIState((prev) => ({ ...prev, difficultyTracker: action.tracker }))
break
}
// Other local actions that don't affect UI (can be ignored for now)
case 'UPDATE_MOMENTUM':
case 'UPDATE_TRAIN_POSITION':
case 'UPDATE_STEAM_JOURNEY':
case 'UPDATE_DIFFICULTY_TRACKER':
case 'UPDATE_AI_SPEEDS':
case 'GENERATE_PASSENGERS': // Passengers generated server-side when route starts
case 'COMPLETE_ROUTE':
case 'HIDE_ROUTE_CELEBRATION':