Ask Your Question

How to make random repeatable?

asked 2016-10-29 22:29:05 -0500

Fairchild gravatar image

updated 2017-01-21 05:36:23 -0500

lennart gravatar image

Is there a way to reuse a seed to make random patterns repeat every cycle until the seed is changed?

Edit: Ah I just looked at the code and I see rand is based on the the incoming pattern midpoint? My Haskell sucks but I can prob hack something together.

Edit: This seems to work ok for rand (for starters):

rands takes a seed for repeatability
rands :: Int -> Pattern Double
rands i = Pattern $ \a -> [(a, a, seedToRand $ (fromIntegral i))]
seedToRand i = fst $ randomDouble $ pureMT $ floor $ (*1000000) i
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-10-30 19:06:00 -0500

bgold gravatar image

I think you could do something like

anotherRand = Pattern $ \(s,e) -> [((s,e), (s,e), timeToRand $ s - sam s)]

which should give numbers that are "random" within a cycle but repeat every cycle.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-10-29 22:29:05 -0500

Seen: 28 times

Last updated: Oct 30 '16