[Sugar-devel] Karma.rand() and Karma.shuffle() remarks

Bryan Berry bryan at olenepal.org
Sat Jan 9 20:51:38 EST 2010


Bert, we did have Squeak programmers but they all emigrated and are
difficult to get in touch with.

I will bother Surendra, who you met, to see if he can help

On Sat, Jan 9, 2010 at 9:57 PM, Bert Freudenberg <bert at freudenbergs.de>wrote:

> Well, OLE Nepal does have Squeak programmers, and it should be rather
> simple for them to write a snippet that exports images and sounds from a
> loaded project.
>
> It's just a bit harder (but I guess not too much) to load each project in a
> folder and export assets found there (the trick would be to just load the
> project but not enter it).
>
> Extracting them without Squeak is rather infeasible.
>
> - Bert -
>
> On 09.01.2010, at 16:39, Tomeu Vizoso wrote:
> >
> > Adding sugar-devel to CC in case Bert wants to say anything
> >
> > On Sat, Jan 9, 2010 at 16:36, Peter Gijsels <peter.gijsels at gmail.com>
> wrote:
> >> Vaibhaw,
> >>
> >> You seem to imply that there is a (difficult) way to extract them,
> >> could you elaborate?
> >>
> >> Do you think it would be useful to have a simple way to extract these
> >> assets from a .pr file?
> >>
> >> I can try to see if I can come up with something. I'm not guaranteeing
> >> anything, but I think it might be worth a shot. I think it would be
> >> more fun than cropping screenshots. ;-)
> >>
> >> I have two possible approaches in mind:
> >> 1) There is probably a central place where the .pr is being read in
> >> and Morph objects are being constructed. If we intercept objects of
> >> the correct type we can dump their image data to a file. The trick is
> >> to find the code that does the deserializing which can be rather
> >> frustrating in Smalltalk if you are not familiar with the code.
> >>
> >> 2) The second approach would be to just walk over all objects, see if
> >> they are an image, and dump them to files.
> >>
> >> Do you have a Squeak development image (with development tools like
> >> the browser and inspector) from which I can read in these .pr files so
> >> that I can poke around a bit?
> >>
> >> Regards,
> >> Peter
> >>
> >> On Sat, Jan 9, 2010 at 3:04 PM, Vaibhaw (Bob) Poddar
> >> <vaibhawp at yahoo.co.uk> wrote:
> >>> Afraid not. There is no (easy) way to extract the info from the .pr
> files. I
> >>> have been just cropping the images out from the screen shots so far.
> >>>
> >>> Vaibhaw (Bob) Poddar
> >>>
> >>> Nepal Cell. +977.98510.61345
> >>> India Cell. +91.99999.15661
> >>> US of A Cell. +1.415.508.4503
> >>>
> >>> http://HimalayanTechies.com
> >>>
> >>> On 1/9/2010 7:43 PM, Peter Gijsels wrote:
> >>>
> >>> Bryan, Vaibhaw,
> >>>
> >>> I've got epaath working on my windows machine.
> >>>
> >>> Do I understand correctly that all of the materials of a lesson are
> >>> contained in one .pr file, e.g. 6_English_actionVerb_3.018.pr? The
> >>> epaath.image running on the squeak vm loads in that file.
> >>>
> >>> Is there an easy way to extract the pictures and sounds from the .pr
> >>> file of the lesson?
> >>>
> >>> Regards,
> >>> Peter
> >>>
> >>> On Thu, Jan 7, 2010 at 5:45 AM, Vaibhaw (Bob) Poddar
> >>> <vaibhawp at yahoo.co.uk> wrote:
> >>>
> >>>
> >>> Step to get Squeak working on a Windows machine (not sure how on a
> Linux
> >>> distribution).
> >>>
> >>> Download and install squeak
> >>> http://www.squeakland.org/download/
> >>>
> >>> Replace the etoys.image inside the Etoys/Etyos.app/Contents/Resources
> with
> >>> the image file from the E-Paath.
> >>>
> >>> That should be it. If you run into any issues I would be happy to look
> at
> >>> that.
> >>>
> >>> Thanks
> >>>
> >>> Vaibhaw (Bob) Poddar
> >>>
> >>> Nepal Cell. +977.98510.61345
> >>> India Cell. +91.99999.15661
> >>> US of A Cell. +1.415.508.4503
> >>>
> >>> http://HimalayanTechies.com
> >>>
> >>> On 1/7/2010 7:44 AM, Bryan Berry wrote:
> >>>
> >>> here is the file http://karma.sugarlabs.org/Squeak.tar.bz2
> >>>
> >>> These are all the Squeak files in the current EPaath. I am not sure how
> to
> >>> actually view the individual projects.
> >>> Vaibhaw: how do we do that? My Squeak skills are rusty
> >>>
> >>> On Thu, Jan 7, 2010 at 7:06 AM, Bryan Berry <bryan at olenepal.org>
> wrote:
> >>>
> >>>
> >>> hey Peter,
> >>> first could u use pastie.org or jsbin.com for small code samples?
> makes it
> >>> easier for everyone to view and comment on your code
> >>>
> >>> On Thu, Jan 7, 2010 at 3:47 AM, Peter Gijsels <peter.gijsels at gmail.com
> >
> >>> wrote:
> >>>
> >>>
> >>> Hi Bryan,
> >>>
> >>> I had a look at the Karma.rand() and Karma.shuffle() functions and
> >>> have some remarks.
> >>>
> >>> Here is a link to some code illustrating the comments below:
> >>> http://dl.dropbox.com/u/3249723/js-shuffle.tgz
> >>>
> >>> It contains the current Karma implementation of these two functions,
> >>> an alternative implementation (AlternativeKarma) and some code to
> >>> print some histograms.
> >>>
> >>> 1) The values returned by Karma.rand(min, max) are not uniform: the
> >>> probability of getting min is half of any other element between min
> >>> and max. The same goes for max. If you use Math.floor i.s.o.
> >>> Math.round (and adjust the argument to Math.random) you have a uniform
> >>> distribution.
> >>>
> >>>
> >>> Good point! Let's use your code
> >>> do you have any idea how we could write a unit test to check that
> values
> >>> aren't uniform? That way I don't change it back to a crappy
> implementation
> >>> by accident later
> >>>
> >>>
> >>>
> >>> 2) The Karma.shuffle(array) function does not return each permutation
> >>> with equal probability. If you work through the math for a three
> >>> element array you can derive this. Or you can simply make a histogram
> >>> ;-) In the code linked above I make a histogram and you can see that
> >>> not every permutation is equally probable. The alternative
> >>> implementation uses the Fisher-Yates algorithm, and does not have this
> >>> problem.
> >>>
> >>>
> >>>
> >>>
> >>> 3) The unit test for Karma.shuffle is not deterministic: it will fail
> >>> with a probability 5/5! = 1/24. I do not know of a good way to test
> >>> these kind of functions. You could do something like the histogram
> >>> thing in the code above and check that the distribution is roughly
> >>> uniform. But then the test is still not deterministic and if you want
> >>> a small chance of failure, running the test would take a bit of time.
> >>> Maybe one thing that you should check is that the result of calling
> >>> shuffle() contains the same elements as the original (sort both and
> >>> see that they have the same elements in the same position).
> >>>
> >>>
> >>> Ouch, you can tell that my CS fundamentals are pretty weak ;)
> >>> I think that shuffling only 5 elements isn't really a valid test,
> better
> >>> to shuffle 25 elements and see if it fails out of 100 tests. I think
> 1/500
> >>> is a tolerable failure rate, what do u think?
> >>> let me test that out now
> >>>
> >>>
> >>> On an unrelated note, did you have time to prepare a download link
> >>> with the Squeak stuff? Tomorrow evening I have some time to have a
> >>> look at it.
> >>>
> >>> Regards,
> >>> Peter
> >>>
> >>>
> >>> Sorry I uploaded most of the files but forget to upload one important
> >>> file, the squeak image ;). I will upload that now and send you the link
> >>> shortly
> >>>
> >>>
> >>>
> >>> No virus found in this incoming message.
> >>> Checked by AVG - www.avg.com
> >>> Version: 9.0.725 / Virus Database: 270.14.127/2603 - Release Date:
> 01/06/10
> >>> 13:20:00
> >>>
> >>>
> >>>
> >>>>
> >>>
> >>>
> >>> No virus found in this incoming message.
> >>> Checked by AVG - www.avg.com
> >>>
> >>> Version: 8.5.432 / Virus Database: 270.14.131/2609 - Release Date:
> 01/09/10
> >>> 07:35:00
> >>>
> >>>
> >>
> >
> >
> >
> > --
> > «Sugar Labs is anyone who participates in improving and using Sugar.
> > What Sugar Labs does is determined by the participants.» - David
> > Farning
> > _______________________________________________
> > Sugar-devel mailing list
> > Sugar-devel at lists.sugarlabs.org
> > http://lists.sugarlabs.org/listinfo/sugar-devel
>
>
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.sugarlabs.org/archive/sugar-devel/attachments/20100110/65ad81b7/attachment.htm 


More information about the Sugar-devel mailing list