Bug 42632 - Ability to seed Math.Random ()
Summary: Ability to seed Math.Random ()
Status: RESOLVED FIXED
Alias: None
Product: plymouth
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: All All
: medium enhancement
Assignee: Ray Strode [halfline]
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-05 13:32 UTC by dendlerdev
Modified: 2014-08-17 22:06 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Working Seed (939 bytes, patch)
2014-08-17 21:42 UTC, Nicholas Little
Details | Splinter Review

Description dendlerdev 2011-11-05 13:32:11 UTC
Would be nice to give the Random a seed function so that subsequent random choices (backgrounds, etc.) are truly random.

As discussed here: http://lists.freedesktop.org/archives/plymouth/2010-July/000387.html
Comment 1 Ray Strode [halfline] 2012-06-08 13:54:51 UTC
should be set in master:

http://cgit.freedesktop.org/plymouth/commit/?id=3f8bd998dcc6d592ffd5d3aefad06f0bbf28a725

script: seed random number generator

Most splash plugins that use random numbers seed the random number generator with the current time, but script fails, too. This commit fixes that. 

https://bugs.freedesktop.org/show_bug.cgi?id=42632
Comment 2 Nicholas Little 2014-08-17 21:42:02 UTC
Created attachment 104777 [details] [review]
Working Seed

Hi, I've been developing a script that uses the Math.Random function to select a splash screen but it always selects the same image.

I'm not exactly sure what the problem is but believe that it lies in the cast from double to int performed when feeding the output of ply_get_timestamp to srand.

I enclose a small patch that corrects the behaviour for scripts, but I noticed using grep that the generator is seeded in the same way throughout plymouth.

Thanks!


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.