On Tue, Nov 18, 2008 at 2:30 AM, Thomas Davie <span dir="ltr">&lt;<a href="mailto:tom.davie@gmail.com">tom.davie@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><div>&nbsp;&lt;snip me&gt;<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

Wow, that&#39;s rather nice, unfortunately I can&#39;t run it at the moment, because I&#39;ve run into the GLUT problems so many people have. &nbsp;I&#39;m wondering though about your definition of randomBehavior.<br>
<br>
randomBehavior :: (Random a) =&gt; Double -&gt; Behavior a<br>
randomBehavior s = fmap (fst . random . mkStdGen . round . (+s)) time<br>
<br>
I don&#39;t know the theory behind pseudo random number generators well enough to be sure, but I have a feeling that while this may be good enough for a game, it&#39;s probably not good enough for anything the relies on the numbers it generates being totally unpredictable. &nbsp;The reason I say that is that as far as I understand it, the guarentee we&#39;re given with a pseudo random number generator is that given an output number, the next output number is impossible to predict. &nbsp;I don&#39;t think we&#39;re given any guarantee that given a monotonically increasing seed, the output of the generator will look particularly different, or be unpredictable.<br>

<br>
Unfortunately, I don&#39;t think that I can come up with a better way to define the behavior though. &nbsp;It would be possible to define an Event at a certain interval that splits the random seed at each occurrence, but I can&#39;t do better than that.</blockquote>
<div><br>You&#39;re absolutely right about randomBehavior and, unfortunately, I was a bit at a loss for what to do to thread through a random number generator.<br><br>I think the basic conclusion I&#39;ve come to is that it might actually be &#39;wrong&#39; to want a Behavior of random values if they are to be properly generated from a pseudo-random generator, as the semantics would require you to somehow be using the RandomGen an infinite number of times to get the right see at any instance.&nbsp; Behaviors are supposed to be continuous afterall.<br>
<br>What I think we really want is a way of saying &quot;at every occurrence of an event, we want an &#39;a&#39;&quot; such that the distribution of a&#39;s is pseudorandom.&nbsp; To me, this would mean trying to make Event, already a Monad, an instance of MonadRandom from Cale Gibbard&#39;s library of the same name.&nbsp; This doesn&#39;t seem like it should be hard, but I&#39;m not clear on it yet.<br>
</div></div><br>I guess it would drop out pretty readily if one had a way to substitute the values of an infinite list sequentially into an Event stream, since then one could take in a RandomGen and use the randoms :: g -&gt; [a] function to create the list &amp; then pair it with the Event.&nbsp; I don&#39;t know if there&#39;s a way to do that without breaking the Event abstraction, but conceptually it makes sense to me:&nbsp; it&#39;s just establishing an isomorphism between infinite lists.<br>
<br>Any other thoughts anyone?<br><br>Cheers,<br>Creighton<br>