Randomness

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Randomness

Michael Rice-3
I just noticed that when I load a morphic project I get the same stream of random numbers each time. Is there a simple way to install a new different random seed each time the project is loaded?

Michael

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Randomness

Levente Uzonyi-2
On Mon, 4 Apr 2011, michael rice wrote:

> I just noticed that when I load a morphic project I get the same stream of random numbers each time. Is there a simple way to install a new different random seed each time the project is loaded?

If you serialize the Random object, then it will have the same state when
it's restored. I guess you should create a subclass of Random, which
implements #comeFullyUpOnReload:. That method can reinitialize the seed of
the random number generator. You may want to check UUIDGenerator >>
#makeSeed if you don't know how to get a good seed for your rng.


Levente

>
> Michael
>
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Randomness

Michael Rice-3
I forgot to mention, I'm using the random number tile and scripting. Does that make it more difficult?

Michael

--- On Mon, 4/4/11, Levente Uzonyi <[hidden email]> wrote:

From: Levente Uzonyi <[hidden email]>
Subject: Re: [Newbies] Randomness
To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
Date: Monday, April 4, 2011, 8:08 PM

On Mon, 4 Apr 2011, michael rice wrote:

> I just noticed that when I load a morphic project I get the same stream of random numbers each time. Is there a simple way to install a new different random seed each time the project is loaded?

If you serialize the Random object, then it will have the same state when it's restored. I guess you should create a subclass of Random, which implements #comeFullyUpOnReload:. That method can reinitialize the seed of the random number generator. You may want to check UUIDGenerator >> #makeSeed if you don't know how to get a good seed for your rng.


Levente

>
> Michael
>
_______________________________________________
Beginners mailing list
Beginners@...
http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Randomness

Levente Uzonyi-2
On Mon, 4 Apr 2011, michael rice wrote:

> I forgot to mention, I'm using the random number tile and scripting. Does that make it more difficult?

Not really, RandomNumberTile uses the global random number generator of
Collection. I don't know how/why is it serialized/restored, but here's a
method which should help:

RandomNumberTile >> #comeFullyUpOnReload: smartRefStream

  | seed |
  [
  seed := (Time millisecondClockValue bitAnd: 16r3FFFFFFF) bitXor: self hash.
  seed := seed bitXor: (Time totalSeconds bitAnd: 16r3FFFFFFF).
  seed := seed bitXor: 16r3FFFFFFF atRandom.
  seed = 0 ] whileTrue. "Try again if ever get a seed = 0"
  Collection mutexForPicking critical: [
  Collection randomForPicking seed: seed ].
  ^super comeFullyUpOnReload: smartRefStream

It's drawback is that it will reseed the rng for every RandomNumberTile.
The best solution would be if Etoys would use a custom Random instance or
a subclass where this is done by default.


Levente

>
> Michael
>
> --- On Mon, 4/4/11, Levente Uzonyi <[hidden email]> wrote:
>
> From: Levente Uzonyi <[hidden email]>
> Subject: Re: [Newbies] Randomness
> To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
> Date: Monday, April 4, 2011, 8:08 PM
>
> On Mon, 4 Apr 2011, michael rice wrote:
>
>> I just noticed that when I load a morphic project I get the same stream of random numbers each time. Is there a simple way to install a new different random seed each time the project is loaded?
>
> If you serialize the Random object, then it will have the same state when it's restored. I guess you should create a subclass of Random, which implements #comeFullyUpOnReload:. That method can reinitialize the seed of the random number generator. You may want to check UUIDGenerator >> #makeSeed if you don't know how to get a good seed for your rng.
>
>
> Levente
>
>>
>> Michael
>>
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Randomness

Michael Rice-3
Thanks again. I'll just modify the seed each time, before I load the project, and get different results that way.

Michael

--- On Mon, 4/4/11, Levente Uzonyi <[hidden email]> wrote:

From: Levente Uzonyi <[hidden email]>
Subject: Re: [Newbies] Randomness
To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
Date: Monday, April 4, 2011, 8:32 PM

On Mon, 4 Apr 2011, michael rice wrote:

> I forgot to mention, I'm using the random number tile and scripting. Does that make it more difficult?

Not really, RandomNumberTile uses the global random number generator of Collection. I don't know how/why is it serialized/restored, but here's a method which should help:

