Room Random Numbers Best Practices

Hello, I'm working on a turn-based game that requires a large set of random numbers to process game logic for a multiplayer match.

Instead of having the master client generate and broadcast random numbers throughout the match, I would like to have all of the numbers predetermined before starting the match. There are 625 numbers, each a single digit, that must be generated.

It seems that room properties could provide a possible solution for this, where the master client would pass a 625 digit number as a custom room property when creating the room.

However, I have a few questions regarding this implementation:

- Is it possible to send a 625 digit number through the room's custom properties before starting the match?
- Is this a secure way of sending sensitive data? (ie. Can network snoopers figure out the numbers and predict the outcome of the match)
- Do you recommend a better way of implementing this idea instead of using a custom room property?


  • Afaik, Random should generate the same sequence of numbers on any platform, if you just use the same seed to initialize it. If you can get this confirmed working for Unity, you only have to pass around a single seed number instead of 625.

    It's not possible to send a single value with 625 digits but you can send a byte-array instead. You can send 1 digit per byte or "compress" the array and send 2 digits per byte.

    Room properties are meant to be read by all clients, so they could not be encrypted. Photon allows you to send a buffered event which could be encrypted. This way, no one would be able to read the numbers while they travel.
    Adding the encryption feature to PUN is possible but requires you to change a lot of api. We never exposed the encryption option in OpRaiseEvent in PUN. This method is what's ultimately used to send RPCs and syncs.

    Keep in mind though that the client will decrypt the messages anyways, so in memory (where a lot of hacking is going on), the numbers would be readable in any case.
    Maybe you send the numbers in chunks to avoid getting them read completely.