Jump to content

Question about random/randomseed functions


DiSaMe

Recommended Posts

In my script I use math.random to generate objects. The script is client-side, so to generate the same objects on all clients, I use the same random seed number. My question is, does the same random seed number generate the same random sequences on all OS versions? If not, then players with different OS versions will see different objects, so I will have to write my own random function.

Link to comment

No, I shouldn't. I don't want my server to waste bandwidth on so many objects. What I do on the server is setting primary data (coordinates, random seed...). Client uses it to generate objects. Because primary data is the same for all clients, they should generate objects in the same way. Unless there are differences between their systems which cause differences between math.random() results. So this is an example of the situation: two players have different versions of Windows. They have random seed set to the same number. Will sequence of math.random results be the same for players?

Link to comment

I would also like to know the answer to this question :)

I've had a similiar question when I was making a maze game with auto-generated mazes. I simply assumed that the sequence would be the same for all clients, and it does work for the large majority of the players. However, I began to doubt that assumption when I saw 2 players running through walls in the maze, it turned out they saw a different maze on their screen. They were using 1.0.2 (I forgot to ask about the OS), while everyone else was using 1.0.4

It might have been a very rare bug in my maze resource, but I couldn't find any mistakes in my code so, to be safe, I dropped the lua random function and went for a custom lineair congruential generator.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...