Hi guys! I’ve ran into a small problem(Maybe a bug?) with the randomseed, it effects everything in a project, for example, lets say I have a two sprites, and I want the Ipad to randomly choose the same color for both of them, the easiest and only way I can think of doing that would be the randomseed. Then we want it to spawn them both at different random locations, the sad thing is, the randomseed will effect both of these things, not just one. Any help? :slight_smile:

That behavior is correct. The reason you would want to set randomseed is so you can get reproducible random number generation.

I’m confused by this:
“lets say I have a two sprites, and I want the Ipad to randomly choose the same color for both of them”

How can you force the ipad to randomly generate the exact same color values for separate calls to random()? If you want two sprites to be the same color, but with different positions, couldn’t you generate the color variables once and then just set both sprites to use that color, and then generate the positions for each of them separately?

@Prynok math.randomseed(value) will create the same sequence of random numbers each time math.random() is called. The purpose of that is to allow you to debug a program that uses random numbers. By using the same value in math.randomseed(), you’ll get that same sequence of random numbers over and over again. You can either use a different value or don’t use math.randomseed(value), just use math.random() with whatever range you need.

So how do you suppose I could separate the tint, and the postion, but still keep them random? :confused:

@Prynok - if you’re saying that you want to choose random values for tint and position, but you want those values to be controlled by randomseed so you can guarantee the same random numbers, AND you want a different random see for tint and position, why don’t you do it like this?

–choose tint random number
–choose position random numbers

ie use randomseed twice

The problem is, for the position, I want it to not have a randomseed at all, is there anyway to do that?

Is there any fancy thing like the notint thing, but for math?

Just say something like spriteTint = color(math.random(1, 255)). Then you can use that variable whenever you want to tint it and use math.random() for the positions. Then they are placed randomly but with the same tint color. (Use tint(spriteTint))