RandomNumberTile >> #comeFullyUpOnReload: smartRefStream

    | seed |
    [
        seed := (Time millisecondClockValue bitAnd: 16r3FFFFFFF) bitXor: self hash.
        seed := seed bitXor: (Time totalSeconds bitAnd: 16r3FFFFFFF).
        seed := seed bitXor: 16r3FFFFFFF atRandom.
        seed = 0 ] whileTrue. "Try again if ever get a seed = 0"
    Collection mutexForPicking critical: [
        Collection randomForPicking seed: seed ].
    ^super comeFullyUpOnReload: smartRefStream

It's drawback is that it will reseed the rng for every RandomNumberTile. The best solution would be if Etoys would use a custom Random instance or a subclass where this is done by default.


Levente

>
> Michael
>
> --- On Mon, 4/4/11, Levente Uzonyi <leves@...> wrote:
>
> From: Levente Uzonyi <leves@...>
> Subject: Re: [Newbies] Randomness
> To: "A friendly place to get answers to even the most basic questions about Squeak." <beginners@...>
> Date: Monday, April 4, 2011, 8:08 PM
>
> On Mon, 4 Apr 2011, michael rice wrote:
>
>> I just noticed that when I load a morphic project I get the same stream of random numbers each time. Is there a simple way to install a new different random seed each time the project is loaded?
>
> If you serialize the Random object, then it will have the same state when it's restored. I guess you should create a subclass of Random, which implements #comeFullyUpOnReload:. That method can reinitialize the seed of the random number generator. You may want to check UUIDGenerator >> #makeSeed if you don't know how to get a good seed for your rng.
>
>
> Levente
>
>>
>> Michael
>>
> _______________________________________________
> Beginners mailing list
> Beginners@...
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
_______________________________________________
Beginners mailing list
Beginners@...
http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Randomness

Bert Freudenberg
In reply to this post by Levente Uzonyi-2

On 05.04.2011, at 02:32, Levente Uzonyi wrote:

> On Mon, 4 Apr 2011, michael rice wrote:
>
>> I forgot to mention, I'm using the random number tile and scripting. Does that make it more difficult?
>
> Not really, RandomNumberTile uses the global random number generator of Collection. I don't know how/why is it serialized/restored

It is not stored in the project. But in trunk, the seed does not get re-initialized when starting up. In the Etoys image, Collection class has a startUp method

startUp
        RandomForPicking seed: Time totalSeconds hash asFloat.

IMHO we should adopt something like this for trunk (maybe with your "more" random approach below).

- Bert -

> but here's a method which should help:
>
> RandomNumberTile >> #comeFullyUpOnReload: smartRefStream
>
> | seed |
> [
> seed := (Time millisecondClockValue bitAnd: 16r3FFFFFFF) bitXor: self hash.
> seed := seed bitXor: (Time totalSeconds bitAnd: 16r3FFFFFFF).
> seed := seed bitXor: 16r3FFFFFFF atRandom.
> seed = 0 ] whileTrue. "Try again if ever get a seed = 0"
> Collection mutexForPicking critical: [
> Collection randomForPicking seed: seed ].
> ^super comeFullyUpOnReload: smartRefStream
>
> It's drawback is that it will reseed the rng for every RandomNumberTile. The best solution would be if Etoys would use a custom Random instance or a subclass where this is done by default.
>
>
> Levente
>
>>
>> Michael
>>
>> --- On Mon, 4/4/11, Levente Uzonyi <[hidden email]> wrote:
>>
>> From: Levente Uzonyi <[hidden email]>
>> Subject: Re: [Newbies] Randomness
>> To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
>> Date: Monday, April 4, 2011, 8:08 PM
>>
>> On Mon, 4 Apr 2011, michael rice wrote:
>>
>>> I just noticed that when I load a morphic project I get the same stream of random numbers each time. Is there a simple way to install a new different random seed each time the project is loaded?
>>
>> If you serialize the Random object, then it will have the same state when it's restored. I guess you should create a subclass of Random, which implements #comeFullyUpOnReload:. That method can reinitialize the seed of the random number generator. You may want to check UUIDGenerator >> #makeSeed if you don't know how to get a good seed for your rng.
>>
>>
>> Levente

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Randomness

Levente Uzonyi-2
On Tue, 5 Apr 2011, Bert Freudenberg wrote:

>
> On 05.04.2011, at 02:32, Levente Uzonyi wrote:
>
>> On Mon, 4 Apr 2011, michael rice wrote:
>>
>>> I forgot to mention, I'm using the random number tile and scripting. Does that make it more difficult?
>>
>> Not really, RandomNumberTile uses the global random number generator of Collection. I don't know how/why is it serialized/restored
>
> It is not stored in the project. But in trunk, the seed does not get re-initialized when starting up. In the Etoys image, Collection class has a startUp method

