logo

Babylon.js Market

By Lawrence

5 minutes

The single-player table you finished works well, but only for one person. Four people can't sit at it. The easy fix is a game server. That server would hold the deck, shuffle it, and tell each browser what it can see. We're not building that. So here is the question this whole course answers. With no referee in the middle, how do four browsers agree on a shuffled deck?

A mesh of browsers, not a server

Picture four browsers wired straight to each other. This is a peer mesh. Every browser is equal, and no host owns the truth. The only thing that crosses a wire is intent: "seat 2 folds," or "deal the next hand." The cards themselves are never sent. Each browser builds the deck on its own. Every browser runs the same shuffle from the same seed, so they all end up with the same 52 cards in the same order. They never send a single card. Someone could still try to cheat by tampering, and that matters in production. But the core idea is simple. Agreement comes from deterministic math, not from a trusted authority.

A server-authoritative table versus a deterministic peer mesh

This lesson adds no entities to your scene. It's a pure module: plain functions that work on numbers and strings. Nothing here imports Babylon, the DOM, or the network. So every peer can run it and get the same result. And you can test it without a second machine.

Continue reading

Unlock the Full Course

Every lesson, the runnable examples, and the finished build — yours to keep.

$9one-time

Was this page helpful?

We read every note — tell us what's working and what isn't.

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search