[reactive] First draft of reactive-tetris

Peter Verswyvelen bugfact at gmail.com
Tue Nov 18 06:33:04 EST 2008


Maybe we should provide a "real"  random generator in the UI / adapter...
Some CPUs provide a hardware random generator...
Maybe this http://firefly.is-a-geek.org/gmpbbs/dist/igo/igo-0.10/hwrandom.c
wraps
it already, don't known

On Tue, Nov 18, 2008 at 9:30 AM, Thomas Davie <tom.davie at gmail.com> wrote:

>
> On 17 Nov 2008, at 21:53, Creighton Hogg wrote:
>
>  Hey Reactive,
>> Since I have no hosting space I'm actually going to include the
>> implementation as an attachment all in one file.  It's not very long anyway,
>> so it should be alright.
>>
>> A few caveats:
>>
>> This code is still _really_ ugly, but it does work as far as I've tested
>> There is no game over, you need to quit manually
>> There is no score or level adjustment yet.  I need to add that when I have
>> more time, i.e. after this week
>>
>> That being said, my first real reactive program was surprisingly simple
>> once I got comfortable with the semantics.  The actual reactive code isn't
>> that complicated, but it did take a pretty big shift in thinking from
>> writing explicit game loops.
>>
>> I've included a good bit of comments so it hopefully it isn't too hard to
>> follow, but if there are any questions about why I did something a
>> particular way (the answer may be 'I'm dumb') please e-mail me or find me on
>> #haskell.
>>
>
> Wow, that's rather nice, unfortunately I can't run it at the moment,
> because I've run into the GLUT problems so many people have.  I'm wondering
> though about your definition of randomBehavior.
>
> randomBehavior :: (Random a) => Double -> Behavior a
> randomBehavior s = fmap (fst . random . mkStdGen . round . (+s)) time
>
> I don'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's probably not good enough for anything the relies on the numbers
> it generates being totally unpredictable.  The reason I say that is that as
> far as I understand it, the guarentee we're given with a pseudo random
> number generator is that given an output number, the next output number is
> impossible to predict.  I don't think we're given any guarantee that given a
> monotonically increasing seed, the output of the generator will look
> particularly different, or be unpredictable.
>
> Unfortunately, I don't think that I can come up with a better way to define
> the behavior though.  It would be possible to define an Event at a certain
> interval that splits the random seed at each occurrence, but I can't do
> better than that.
>
> Bob
>
> _______________________________________________
> Reactive mailing list
> Reactive at haskell.org
> http://www.haskell.org/mailman/listinfo/reactive
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/reactive/attachments/20081118/0aa5f347/attachment.htm


More information about the Reactive mailing list