So it doesn't give the same random numbers after project loading, but
after image startup in Squeak?

>
> startUp
> RandomForPicking seed: Time totalSeconds hash asFloat.
>
> IMHO we should adopt something like this for trunk (maybe with your "more" random approach below).

It can be even better, I just copied (and slightly modified) the code from
UUIDGenerator. Maybe it's the best to move the reseeding code to Random.


Levente

>
> - Bert -
>
>> but here's a method which should help:
>>
>> RandomNumberTile >> #comeFullyUpOnReload: smartRefStream
>>
>> | seed |
>> [
>> seed := (Time millisecondClockValue bitAnd: 16r3FFFFFFF) bitXor: self hash.
>> seed := seed bitXor: (Time totalSeconds bitAnd: 16r3FFFFFFF).
>> seed := seed bitXor: 16r3FFFFFFF atRandom.
>> seed = 0 ] whileTrue. "Try again if ever get a seed = 0"
>> Collection mutexForPicking critical: [
>> Collection randomForPicking seed: seed ].
>> ^super comeFullyUpOnReload: smartRefStream
>>
>> It's drawback is that it will reseed the rng for every RandomNumberTile. The best solution would be if Etoys would use a custom Random instance or a subclass where this is done by default.
>>
>>
>> Levente
>>
>>>
>>> Michael
>>>
>>> --- On Mon, 4/4/11, Levente Uzonyi <[hidden email]> wrote:
>>>
>>> From: Levente Uzonyi <[hidden email]>
>>> Subject: Re: [Newbies] Randomness
>>> To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
>>> Date: Monday, April 4, 2011, 8:08 PM
>>>
>>> On Mon, 4 Apr 2011, michael rice wrote:
>>>
>>>> I just noticed that when I load a morphic project I get the same stream of random numbers each time. Is there a simple way to install a new different random seed each time the project is loaded?
>>>
>>> If you serialize the Random object, then it will have the same state when it's restored. I guess you should create a subclass of Random, which implements #comeFullyUpOnReload:. That method can reinitialize the seed of the random number generator. You may want to check UUIDGenerator >> #makeSeed if you don't know how to get a good seed for your rng.
>>>
>>>
>>> Levente
>
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Randomness

David T. Lewis
In reply to this post by Bert Freudenberg
I made the update in Squeak trunk similar to the Etoys image, but used
the existing seed generator in Random>>initialize on the theory that if
the generator is good enough for a new Random, it should be good enough
for an existing one too ;)

Michael, thanks for spotting the problem.

Dave

On Tue, Apr 05, 2011 at 01:16:31PM +0200, Bert Freudenberg wrote:

>
> On 05.04.2011, at 02:32, Levente Uzonyi wrote:
>
> > On Mon, 4 Apr 2011, michael rice wrote:
> >
> >> I forgot to mention, I'm using the random number tile and scripting. Does that make it more difficult?
> >
> > Not really, RandomNumberTile uses the global random number generator of Collection. I don't know how/why is it serialized/restored
>
> It is not stored in the project. But in trunk, the seed does not get re-initialized when starting up. In the Etoys image, Collection class has a startUp method
>
> startUp
> RandomForPicking seed: Time totalSeconds hash asFloat.
>
> IMHO we should adopt something like this for trunk (maybe with your "more" random approach below).
>
> - Bert -
>
> > but here's a method which should help:
> >
> > RandomNumberTile >> #comeFullyUpOnReload: smartRefStream
> >
> > | seed |
> > [
> > seed := (Time millisecondClockValue bitAnd: 16r3FFFFFFF) bitXor: self hash.
> > seed := seed bitXor: (Time totalSeconds bitAnd: 16r3FFFFFFF).
> > seed := seed bitXor: 16r3FFFFFFF atRandom.
> > seed = 0 ] whileTrue. "Try again if ever get a seed = 0"
> > Collection mutexForPicking critical: [
> > Collection randomForPicking seed: seed ].
> > ^super comeFullyUpOnReload: smartRefStream
> >
> > It's drawback is that it will reseed the rng for every RandomNumberTile. The best solution would be if Etoys would use a custom Random instance or a subclass where this is done by default.
> >
> >
> > Levente
> >
> >>
> >> Michael
> >>
> >> --- On Mon, 4/4/11, Levente Uzonyi <[hidden email]> wrote:
> >>
> >> From: Levente Uzonyi <[hidden email]>
> >> Subject: Re: [Newbies] Randomness
> >> To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
> >> Date: Monday, April 4, 2011, 8:08 PM
> >>
> >> On Mon, 4 Apr 2011, michael rice wrote:
> >>
> >>> I just noticed that when I load a morphic project I get the same stream of random numbers each time. Is there a simple way to install a new different random seed each time the project is loaded?
> >>
> >> If you serialize the Random object, then it will have the same state when it's restored. I guess you should create a subclass of Random, which implements #comeFullyUpOnReload:. That method can reinitialize the seed of the random number generator. You may want to check UUIDGenerator >> #makeSeed if you don't know how to get a good seed for your rng.
> >>
> >>
> >> Levente
>
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Randomness

