GASDocumentation icon indicating copy to clipboard operation
GASDocumentation copied to clipboard

Suggestion for Section 5.5 (Generating a Random Number on Client and Server)

Open Agamemjohn opened this issue 3 years ago • 1 comments

You mention using the prediction activation key as the seed for the pseudo random number generator, but list a series of (valid) downsides to that approach.

The alternative suggestion could be an extension of the prediction activation key approach, but with additional information hashed in that the server and client both know. For instance, hashing together the prediction activation key and a server-set, replicated Match ID number would make the values different per match, and the first values wouldn't be seeded with 0.

You might also hash the prediction activation key with the client's network ID. The server and client both know the requesting client's network ID, so no new information need be sent in that case, and you get the added bonus that each peer gets a different series of numbers they'll generate.

Agamemjohn avatar Jan 25 '22 09:01 Agamemjohn

These suggestions sound good! It's a more complex solution that I would want to test before adding to the documentation, possibly with code snippets. But, I just don't have the time to do that.

There's lots of ways to handle random numbers and it depends on the requirements of the individual game. My intent with that section is to get people thinking about using the activation and scoped prediction keys beyond just predicted effects. Beginners will have something that will be "okay enough". I expect more experienced developers to devise a system that works best for them - their code architectural style and game requirements.

tranek avatar Feb 05 '22 17:02 tranek