Multiplayer skill

Multiplayer game development principles.

by davila7·MIT license·★ 32,299 Stars on the repo·GitHub ↗

Use now

Files of Multiplayer

davila7/main1 file shown
SKILL.md
Show the full text133 lines

Multiplayer Game Development

Networking architecture and synchronization principles.


1. Architecture Selection

Decision Tree
What type of multiplayer?
│
├── Competitive / Real-time
│   └── Dedicated Server (authoritative)
│
├── Cooperative / Casual
│   └── Host-based (one player is server)
│
├── Turn-based
│   └── Client-server (simple)
│
└── Massive (MMO)
    └── Distributed servers
Comparison
Architecture Latency Cost Security
Dedicated Low High Strong
P2P Variable Low Weak
Host-based Medium Low Medium

2. Synchronization Principles

State vs Input
Approach Sync What Best For
State Sync Game state Simple, few objects
Input Sync Player inputs Action games
Hybrid Both Most games
Lag Compensation
Technique Purpose
Prediction Client predicts server
Interpolation Smooth remote players
Reconciliation Fix mispredictions
Lag compensation Rewind for hit detection

3. Network Optimization

Bandwidth Reduction
Technique Savings
Delta compression Send only changes
Quantization Reduce precision
Priority Important data first
Area of interest Only nearby entities
Update Rates
Type Rate
Position 20-60 Hz
Health On change
Inventory On change
Chat On send

4. Security Principles

Server Authority
Client: "I hit the enemy"
Server: Validate → did projectile actually hit?
         → was player in valid state?
         → was timing possible?
Anti-Cheat
Cheat Prevention
Speed hack Server validates movement
Aimbot Server validates sight line
Item dupe Server owns inventory
Wall hack Don't send hidden data

5. Matchmaking

Considerations
Factor Impact
Skill Fair matches
Latency Playable connection
Wait time Player patience
Party size Group play

6. Anti-Patterns

❌ Don't ✅ Do
Trust the client Server is authority
Send everything Send only necessary
Ignore latency Design for 100-200ms
Sync exact positions Interpolate/predict

Remember: Never trust the client. The server is the source of truth.

1---
2name: multiplayer
3description: Multiplayer game development principles. Architecture, networking, synchronization.
4allowed-tools: Read, Write, Edit, Glob, Grep, Bash
5---
6 
7# Multiplayer Game Development
8 
9> Networking architecture and synchronization principles.
10 
11---
12 
13## 1. Architecture Selection
14 
15### Decision Tree
16 
17```
18What type of multiplayer?
19│
20├── Competitive / Real-time
21│ └── Dedicated Server (authoritative)
22│
23├── Cooperative / Casual
24│ └── Host-based (one player is server)
25│
26├── Turn-based
27│ └── Client-server (simple)
28│
29└── Massive (MMO)
30 └── Distributed servers
31```
32 
33### Comparison
34 
35| Architecture | Latency | Cost | Security |
36|--------------|---------|------|----------|
37| **Dedicated** | Low | High | Strong |
38| **P2P** | Variable | Low | Weak |
39| **Host-based** | Medium | Low | Medium |
40 
41---
42 
43## 2. Synchronization Principles
44 
45### State vs Input
46 
47| Approach | Sync What | Best For |
48|----------|-----------|----------|
49| **State Sync** | Game state | Simple, few objects |
50| **Input Sync** | Player inputs | Action games |
51| **Hybrid** | Both | Most games |
52 
53### Lag Compensation
54 
55| Technique | Purpose |
56|-----------|---------|
57| **Prediction** | Client predicts server |
58| **Interpolation** | Smooth remote players |
59| **Reconciliation** | Fix mispredictions |
60| **Lag compensation** | Rewind for hit detection |
61 
62---
63 
64## 3. Network Optimization
65 
66### Bandwidth Reduction
67 
68| Technique | Savings |
69|-----------|---------|
70| **Delta compression** | Send only changes |
71| **Quantization** | Reduce precision |
72| **Priority** | Important data first |
73| **Area of interest** | Only nearby entities |
74 
75### Update Rates
76 
77| Type | Rate |
78|------|------|
79| Position | 20-60 Hz |
80| Health | On change |
81| Inventory | On change |
82| Chat | On send |
83 
84---
85 
86## 4. Security Principles
87 
88### Server Authority
89 
90```
91Client: "I hit the enemy"
92Server: Validate → did projectile actually hit?
93 → was player in valid state?
94 → was timing possible?
95```
96 
97### Anti-Cheat
98 
99| Cheat | Prevention |
100|-------|------------|
101| Speed hack | Server validates movement |
102| Aimbot | Server validates sight line |
103| Item dupe | Server owns inventory |
104| Wall hack | Don't send hidden data |
105 
106---
107 
108## 5. Matchmaking
109 
110### Considerations
111 
112| Factor | Impact |
113|--------|--------|
114| **Skill** | Fair matches |
115| **Latency** | Playable connection |
116| **Wait time** | Player patience |
117| **Party size** | Group play |
118 
119---
120 
121## 6. Anti-Patterns
122 
123| ❌ Don't | ✅ Do |
124|----------|-------|
125| Trust the client | Server is authority |
126| Send everything | Send only necessary |
127| Ignore latency | Design for 100-200ms |
128| Sync exact positions | Interpolate/predict |
129 
130---
131 
132> **Remember:** Never trust the client. The server is the source of truth.
133 

Discussion