Michael Rice-3
So it was a problem? The old behavior was: if I saved a project and quit the image without saving it, the next time I bought up the image and loaded the project I would get the same stream of random numbers. What is the new behavior?

Michael

--- On Wed, 4/6/11, David T. Lewis <[hidden email]> wrote:

From: David T. Lewis <[hidden email]>
Subject: Re: [Newbies] Randomness
To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
Date: Wednesday, April 6, 2011, 8:35 PM

I made the update in Squeak trunk similar to the Etoys image, but used
the existing seed generator in Random>>initialize on the theory that if
the generator is good enough for a new Random, it should be good enough
for an existing one too ;)

Michael, thanks for spotting the problem.

Dave

On Tue, Apr 05, 2011 at 01:16:31PM +0200, Bert Freudenberg wrote:

>
> On 05.04.2011, at 02:32, Levente Uzonyi wrote:
>
> > On Mon, 4 Apr 2011, michael rice wrote:
> >
> >> I forgot to mention, I'm using the random number tile and scripting. Does that make it more difficult?
> >
> > Not really, RandomNumberTile uses the global random number generator of Collection. I don't know how/why is it serialized/restored
>
> It is not stored in the project. But in trunk, the seed does not get re-initialized when starting up. In the Etoys image, Collection class has a startUp method
>
> startUp
>     RandomForPicking seed: Time totalSeconds hash asFloat.
>
> IMHO we should adopt something like this for trunk (maybe with your "more" random approach below).
>
> - Bert -
>
> > but here's a method which should help:
> >
> > RandomNumberTile >> #comeFullyUpOnReload: smartRefStream
> >
> >     | seed |
> >     [
> >         seed := (Time millisecondClockValue bitAnd: 16r3FFFFFFF) bitXor: self hash.
> >         seed := seed bitXor: (Time totalSeconds bitAnd: 16r3FFFFFFF).
> >         seed := seed bitXor: 16r3FFFFFFF atRandom.
> >         seed = 0 ] whileTrue. "Try again if ever get a seed = 0"
> >     Collection mutexForPicking critical: [
> >         Collection randomForPicking seed: seed ].
> >     ^super comeFullyUpOnReload: smartRefStream
> >
> > It's drawback is that it will reseed the rng for every RandomNumberTile. The best solution would be if Etoys would use a custom Random instance or a subclass where this is done by default.
> >
> >
> > Levente
> >
> >>
> >> Michael
> >>
> >> --- On Mon, 4/4/11, Levente Uzonyi <leves@...> wrote:
> >>
> >> From: Levente Uzonyi <leves@...>
> >> Subject: Re: [Newbies] Randomness
> >> To: "A friendly place to get answers to even the most basic questions about Squeak." <beginners@...>
> >> Date: Monday, April 4, 2011, 8:08 PM
> >>
> >> On Mon, 4 Apr 2011, michael rice wrote:
> >>
> >>> I just noticed that when I load a morphic project I get the same stream of random numbers each time. Is there a simple way to install a new different random seed each time the project is loaded?
> >>
> >> If you serialize the Random object, then it will have the same state when it's restored. I guess you should create a subclass of Random, which implements #comeFullyUpOnReload:. That method can reinitialize the seed of the random number generator. You may want to check UUIDGenerator >> #makeSeed if you don't know how to get a good seed for your rng.
> >>
> >>
> >> Levente
>
> _______________________________________________
> Beginners mailing list
> Beginners@...
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
_______________________________________________
Beginners mailing list
Beginners@...
http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Randomness

