multiplayer-netcode
Use when the user asks about multiplayer netcode, client-side prediction and server reconciliation, entity interpolation, rollback netcode, GGPO, lag…
от j4flmao★ 47 звёзд на GitHub
Установить multiplayer-netcode в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Multiplayer Netcode — Deep Guide
Purpose
Building robust multiplayer requires understanding latency, jitter, bandwidth, and how to hide them. This guide covers the full stack: transport, protocol design, client-server architecture, prediction, reconciliation, interpolation, lag compensation, rollback, and scalability.
Agent Protocol
Trigger
"multiplayer", "netcode", "client prediction", "server reconciliation", "entity interpolation", "rollback netcode", "lag compensation", "GGPO".
Input Context
- Genre and player count
- Engine and transport
- Latency targets and authority model
Output Artifact
Netcode design and code. No file unless requested.
Response Format
Model: {client-server | rollback}
Tick/send rates: {Hz}
Latency hiding: {technique}
Code: {snippet}
1. The Problem: The Network Is the Enemy
Typical round-trip times (RTT):
LAN: < 5 ms
Same region: 20-60 ms
Cross-continent: 100-200 ms (+ Wi-Fi/mobile jitter and loss)
Every client sees the world at least RTT/2 old; netcode decides who pays for that delay (the shooter, the target, or nobody via prediction).
Netcode turns "what happened at t" into "what each client believes happened at t".
2. Transport Layer
2.1 UDP vs TCP
| Aspect | TCP | UDP |
|---|---|---|
| Delivery | guaranteed, ordered | best-effort |
| Use | HTTP auth, file sync, chat | game state every frame |
| Problem | head-of-line blocking, retransmit stalls | reordering, loss |
Rule: game-critical state on UDP (custom reliable layer or RakNet-like reliable-UDP).
2.2 Reliable & Unreliable Channels
Split messages into channels:
- Unreliable (most important): position snapshots, input (recent is enough).
- Reliable ordered: login, join, inventory, item drop events.
- Reliable unordered: individual events with own ordering (per-entity).
Reliable-UDP: every packet carries its sequence number plus the latest received sequence and a 32-bit ack bitfield for the previous 32 packets, so each packet acknowledges many; lost reliable messages are re-sent in a later packet (not the same packet retransmitted).
2.3 Packet Layout
[Magic][Seq#][Ack#][AckBits][MessageCount][Message0][Message1]...
Header + per-message headers with bitpacking. Aim <1200B (Ethernet MTU 1500 minus IP/UDP headers); fragment bigger messages.
3. Architectures
3.1 Server-Authoritative (Mostly Standard)
Client ----inputs----> Server ----authoritative state----> Clients
<----snapshots (30-60Hz)----
- Server owns physics/gameplay. Clients send inputs and predict locally.
- Fair, cheat-resistant. Used by FPS (Valve, Overwatch, Fortnite).
3.2 P2P with Host Migration
- One peer is host with authority; migrating host on disconnect.
- Simpler for small games (party-based). Risk: host advantages.
3.3 P2P Lockstep (RTS)
- Every peer runs the SAME deterministic sim; inputs are exchanged and executed in lockstep with a fixed delay.
- Determinism is mandatory (fixed-point float discipline). Tiny bandwidth, perfect determinism → replays trivial.
- Problem: waits for the slowest peer per tick.
3.4 Client/Server vs P2P decision
| Game | Type |
|---|---|
| Competitive FPS/MOBA | server-authoritative + prediction |
| Top-down RTS/co-op | lockstep deterministic |
| Small co-op party | listen server with a client |
| Battle royale (40+ players) | dedicated server clusters |
4. Core Algorithms
4.1 Client-Side Prediction (Input-Based)
Client runs a local simulation of its controlled entity:
struct InputState { bool forward, back, left, right, fire; uint16_t seq; };
void ClientFrame() {
InputState in = CaptureInput();
pending.push_back({in, localTick});
ApplyToLocalSimulation(in); // PREDICT immediately
SendInputToServer(in); // UNRELIABLE channel
}
4.2 Server Reconciliation
Authoritative snapshots from server; client compares against its own predicted saved state at that point in time:
Server sends: tick, position, velocity, HP
Client: find the local state saved under same tick (input seq)
if position differs by > threshold -> snap BACK correction,
then re-apply all pending inputs up to now (fast-forward)
void OnSnapshot(tick, serverState) {
Saved& saved = history[tick];
if (distance(saved.pos, serverState.pos) > tolerance) {
world.state = serverState; // correct
for (pending input after tick) ApplyToLocalSimulation(input); // re-simulate
}
}
4.3 Interpolation (Visual Smoothing for Remote Entities)
Render other players via interpolation, not prediction:
- Keep a buffer of the last ~100ms of received snapshots.
- Render at
serverTime - interpolationDelay, where the delay covers ~2 snapshot intervals plus jitter (e.g. ~100 ms at 20 Hz snapshots) — it is independent of RTT. - For jitter: Jitter Buffer (s
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/merged-game-engine-multiplayer-netcode.md
FAQ
Что делает скилл multiplayer-netcode?
Use when the user asks about multiplayer netcode, client-side prediction and server reconciliation, entity interpolation, rollback netcode, GGPO, lag compensation for a shooter or choosing a transport. Produces gameplay netcode design and code. Not for server tick and fleet design (use authoritative-server or scaling-architecture).
Как установить скилл multiplayer-netcode?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл multiplayer-netcode запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…