aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/blog/game.md (renamed from src/game.md)0
-rw-r--r--src/images/favicon.icobin0 -> 46927 bytes
-rw-r--r--src/index.md2
-rw-r--r--src/misc/gambetta.md51
-rw-r--r--src/notes/ase.md (renamed from src/ase.md)0
-rw-r--r--src/notes/spo.md (renamed from src/spo.md)0
-rw-r--r--src/styles/style.css10
7 files changed, 58 insertions, 5 deletions
diff --git a/src/game.md b/src/blog/game.md
index 0f5b681..0f5b681 100644
--- a/src/game.md
+++ b/src/blog/game.md
diff --git a/src/images/favicon.ico b/src/images/favicon.ico
new file mode 100644
index 0000000..d537e87
--- /dev/null
+++ b/src/images/favicon.ico
Binary files differ
diff --git a/src/index.md b/src/index.md
index aafa6bb..ff2470e 100644
--- a/src/index.md
+++ b/src/index.md
@@ -8,4 +8,4 @@ I occasionally post videos of my game along with other stuff [here](https://yout
## Posts
-➤ [Project Aftershock](/game "2021-05-07")
+➤ [Project Aftershock](/blog/game "2021-05-07")
diff --git a/src/misc/gambetta.md b/src/misc/gambetta.md
new file mode 100644
index 0000000..ef5978b
--- /dev/null
+++ b/src/misc/gambetta.md
@@ -0,0 +1,51 @@
+<p id="date"><em>2022-09-27</em></p>
+
+# Fast-Paced Multiplayer (Part I): Client-Server Game Architecture {#title}
+
+## Introduction
+
+This is the first in a series of articles exploring the techniques and algorithms that make fast-paced multiplayer games possible. If you’re familiar with the concepts behind multiplayer games, you can safely skip to the next article – what follows is an introductory discussion.
+
+Developing any kind of game is itself challenging; multiplayer games, however, add a completely new set of problems to be dealt with. Interestingly enough, the core problems are human nature and physics!
+
+## The problem of cheating
+
+It all starts with cheating.
+
+As a game developer, you usually don’t care whether a player cheats in your single-player game – their actions don’t affect anyone but him. A cheating player may not experience the game exactly as you planned, but since it’s their game, they have the right to play it in any way they please.
+
+Multiplayer games are different, though. In any competitive game, a cheating player isn’t just making the experience better for himself, they’re also making the experience worse for the other players. As the developer, you probably want to avoid that, since it tends to drive players away from your game.
+
+There are many things that can be done to prevent cheating, but the most important one (and probably the only really meaningful one) is simple : *don’t trust the player*. Always assume the worst – that players *will* try to cheat.
+
+## Authoritative servers and dumb clients
+
+This leads to a seemingly simple solution – you make everything in your game happen in a central server under your control, and make the clients just privileged spectators of the game. In other words, your game client sends inputs (key presses, commands) to the server, the server runs the game, and you send the results back to the clients. This is usually called using an *authoritative server*, because the one and only authority regarding everything that happens in the world is the server.
+
+Of course, your server can be exploited for vulnerabilities, but that’s out of the scope of this series of articles. Using an authoritative server does prevent a wide range of hacks, though. For example, you don’t trust the client with the health of the player; a hacked client can modify its local copy of that value and tell the player it has 10000% health, but the server *knows* it only has 10% – when the player is attacked it will die, regardless of what a hacked client may think.
+
+You also don’t trust the player with its position in the world. If you did, a hacked client would tell the server “**I’m at (10,10)**” and a second later “**I’m at (20,10)**”, possibly going through a wall or moving faster than the other players. Instead, the server *knows* the player is at (10,10), the client tells the server “**I want to move one square to the right**”, the server updates its internal state with the new player position at (11,10), and then replies to the player “**You’re at (11, 10)**”:
+
+![alt text](https://www.gabrielgambetta.com/img/fpm1-01.png)
+
+In summary: the game state is managed by the server alone. Clients send their actions to the server. The server updates the game state periodically, and then sends the new game state back to clients, who just render it on the screen.
+
+## Dealing with networks
+
+The dumb client scheme works fine for slow turn based games, for example strategy games or poker. It would also work in a LAN setting, where communications are, for all practical purposes, instantaneous. But this breaks down when used for a fast-paced game over a network such as the internet.
+
+Let’s talk physics. Suppose you’re in San Francisco, connected to a server in the NY. That’s approximately 4,000 km, or 2,500 miles (that’s roughly the distance between Lisbon and Moscow). Nothing can travel faster than light, not even bytes on the Internet (which at the lower level are pulses of light, electrons in a cable, or electromagnetic waves). Light travels at approximately 300,000 km/s, so it takes 13 ms to travel 4,000 km.
+
+This may sound quite fast, but it’s actually a very optimistic setup – it assumes data travels at the speed of light in a straight path, with is most likely not the case. In real life, data goes through a series of jumps (called *hops* in networking terminology) from router to router, most of which aren’t done at lightspeed; routers themselve introduce a bit of delay, since packets must be copied, inspected, and rerouted.
+
+For the sake of the argument, let’s assume data takes 50 ms from client to server. This is close to a best-case scenario – what happens if you’re in NY connected to a server in Tokyo? What if there’s network congestion for some reason? Delays of 100, 200, even 500 ms are not unheard of.
+
+Back to our example, your client sends some input to the server (“**I pressed the right arrow**”). The server gets it 50 ms later. Let’s say the server processes the request and sends back the updated state immediately. Your client gets the new game state (“**You’re now at (1, 0)**”) 50 ms later.
+
+From your point of view, what happened is that you pressed the right arrow but nothing happened for a tenth of a second; then your character finally moved one square to the right. This perceived *lag* between your inputs and its consequences may not sound like much, but it’s noticeable – and of course, a lag of half a second isn’t just noticeable, it actually makes the game unplayable.
+
+## Summary
+
+Networked multiplayer games are incredibly fun, but introduce a whole new class of challenges. The authoritative server architecture is pretty good at stopping most cheats, but a straightforward implementation may make games quite unresponsive to the player.
+
+In the following articles, we’ll explore how can we build a system based on an authoritative server, while minimizing the delay experienced by the players, to the point of making it almost indistinguishable from local or single player games.
diff --git a/src/ase.md b/src/notes/ase.md
index 5618803..5618803 100644
--- a/src/ase.md
+++ b/src/notes/ase.md
diff --git a/src/spo.md b/src/notes/spo.md
index 06d676e..06d676e 100644
--- a/src/spo.md
+++ b/src/notes/spo.md
diff --git a/src/styles/style.css b/src/styles/style.css
index 61b4732..f932d79 100644
--- a/src/styles/style.css
+++ b/src/styles/style.css
@@ -1,8 +1,8 @@
:root {
- --bg: #f3f3f3;
+ --bg: #fafafa;
--fg: #181a1b;
--link: #175db6;
- --code: #e8e8e8;
+ --code: #efefef;
--footer: #828997;
--home-link: #c02c38;
--quote-border: #c678dd;
@@ -26,7 +26,7 @@ html {
body {
font: 1em/1.6 'Open Sans', sans-serif;
margin: 0 auto;
- max-width: 46em;
+ max-width: 50em;
padding: 0em 1em;
}
@@ -75,7 +75,9 @@ code {
}
p img, table {
- max-width: 100%;
+ max-width: 95%;
+ margin-top: 2.2em;
+ margin-bottom: 2.2em;
}
img {