Marketplace
synchronization-algorithms
Network synchronization, lag compensation, client prediction, and state consistency for responsive multiplayer games.
$ Installer
git clone https://github.com/pluginagentmarketplace/custom-plugin-game-developer /tmp/custom-plugin-game-developer && cp -r /tmp/custom-plugin-game-developer/skills/synchronization-algorithms ~/.claude/skills/custom-plugin-game-developer// tip: Run this command in your terminal to install the skill
SKILL.md
name: synchronization-algorithms version: "2.0.0" description: | Network synchronization, lag compensation, client prediction, and state consistency for responsive multiplayer games. sasmp_version: "1.3.0" bonded_agent: 05-networking-multiplayer bond_type: PRIMARY_BOND
parameters:
- name: technique type: string required: false validation: enum: [prediction, interpolation, reconciliation, rollback, lockstep]
- name: game_type type: string required: false validation: enum: [fps, fighting, rts, mmo, racing]
retry_policy: enabled: true max_attempts: 5 backoff: exponential jitter: true
observability: log_events: [start, complete, error, desync] metrics: [prediction_error_ms, rollback_count, resync_frequency]
Multiplayer Synchronization
Synchronization Techniques
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SYNC TECHNIQUES OVERVIEW β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β CLIENT PREDICTION: β
β β Execute input locally before server confirms β
β β Feels responsive, requires reconciliation β
β Best for: FPS, action games β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β INTERPOLATION: β
β β Display positions between known states β
β β Smooth visuals, adds latency β
β Best for: Other players, NPCs β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β ROLLBACK NETCODE: β
β β Rewind game state on correction β
β β Re-simulate with corrected data β
β Best for: Fighting games, precise timing β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β LOCKSTEP: β
β β All clients advance together β
β β Deterministic, waits for slowest β
β Best for: RTS, turn-based β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Client Prediction & Reconciliation
PREDICTION FLOW:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frame N: β
β 1. Capture input β
β 2. Predict result locally (immediate response) β
β 3. Store input + predicted state β
β 4. Send input to server β
β β
β Frame N+RTT: β
β 5. Receive server state for Frame N β
β 6. Compare with stored prediction β
β 7. If mismatch: RECONCILE β
β a. Snap to server state β
β b. Re-apply all inputs since Frame N β
β c. Smooth correction to avoid visual pop β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// β
Production-Ready: Prediction Buffer
public class PredictionBuffer
{
private const int BUFFER_SIZE = 128;
private readonly PredictionEntry[] _buffer = new PredictionEntry[BUFFER_SIZE];
public void Store(uint tick, InputPayload input, PlayerState predictedState)
{
int index = (int)(tick % BUFFER_SIZE);
_buffer[index] = new PredictionEntry
{
Tick = tick,
Input = input,
PredictedState = predictedState
};
}
public void Reconcile(uint serverTick, PlayerState serverState)
{
int index = (int)(serverTick % BUFFER_SIZE);
var entry = _buffer[index];
if (entry.Tick != serverTick) return; // Stale data
float error = Vector3.Distance(entry.PredictedState.Position, serverState.Position);
if (error < 0.01f) return; // Within tolerance
// Misprediction detected - reconcile
PlayerState currentState = serverState;
// Re-simulate all inputs since server tick
for (uint t = serverTick + 1; t <= CurrentTick; t++)
{
int idx = (int)(t % BUFFER_SIZE);
if (_buffer[idx].Tick == t)
{
currentState = SimulateInput(currentState, _buffer[idx].Input);
}
}
// Apply corrected state (with smoothing)
ApplyCorrectedState(currentState);
}
}
Interpolation
INTERPOLATION BUFFER:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β RECEIVE: [State T-100ms] [State T-50ms] [State T-now] β
β β
β RENDER: Display interpolated position between T-100ms β
β and T-50ms based on current render time β
β β
β WHY: Always have two states to interpolate between β
β (render behind real-time by buffer amount) β
β β
β BUFFER SIZE: β
β β’ Too small: Choppy when packets delayed β
β β’ Too large: Everything feels delayed β
β β’ Typical: 100-200ms for other players β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Rollback Netcode
ROLLBACK FLOW (Fighting Games):
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 1. Execute frame with predicted opponent input β
β 2. Store complete game state snapshot β
β 3. When actual input arrives: β
β a. If matches prediction: continue β
β b. If mismatch: β
β - Load snapshot from that frame β
β - Re-simulate all frames with correct input β
β - "Rollback" visual to corrected state β
β 4. Hide rollbacks with animation tricks β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ROLLBACK LIMITS:
β’ Max rollback: 7-8 frames (~116ms at 60fps)
β’ Beyond: Game stutters or desyncs
β’ Input delay trade-off: 0-3 frames pre-delay
Lockstep Synchronization
LOCKSTEP (RTS Games):
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frame 0: All clients send inputs β
β Wait for all inputs β
β Execute deterministically β
β β
β Frame 1: Repeat β
β β
β REQUIREMENTS: β
β β’ Deterministic simulation (fixed-point math) β
β β’ Synchronized RNG seeds β
β β’ Identical execution order β
β β
β PROS: Minimal bandwidth (only inputs) β
β CONS: Latency = slowest player, input delay β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π§ Troubleshooting
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PROBLEM: Visible rubber-banding β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β SOLUTIONS: β
β β Increase interpolation buffer β
β β Smooth reconciliation (lerp, not snap) β
β β Add visual damping β
β β Check for consistent tick rate β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PROBLEM: Clients desyncing β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β SOLUTIONS: β
β β Use fixed-point math β
β β Sync random number seeds β
β β Periodic full-state resync β
β β Add state hash verification β
β β Check floating-point determinism β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PROBLEM: Too many rollbacks (fighting games) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β SOLUTIONS: β
β β Add input delay frames (1-3) β
β β Better input prediction β
β β Limit max rollback frames β
β β Disconnect players with bad connections β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Technique Selection
| Game Type | Primary | Secondary | Latency Budget |
|---|---|---|---|
| FPS | Prediction | Interpolation | 50-100ms |
| Fighting | Rollback | Input delay | 50-80ms |
| RTS | Lockstep | - | 200-500ms |
| MMO | Interpolation | Prediction | 100-200ms |
| Racing | Prediction | Extrapolation | 50-100ms |
Use this skill: When building multiplayer systems, optimizing netcode, or fixing desync issues.
Repository

pluginagentmarketplace
Author
pluginagentmarketplace/custom-plugin-game-developer/skills/synchronization-algorithms
1
Stars
0
Forks
Updated3d ago
Added1w ago