ravens-engine / core

A Javascript library for building multiplayer turn-based games
https://ravens.dev/
15 stars 2 forks source link

Add randomness #3

Closed Longwelwind closed 3 years ago

Longwelwind commented 3 years ago

Games have randomness (shuffle a stack of cards, roll a dice, ...). Since Ravens relies on a deterministic model to properly update the state of the game on the server and on each clients, a special mechanism must be created to allow for randomness.

At it's core, it's quite simple: server-side, before applying an operation, the game must generate a seed and make it available through an API to processAction. When broadcasting the operation to the clients, the server should also send the seed so that the clients can correctly synchronizes their state.