David T. Lewis
The new behavior should be the same as what you would get using
an Etoys image rather than a Squeak trunk image. So if the scenario
that you describe works properly in an Etoys image, it should now
also work properly in an updated Squeak trunk image.

There is an instance of Random (in other words an individual random
number generator) associated with the class Collection. This random
number generator is used whenever selecting a "random" element from
a collection of elements. Random number generators on computers are
not really random at all, but they attempt to create an illusion of
randomness by producing a sequence of apparently random values based
on some arbitrary initial value (the "seed").

In the Etoys image, the single instance of Random that is used in
class Collection (whenever you want to select something "at random")
has its seed value reset whenever a startUp occurs. Normally you want
all your objects to be restarted exactly as they were before, but
a random number generator is different; you really would prefer
to have it behave randomly. The Etoys image has a special #startUp
method that makes this happen, and this is the feature that has
now been added to Squeak.

Dave

On Wed, Apr 06, 2011 at 05:54:34PM -0700, michael rice wrote:

> So it was a problem? The old behavior was: if I saved a project and quit the image without saving it, the next time I bought up the image and loaded the project I would get the same stream of random numbers. What is the new behavior?
>
> Michael
>
> --- On Wed, 4/6/11, David T. Lewis <[hidden email]> wrote:
>
> From: David T. Lewis <[hidden email]>
> Subject: Re: [Newbies] Randomness
> To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
> Date: Wednesday, April 6, 2011, 8:35 PM
>
> I made the update in Squeak trunk similar to the Etoys image, but used
> the existing seed generator in Random>>initialize on the theory that if
> the generator is good enough for a new Random, it should be good enough
> for an existing one too ;)
>
> Michael, thanks for spotting the problem.
>
> Dave
>
> On Tue, Apr 05, 2011 at 01:16:31PM +0200, Bert Freudenberg wrote:
> >
> > On 05.04.2011, at 02:32, Levente Uzonyi wrote:
> >
> > > On Mon, 4 Apr 2011, michael rice wrote:
> > >
> > >> I forgot to mention, I'm using the random number tile and scripting. Does that make it more difficult?
> > >
> > > Not really, RandomNumberTile uses the global random number generator of Collection. I don't know how/why is it serialized/restored
> >
> > It is not stored in the project. But in trunk, the seed does not get re-initialized when starting up. In the Etoys image, Collection class has a startUp method
> >
> > startUp
> > ??? RandomForPicking seed: Time totalSeconds hash asFloat.
> >
> > IMHO we should adopt something like this for trunk (maybe with your "more" random approach below).
> >
> > - Bert -
> >
> > > but here's a method which should help:
> > >
> > > RandomNumberTile >> #comeFullyUpOnReload: smartRefStream
> > >
> > > ??? | seed |
> > > ??? [
> > > ??? ??? seed := (Time millisecondClockValue bitAnd: 16r3FFFFFFF) bitXor: self hash.
> > > ??? ??? seed := seed bitXor: (Time totalSeconds bitAnd: 16r3FFFFFFF).
> > > ??? ??? seed := seed bitXor: 16r3FFFFFFF atRandom.
> > > ??? ??? seed = 0 ] whileTrue. "Try again if ever get a seed = 0"
> > > ??? Collection mutexForPicking critical: [
> > > ??? ??? Collection randomForPicking seed: seed ].
> > > ??? ^super comeFullyUpOnReload: smartRefStream
> > >
> > > It's drawback is that it will reseed the rng for every RandomNumberTile. The best solution would be if Etoys would use a custom Random instance or a subclass where this is done by default.
> > >
> > >
> > > Levente
> > >
> > >>
> > >> Michael
> > >>
> > >> --- On Mon, 4/4/11, Levente Uzonyi <[hidden email]> wrote:
> > >>
> > >> From: Levente Uzonyi <[hidden email]>
> > >> Subject: Re: [Newbies] Randomness
> > >> To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
> > >> Date: Monday, April 4, 2011, 8:08 PM
> > >>
> > >> On Mon, 4 Apr 2011, michael rice wrote:
> > >>
> > >>> I just noticed that when I load a morphic project I get the same stream of random numbers each time. Is there a simple way to install a new different random seed each time the project is loaded?
> > >>
> > >> If you serialize the Random object, then it will have the same state when it's restored. I guess you should create a subclass of Random, which implements #comeFullyUpOnReload:. That method can reinitialize the seed of the random number generator. You may want to check UUIDGenerator >> #makeSeed if you don't know how to get a good seed for your rng.
> > >>
> > >>
> > >> Levente
> >
> > _______________________________________________
> > Beginners mailing list
> > [hidden email]
> > http://lists.squeakfoundation.org/mailman/listinfo/beginners
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Randomness

