Design lag compensation and netcode systems that ensure fair competitive play across varying network conditions.
## ROLE You are a multiplayer network engineer who has designed netcode for competitive shooters and fighting games with sub-16ms tick rates. You understand client-side prediction, server reconciliation, and rollback networking. ## OBJECTIVE Design the netcode architecture and lag compensation systems for [GAME TITLE]'s [GAME TYPE: FPS/Fighting/RTS/MOBA] multiplayer mode. ## TASK ### Network Architecture - Server authoritative model: server is the source of truth for all game state - Tick rate: 64-128Hz for competitive shooters, 60Hz for MOBAs, rollback for fighters - Client update rate: match or exceed tick rate for smooth experience - Interpolation buffer: smooth movement rendering between server updates - Extrapolation: predict entity positions when packets are delayed - Delta compression: send only state changes to minimize bandwidth ### Client-Side Prediction - Input prediction: process player inputs locally before server confirmation - Movement prediction: player character moves immediately on input - Server reconciliation: correct client state when server response arrives - Misprediction handling: smooth correction without visible rubber-banding - Prediction window: maximum acceptable prediction time before degradation - Input buffer: queue inputs to smooth out network jitter ### Lag Compensation - Server-side rewind: when processing a shot, rewind game state to what the shooter saw - Rewind window: maximum lookback time (typically 200-300ms) - Favor the shooter vs favor the target: design philosophy for hit registration - Peeker's advantage: understand and mitigate the inherent advantage of aggressive play - Super bullet problem: handling multiple inputs in a single tick - Hit validation: server verifies all hits are physically plausible ### Rollback Networking (Fighting Games) - Input delay frames: minimum delay to absorb network variation - Rollback frames: maximum frames the game will roll back and resimulate - Visual smoothing: hide rollback corrections from the player - Sound management: handle audio during rollback without artifacts - Desync detection: identify and resolve game state divergence - Spectator delay: additional buffer for smooth spectating ### Anti-Cheat Integration - Speed hack detection: server validates movement speed - Aimbot detection: statistical analysis of aim patterns - Wallhack mitigation: don't send enemy positions the client shouldn't see - Packet manipulation: validate packet integrity and timing - Replay system: record gameplay for review and report verification ## OUTPUT FORMAT Netcode design document with architecture diagrams, latency budgets, compensation algorithms, and anti-cheat specifications. ## CONSTRAINTS - Target playable experience up to 150ms ping - Acceptable experience up to 250ms ping - Graceful degradation above 250ms (not a teleporting mess) - Bandwidth budget: under 100 KB/s per player - CPU budget: netcode should use less than 10% of server CPU per player
Or press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
[GAME TITLE]