RSS/Atom feed Twitter
Site is read-only, email is disabled

Random number seeding interface

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

3 of 3 messages available
Toggle history

Please log in to manage your subscriptions.

Random number seeding interface David Neary 21 Nov 14:59
  Random number seeding interface Guillermo S. Romero / Familia Romero 21 Nov 16:48
  Random number seeding interface Nathan Carl Summers 21 Nov 16:52
David Neary
2002-11-21 14:59:36 UTC (over 21 years ago)

Random number seeding interface

Hi all,

I recently changed all occurrences of rand() and friends to use g_rand* from the glib 2.0 interface. And in doing so, some of the flaws of the gimp random seed widget annoyed me. I have some suggestions for changing it, which I thopught I'd run past the list before I commit the changes (these are, for the most part, minor changes which are already done on my machine).

The gimp_random_seed_new() function currently creates a spinbutton for the seed, and a togglebutton for whether a Time seed should be used. With the change over to g_rand* () the default seeding (which is from /dev/urandom by default, and time if that fails) is much better, so Time os probably no longer appropriate as a label. But that's superficial.

The real change would be to do away with the toggle, replace the toggle button with a normal button, and set a random seed in the spin-box when the button is pressed. For this, I've been using the global PRNG (g_random_int) rather than setting up what would be a short-lived GRand * object, but again that would be a trivial change.

After that the only thing left to do is "intelligent" default seeding. Do we seed with 0 as the default, and use the same seed as the last time if "run with last vals" is used for a plug-in? Should the gimp_random_seed_new() function set a random seed when called? Or do we seed with a random number to start? Currently the setting of an initial seed is entirely the plug-ins responsibility. I propose we leave it that way. The "run with last vals" should use, imho, the same seed value. This can, of course, be modified from plug-in to plug-in, but I think it's a sane behaviour.

Also, once the behaviour is decided, we should use the random seed widget across more plug-ins. Several plug-ins currently do their own thing in this respect, and there's no real need for it. So there you go - nothing too contentious, but since it's an interface change, it was suggested I send in a mail. My opinion is that a random seed box, when used, should set a seed.

Cheers, Dave.

Guillermo S. Romero / Familia Romero
2002-11-21 16:48:47 UTC (over 21 years ago)

Random number seeding interface

dneary@wanadoo.fr (2002-11-21 at 1459.36 +0100):

The gimp_random_seed_new() function currently creates a spinbutton for the seed, and a togglebutton for whether a Time seed should be used. With the change over to g_rand* () the default seeding (which is from /dev/urandom by default, and time if that fails) is much better, so Time os probably no longer appropriate as a label. But that's superficial.

Change the label to New Random Seed or something like that. It could be:

Current Seed: _78928___^v |New Random Seed|

I keep the spin button so people can just use a simple approach, start with one value (via the button or manual input) and test consecutive numbers, thus allowing going back to a nicer result you got four clicks ago, for example.

The real change would be to do away with the toggle, replace the toggle button with a normal button, and set a random seed in the spin-box when the button is pressed. For this, I've been using

Yep, nice for experiments. The ascii art above uses plain button, not toggle, as you recommend.

the global PRNG (g_random_int) rather than setting up what would be a short-lived GRand * object, but again that would be a trivial change.

After that the only thing left to do is "intelligent" default seeding. Do we seed with 0 as the default, and use the same seed as the last time if "run with last vals" is used for a plug-in? Should the gimp_random_seed_new() function set a random seed when called? Or do we seed with a random number to start? Currently the setting of an initial seed is entirely the plug-ins responsibility. I propose we leave it that way. The "run with last vals" should use, imho, the same seed value. This can, of course, be modified from plug-in to plug-in, but I think it's a sane behaviour.

Only things I see as important is being able to reproduce the same results as many times as needed, thus "last vals" should be a run again, no changes at all. The other thing, the value for first run or new seeds, do whatever you want, seed with a random number from a highly random source or use time, I do not think anybody will have problems with not so random things in images (anybody so weird to do crypto with gimp?). If it looks random, it should be enough.

Also, once the behaviour is decided, we should use the random seed widget across more plug-ins. Several plug-ins currently do their own thing in this respect, and there's no real need for it.

Yes, you will make some people happy, specially about the rerun part.

GSR

Nathan Carl Summers
2002-11-21 16:52:37 UTC (over 21 years ago)

Random number seeding interface

On Thu, 21 Nov 2002, David Neary wrote:

The real change would be to do away with the toggle, replace the toggle button with a normal button, and set a random seed in the spin-box when the button is pressed. For this, I've been using the global PRNG (g_random_int) rather than setting up what would be a short-lived GRand * object, but again that would be a trivial change.

This would be great! Several times I have lost a really good seed because I did something that causes the plug-in to change the seed, or because I wanted to use it in multiple invocations, and couldn't, because of course it comes up with a new seed each time.

Rockwalrus