Steve Thomas
On Wed, Apr 6, 2011 at 9:44 PM, David T. Lewis <[hidden email]> wrote:
The new behavior should be the same as what you would get using
an Etoys image rather than a Squeak trunk image. 

Great that Etoys is contributing to the latest Squeak.
Now if we could just get some help bring Etoys up to date so it runs on the latest version of Squeak, that would be much appreciated by the kids around the world who use it ;)

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Randomness

Bert Freudenberg
In reply to this post by Michael Rice-3
The new behavior is that you get a different stream of random numbers each time you start the image. Or at least it's really really unlikely you get the same sequence again. 

- Bert -

On 07.04.2011, at 02:54, michael rice wrote:

So it was a problem? The old behavior was: if I saved a project and quit the image without saving it, the next time I bought up the image and loaded the project I would get the same stream of random numbers. What is the new behavior?

Michael

--- On Wed, 4/6/11, David T. Lewis <[hidden email]> wrote:

From: David T. Lewis <[hidden email]>
Subject: Re: [Newbies] Randomness
To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
Date: Wednesday, April 6, 2011, 8:35 PM

I made the update in Squeak trunk similar to the Etoys image, but used
the existing seed generator in Random>>initialize on the theory that if
the generator is good enough for a new Random, it should be good enough
for an existing one too ;)

Michael, thanks for spotting the problem.

Dave

On Tue, Apr 05, 2011 at 01:16:31PM +0200, Bert Freudenberg wrote:

>
> On 05.04.2011, at 02:32, Levente Uzonyi wrote:
>
> > On Mon, 4 Apr 2011, michael rice wrote:
> >
> >> I forgot to mention, I'm using the random number tile and scripting. Does that make it more difficult?
> >
> > Not really, RandomNumberTile uses the global random number generator of Collection. I don't know how/why is it serialized/restored
>
> It is not stored in the project. But in trunk, the seed does not get re-initialized when starting up. In the Etoys image, Collection class has a startUp method
>
> startUp
>     RandomForPicking seed: Time totalSeconds hash asFloat.
>
> IMHO we should adopt something like this for trunk (maybe with your "more" random approach below).
>
> - Bert -
>
> > but here's a method which should help:
> >
> > RandomNumberTile >> #comeFullyUpOnReload: smartRefStream
> >
> >     | seed |
> >     [
> >         seed := (Time millisecondClockValue bitAnd: 16r3FFFFFFF) bitXor: self hash.
> >         seed := seed bitXor: (Time totalSeconds bitAnd: 16r3FFFFFFF).
> >         seed := seed bitXor: 16r3FFFFFFF atRandom.
> >         seed = 0 ] whileTrue. "Try again if ever get a seed = 0"
> >     Collection mutexForPicking critical: [
> >         Collection randomForPicking seed: seed ].
> >     ^super comeFullyUpOnReload: smartRefStream
> >
> > It's drawback is that it will reseed the rng for every RandomNumberTile. The best solution would be if Etoys would use a custom Random instance or a subclass where this is done by default.
> >
> >
> > Levente
> >
> >>
> >> Michael
> >>
> >> --- On Mon, 4/4/11, Levente Uzonyi <<a ymailto="mailto:leves@elte.hu" href="x-msg://1683/mc/compose?to=leves@elte.hu">leves@...> wrote:
> >>
> >> From: Levente Uzonyi <<a ymailto="mailto:leves@elte.hu" href="x-msg://1683/mc/compose?to=leves@elte.hu">leves@...>
> >> Subject: Re: [Newbies] Randomness
> >> To: "A friendly place to get answers to even the most basic questions about Squeak." <<a ymailto="mailto:beginners@lists.squeakfoundation.org" href="x-msg://1683/mc/compose?to=beginners@lists.squeakfoundation.org">beginners@...>
> >> Date: Monday, April 4, 2011, 8:08 PM
> >>
> >> On Mon, 4 Apr 2011, michael rice wrote:
> >>
> >>> I just noticed that when I load a morphic project I get the same stream of random numbers each time. Is there a simple way to install a new different random seed each time the project is loaded?
> >>
> >> If you serialize the Random object, then it will have the same state when it's restored. I guess you should create a subclass of Random, which implements #comeFullyUpOnReload:. That method can reinitialize the seed of the random number generator. You may want to check UUIDGenerator >> #makeSeed if you don't know how to get a good seed for your rng.
> >>
> >>
> >> Levente



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Randomness

