perlinNoise2 <- how do i seed this?

I’m trying to create a heightmap with Perlin noise and decided it would make sense to use the built in PerlinNoise2 class. I need to be able to reproduce the same image by handing it the same seed, but it seems like it cannot be seeded, unless the reference section of this site is wrong?

I just think it seems strange to create a Perlin noise function (and even include a getSeed() method!) but offer no way of setting the seed as it limits a lot of the possible uses.

Have I missed something?

Thanks for the help.

EDIT: If it is indeed impossible to seed it, perhaps this would be a useful thing to change for a future version? It shouldn’t take more than a few lines to implement and would make the class much more flexible.

I believe you can pass it in the constructor:

pn = PerlinNoise2(sx, sy, table_size=256, seed=0)

Great! Thanks a lot for that, could you give me a clue as to what the tablesize would be for though?

very speedy reply btw, thanks :slight_smile:

Dunno. It’s by default set to 256.
Some comments in the source code say:

// It is necessary for _table_size to be a power of 2.
...
// The _index table is just a randomly shuffled index
// table.

huh, I guess I’ll just leave it alone then :slight_smile:

anyway, just managed to make it produce the same image twice, so success!

Thanks again.