Random Number Streaming

Hi.

Please pardon me for this ignorant question. I’m new to Lumbeyard though I’ve done programming for several years.

I like to continuously stream a random number to my players. So on my server end, I have a random number generated continuously. This number will be streamed to the players who are connected to my game. All the players who are connected will get the same number continuously.

How do I do that? I should have some codes running at the server end right? Do I use the Twitch service? Any pointer is very much appreciated.

Thank you.

Marc

I just lost the answer I wrote you.

You can pass values from server to client by rpc call with arguments.rpc

However you may not need it as you can just share the random seed in a reflected and replicated property both in c++ and lua. If you are interested next you can read why and decide if it is your case.

To resume my full answer you can use a specific pseudorandom number generators instance initialized with a shared seed on every machine.Use this generator for just one synchronized generation purpose. use multiple if you need multiple synchronized random features and an additional one for the general purpose random use.They need to be indipendent as they don’t have to mess with the seed of the other instances.

In some games you may need a generator assigned for every player you may require to init with the same seed or every player can have a different seed too decided on the server and sent to every client or just the affected client depending on the game.

this method makes every generator output the same numbers on every machine with just the initial sharing of seeds.

How frequently do you change the random number?

If it is only every few minutes, you could implement an AWS Lambda Function that returns the latest number, and updates the number if it has expired. Clients would call this every few minutes. The number could be stored in DynamoDB, along with the time it expires. You could maintain different numbers for different sessions if you used a session id as the key.

Or you could use a scheduled Lambda Function, which AWS will run every few minutes for you, and then use AWS SNS to push new numbers out to clients. Not only will this likely be cheaper than the first solution, but it would also work well for mobile games or apps (less network i/o, less impact on battery life).

However, if your changing the number every few seconds, those approaches won’t work very well. In that case you’ll likely need to run a service instance constantly on EC2 and use your own protocol to stream changes to the client. If your game is “session” based (short lived PvP matchmaking, that sort of thing), then AWS Gamelift can simplify the use of EC2 for running your service backend.