Michael Rice-3
And I can acquire the new behavior by updating Squeak?

Michael

--- On Thu, 4/7/11, Bert Freudenberg <[hidden email]> wrote:

From: Bert Freudenberg <[hidden email]>
Subject: Re: [Newbies] Randomness
To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
Date: Thursday, April 7, 2011, 6:19 AM

The new behavior is that you get a different stream of random numbers each time you start the image. Or at least it's really really unlikely you get the same sequence again. 

- Bert -

On 07.04.2011, at 02:54, michael rice wrote:

So it was a problem? The old behavior was: if I saved a project and quit the image without saving it, the next time I bought up the image and loaded the project I would get the same stream of random numbers. What is the new behavior?

Michael

--- On Wed, 4/6/11, David T. Lewis <lewis@...> wrote:

From: David T. Lewis <lewis@...>
Subject: Re: [Newbies] Randomness
To: "A friendly place to get answers to even the most basic questions about Squeak." <beginners@...>
Date: Wednesday, April 6, 2011, 8:35 PM

I made the update in Squeak trunk similar to the Etoys image, but used
the existing seed generator in Random>>initialize on the theory that if
the generator is good enough for a new Random, it should be good enough
for an existing one too ;)

Michael, thanks for spotting the problem.

Dave

On Tue, Apr 05, 2011 at 01:16:31PM +0200, Bert Freudenberg wrote:

>
> On 05.04.2011, at 02:32, Levente Uzonyi wrote:
>
> > On Mon, 4 Apr 2011, michael rice wrote:
> >
> >> I forgot to mention, I'm using the random number tile and scripting. Does that make it more difficult?
> >
> > Not really, RandomNumberTile uses the global random number generator of Collection. I don't know how/why is it serialized/restored
>
> It is not stored in the project. But in trunk, the seed does not get re-initialized when starting up. In the Etoys image, Collection class has a startUp method
>
> startUp
>     RandomForPicking seed: Time totalSeconds hash asFloat.
>
> IMHO we should adopt something like this for trunk (maybe with your "more" random approach below).
>
> - Bert -
>
> > but here's a method which should help:
> >
> > RandomNumberTile >> #comeFullyUpOnReload: smartRefStream
> >
> >     | seed |
> >     [
> >         seed := (Time millisecondClockValue bitAnd: 16r3FFFFFFF) bitXor: self hash.
> >         seed := seed bitXor: (Time totalSeconds bitAnd: 16r3FFFFFFF).
> >         seed := seed bitXor: 16r3FFFFFFF atRandom.
> >         seed = 0 ] whileTrue. "Try again if ever get a seed = 0"
> >     Collection mutexForPicking critical: [
> >         Collection randomForPicking seed: seed ].
> >     ^super comeFullyUpOnReload: smartRefStream
> >
> > It's drawback is that it will reseed the rng for every RandomNumberTile. The best solution would be if Etoys would use a custom Random instance or a subclass where this is done by default.
> >
> >
> > Levente
> >
> >>
> >> Michael
> >>
> >> --- On Mon, 4/4/11, Levente Uzonyi <[hidden email]> wrote:
> >>
> >> From: Levente Uzonyi <[hidden email]>
> >> Subject: Re: [Newbies] Randomness
> >> To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
> >> Date: Monday, April 4, 2011, 8:08 PM
> >>
> >> On Mon, 4 Apr 2011, michael rice wrote:
> >>
> >>> I just noticed that when I load a morphic project I get the same stream of random numbers each time. Is there a simple way to install a new different random seed each time the project is loaded?
> >>
> >> If you serialize the Random object, then it will have the same state when it's restored. I guess you should create a subclass of Random, which implements #comeFullyUpOnReload:. That method can reinitialize the seed of the random number generator. You may want to check UUIDGenerator >> #makeSeed if you don't know how to get a good seed for your rng.
> >>
> >>
> >> Levente



-----Inline Attachment Follows-----

_______________________________________________
Beginners mailing list
Beginners@...
http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Randomness

Bert Freudenberg
If you are following trunk updates, yes. Otherwise you would have to wait for the next release.

- Bert -

On 07.04.2011, at 14:20, michael rice wrote:

And I can acquire the new behavior by updating Squeak?

Michael

--- On Thu, 4/7/11, Bert Freudenberg <[hidden email]> wrote:

From: Bert Freudenberg <[hidden email]>
Subject: Re: [Newbies] Randomness
To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
Date: Thursday, April 7, 2011, 6:19 AM

The new behavior is that you get a different stream of random numbers each time you start the image. Or at least it's really really unlikely you get the same sequence again. 

- Bert -

On 07.04.2011, at 02:54, michael rice wrote:

So it was a problem? The old behavior was: if I saved a project and quit the image without saving it, the next time I bought up the image and loaded the project I would get the same stream of random numbers. What is the new behavior?

Michael

--- On Wed, 4/6/11, David T. Lewis <<a rel="nofollow" ymailto="mailto:lewis@mail.msen.com" target="_blank" href="x-msg://1774/mc/compose?to=lewis@mail.msen.com">lewis@...> wrote:

From: David T. Lewis <<a rel="nofollow" ymailto="mailto:lewis@mail.msen.com" target="_blank" href="x-msg://1774/mc/compose?to=lewis@mail.msen.com">lewis@...>
Subject: Re: [Newbies] Randomness
To: "A friendly place to get answers to even the most basic questions about Squeak." <<a rel="nofollow" ymailto="mailto:beginners@lists.squeakfoundation.org" target="_blank" href="x-msg://1774/mc/compose?to=beginners@lists.squeakfoundation.org">beginners@...>
Date: Wednesday, April 6, 2011, 8:35 PM

I made the update in Squeak trunk similar to the Etoys image, but used
the existing seed generator in Random>>initialize on the theory that if
the generator is good enough for a new Random, it should be good enough
for an existing one too ;)

Michael, thanks for spotting the problem.

Dave

On Tue, Apr 05, 2011 at 01:16:31PM +0200, Bert Freudenberg wrote:

>
> On 05.04.2011, at 02:32, Levente Uzonyi wrote:
>
> > On Mon, 4 Apr 2011, michael rice wrote:
> >
> >> I forgot to mention, I'm using the random number tile and scripting. Does that make it more difficult?
> >
> > Not really, RandomNumberTile uses the global random number generator of Collection. I don't know how/why is it serialized/restored
>
> It is not stored in the project. But in trunk, the seed does not get re-initialized when starting up. In the Etoys image, Collection class has a startUp method
>
> startUp
>     RandomForPicking seed: Time totalSeconds hash asFloat.
>
> IMHO we should adopt something like this for trunk (maybe with your "more" random approach below).
>
> - Bert -
>
> > but here's a method which should help:
> >
> > RandomNumberTile >> #comeFullyUpOnReload: smartRefStream
> >
> >     | seed |
> >     [
> >         seed := (Time millisecondClockValue bitAnd: 16r3FFFFFFF) bitXor: self hash.
> >         seed := seed bitXor: (Time totalSeconds bitAnd: 16r3FFFFFFF).
> >         seed := seed bitXor: 16r3FFFFFFF atRandom.
> >         seed = 0 ] whileTrue. "Try again if ever get a seed = 0"
> >     Collection mutexForPicking critical: [
> >         Collection randomForPicking seed: seed ].
> >     ^super comeFullyUpOnReload: smartRefStream
> >
> > It's drawback is that it will reseed the rng for every RandomNumberTile. The best solution would be if Etoys would use a custom Random instance or a subclass where this is done by default.
> >
> >
> > Levente
> >
> >>
> >> Michael
> >>
> >> --- On Mon, 4/4/11, Levente Uzonyi <[hidden email]> wrote:
> >>
> >> From: Levente Uzonyi <[hidden email]>
> >> Subject: Re: [Newbies] Randomness
> >> To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
> >> Date: Monday, April 4, 2011, 8:08 PM
> >>
> >> On Mon, 4 Apr 2011, michael rice wrote:
> >>
> >>> I just noticed that when I load a morphic project I get the same stream of random numbers each time. Is there a simple way to install a new different random seed each time the project is loaded?
> >>
> >> If you serialize the Random object, then it will have the same state when it's restored. I guess you should create a subclass of Random, which implements #comeFullyUpOnReload:. That method can reinitialize the seed of the random number generator. You may want to check UUIDGenerator >> #makeSeed if you don't know how to get a good seed for your rng.
> >>
> >>
> >> Levente



-----Inline Attachment Follows-----



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners