>> >> p.p.s. inspired by Paul Bissex - a guy who once wrote a small article >> about squeak for Wired - challenge on: >> http://e-scribe.com/news/193 >> I wrote an Etoys version of this "reverse"-game. >> It can be found on >> http://www.squeakland.org/project.jsp?http://www.emergent.de/pub/ >> smalltalk/squeak/projects/reverse.pr >> >> (I hope you all have the squeakland plugin installed... ;-) ) >> >> It has only a few lines more than the smalltalk (I included a >> smalltalk version), python, ruby,... version but comes with a much >> more sophisticated user interface. >> So I do think that Etoys are the way to go... no matter what the >> language is underneath - be it smalltalk/python/ruby/etc... On Jul 7, 2006, at 8:09 PM, Chris Muller wrote: >> > > Hi Markus, I didn't see any Smalltalk on that page. Just for fun I > coded up that reverse game and posted it, we'll see if it shows > up. It > was 8 lines "beating" Ruby by 2 lines and Python by 1. > > Here's the code I ended up with: > > numbers := (1 to: 9) asArray shuffled. > steps := 0. > > [ Transcript cr; show: numbers. > numbers isSorted ] whileFalse: > [ flipCount := (FillInTheBlank request: 'reverse how many?') > asNumber. > 1 to: flipCount//2 do: [ :n | numbers swap: n with: flipCount-n+1 ]. > steps := steps + 1 ]. > > Transcript cr; show: 'done, that took you ', steps printString, ' > steps.' > > Strange, I'm not sure why there are ~20 languages (including "REBOL") > represented but no mention of Smalltalk anywhere, especially if you > had > submitted it.. Hi Chris, thanks! Using your swap and isSorted methods and our extreme naked objects approach ;-) I came up with a version of 7 lines: steps := 0. numbers := (1 to: 9) asArray shuffled. [numbers isSorted ] whileFalse: [flipCount:= numbers indexOf: ((SelectionMenu selections: numbers) startUpWithCaption: 'Revert up to which number?') . 1 to: flipCount//2 do: [ :n | numbers swap: n with: flipCount-n+1 ]. steps := steps + 1]. PopUpMenu inform: 'You needed ', steps asString,' steps.' Don't know, why it did not show up, Paul sent me a mail that he liked squeak and wanted to add it...so I added him here on the bcc. Anyone tried the Etoys-Version? Someone told me that it was not working for him, but I did not investigate... http://www.squeakland.org/project.jsp?http://www.emergent.de/pub/ smalltalk/squeak/projects/reverse.pr Cheers, Markus p.s. The following Python script does not work for me under OS-X. Maybe sorted() and reversed() need some library here? import random numbers = random.sample(range(1,10), 9) steps = 0 while numbers != sorted(numbers): print " ".join(map(str, numbers)) flipcount = int(raw_input("Reverse how many? ")) numbers[:flipcount] = reversed(numbers[:flipcount]) steps += 1 print "Done! That took you %d steps." % steps _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Hey Chris,
thanks! (blush) I actually did not realize the keyboard-interface - you can actually type in the number to which you want to revert and then enter. Thanks for pointing this out... :-) Here is a slightly improved version, that keeps the "playfield" ;-) at the same place... steps := 0. numbers := (1 to: 9) asArray shuffled. [numbers isSorted] whileFalse: [flipCount:= numbers indexOf: ((SelectionMenu selections: numbers) startUpWithCaption: 'Revert up to which number?' at: Display center ). 1 to: flipCount//2 do: [:i | numbers swap: i with: flipCount-i+1]. steps := steps + 1]. PopUpMenu inform: 'You needed ', steps asString,' steps to sort the list.' Cheers, Markus p.s. I am wondering what it would take to write a version by scripting some morphs - and not exploiting the poor SelectionMenu... On Jul 11, 2006, at 9:16 PM, Chris Muller wrote: > That is great! Not only is the program more stable because you can't > make bad input, but you also have a visual interface with both > keyboard > AND mouse support. We should get extra credit. > > What other language/environment can touch that?! > > :) > > > --- Markus Gaelli <[hidden email]> wrote: > >> >>>> >>>> p.p.s. inspired by Paul Bissex - a guy who once wrote a small >> article >>>> about squeak for Wired - challenge on: >>>> http://e-scribe.com/news/193 >>>> I wrote an Etoys version of this "reverse"-game. >>>> It can be found on >>>> http://www.squeakland.org/project.jsp?http://www.emergent.de/pub/ >>>> smalltalk/squeak/projects/reverse.pr >>>> >>>> (I hope you all have the squeakland plugin installed... ;-) ) >>>> >>>> It has only a few lines more than the smalltalk (I included a >>>> smalltalk version), python, ruby,... version but comes with a much >>>> more sophisticated user interface. >>>> So I do think that Etoys are the way to go... no matter what the >>>> language is underneath - be it smalltalk/python/ruby/etc... >> >> On Jul 7, 2006, at 8:09 PM, Chris Muller wrote: >>>> >>> >>> Hi Markus, I didn't see any Smalltalk on that page. Just for fun I >>> coded up that reverse game and posted it, we'll see if it shows >>> up. It >>> was 8 lines "beating" Ruby by 2 lines and Python by 1. >>> >>> Here's the code I ended up with: >>> >>> numbers := (1 to: 9) asArray shuffled. >>> steps := 0. >>> >>> [ Transcript cr; show: numbers. >>> numbers isSorted ] whileFalse: >>> [ flipCount := (FillInTheBlank request: 'reverse how many?') >>> asNumber. >>> 1 to: flipCount//2 do: [ :n | numbers swap: n with: flipCount-n+1 >> ]. >>> steps := steps + 1 ]. >>> >>> Transcript cr; show: 'done, that took you ', steps printString, ' >>> steps.' >>> >>> Strange, I'm not sure why there are ~20 languages (including >> "REBOL") >>> represented but no mention of Smalltalk anywhere, especially if you >>> had >>> submitted it.. >> >> Hi Chris, >> >> thanks! Using your swap and isSorted methods and our extreme naked >> objects approach ;-) >> I came up with a version of 7 lines: >> >> steps := 0. >> numbers := (1 to: 9) asArray shuffled. >> [numbers isSorted ] whileFalse: >> [flipCount:= numbers indexOf: ((SelectionMenu selections: numbers) >> startUpWithCaption: 'Revert up to which number?') . >> 1 to: flipCount//2 do: [ :n | numbers swap: n with: flipCount-n+1 ]. >> steps := steps + 1]. >> PopUpMenu inform: 'You needed ', steps asString,' steps.' >> >> Don't know, why it did not show up, Paul sent me a mail that he liked >> squeak and wanted to add it...so I added him here on the bcc. >> >> Anyone tried the Etoys-Version? Someone told me that it was not >> working for him, but I did not investigate... >> >> http://www.squeakland.org/project.jsp?http://www.emergent.de/pub/ >> smalltalk/squeak/projects/reverse.pr >> >> Cheers, >> >> Markus >> >> p.s. The following Python script does not work for me under OS-X. >> Maybe sorted() and reversed() need some library here? >> >> import random >> >> numbers = random.sample(range(1,10), 9) >> steps = 0 >> >> while numbers != sorted(numbers): >> print " ".join(map(str, numbers)) >> flipcount = int(raw_input("Reverse how many? ")) >> numbers[:flipcount] = reversed(numbers[:flipcount]) >> steps += 1 >> >> print "Done! That took you %d steps." % steps >> >> >> >> >> > > _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Markus Gälli-3
(cross-post from beginners list)
On 7/11/06, Markus Gaelli <[hidden email]> wrote: > > Anyone tried the Etoys-Version? Someone told me that it was not > working for him, but I did not investigate... > http://www.squeakland.org/project.jsp?http://www.emergent.de/pub/smalltalk/squeak/projects/reverse.pr Yes - it is fun and has a lovely interface. (I am using Linux and Firefox - and I have a squeakland-3.8-1.noarch.rpm from www.squeakland.org) It is a great demo of the power of tiles and Etoys. I am brand new to smalltalk and Etoys, and to 'everything is an object'. So, I tried to teach myself something from Markus work. My learning anecdote is included as a p.s. My tentative conclusion - it feels like I have a long learning curve ahead of me - a curve of building, breaking and repairing many Etoys, and learning the underlying development tools, before I could confidently assist a 12 year old who wants to make his imagination come to life on his computer screen. I intend to embark on that learning curve. I hope to be surprised later when my nephew takes the odd 'message not understood' dialog in his stride, deletes (or loses) some of his work, and starts again in the excitement of authoring his own multimedia product. Do my thoughts resonate with those of you more experienced, or is it easier than it looks to introduce tile scripting to kids? BTW - thanks Markus and best regards, David p.s. my anecdote : to teach myself a little from Markus's Reverse Game, I click around a bit to try to work out 1. why/how do all the buttons run the same scripts? 2. where is the HelperStack? In overenthusiastic clicking, I delete a ScriptStatusControl and break the toy :( ('Message not understood' dialog whenever I click on a number cell.) I decide this is another learning opportunity. A couple of minutes clicking around and I haven't found out how to give the broken script a new status control. I googled aound a bit for docs, but I know too little about Squeak to know what to ask Google. Next I try to make a new tile script from scratch (monkey see - monkey do) Oops! I accidentally click on a 'send message' (! bang) button, and Squeak goes into a busy loop. The screen is not updating at all, and my processsor is at 100% for 3 or 4 minutes. Finally, my processor load goes back to normal, but still nothing is happening in the Squeak window. I still don't know the answers to my first two questions. I have more sympathy with Chris Cunnington. _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Hi David,
On Jul 13, 2006, at 11:28 AM, David Corking wrote:
I cc it to squeakland, as this is the preferred list to discuss Etoy-related questions.
Thank you for trying. Glad that it works and that you like it. :-)
Etoys is a nice implementation of prototype systems as it stems back from "self". That means, that you can create shallow copies of any morph using "siblings...". So I created one cell, and then via red menu halo "Siblings..." -> "Create multiple Siblings..." I created another 8 siblings of this one. A script done for one morph then also applies to all its siblings. If you change that script, all siblings change their behavior also, as they share the very same script.
This is the one behind the ReverseStack. (The one where you can only see the orange outline, I should have denoted it...) In Etoys you can only program visual objects. Thus I used that HelperStack to put in the cell at the cursor of the ReverseStack (which always denotes the first cell) until the clicked cell is at the first position. As the cells are always included at the last position of the HelperStack (using the default include: method) and afterwards included at the first position of the ReverseStack (using the includeAtCursor: method) the cells get reversed. But I agree, as long as Etoys do not provide a visual debugger, where one could watch each step animated, it is hard to understand what is going on. For a start you could drag (thus disable) the "HelperStack tellAllContents: includeInReverseField"-tile out of its script to actually see the cells in the ReverseStack after pressing some cell.
This project is intended to show (off ;-) what could be done with Etoys and really pushing its limits. I guess it is less suited as a general intro, but - who knows? Cheers, Markus _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
On 7/13/06, Markus Gaelli <[hidden email]> wrote:
> 1. why/how do all the buttons run the same > scripts? > > Etoys is a nice implementation of prototype systems as it stems back from > "self". > That means, that you can create shallow copies of any morph using > "siblings...". > So I created one cell, and then via red menu halo "Siblings..." -> "Create > multiple Siblings..." I created another 8 siblings of this one. > > A script done for one morph then also applies to all its siblings. If you > change that script, all siblings change their behavior also, as they share > the very same script. A very useful lesson - thank you Markus. This is looks quite different from the class methods of some other object systems. > 2. where is the HelperStack? > > This is the one behind the ReverseStack. (The one where you can only see the > orange outline, I should have denoted it...) > > In Etoys you can only program visual objects. > Thus I used that HelperStack to put in the cell at the cursor of the > ReverseStack (which always denotes the first cell) until the clicked cell is > at the first position. > As the cells are always included at the last position of the HelperStack > (using the default include: method) and afterwards included at the first > position of the ReverseStack > (using the includeAtCursor: method) the cells get reversed. > > But I agree, as long as Etoys do not provide a visual debugger, where one > could watch each step animated, it is hard to understand what is going on. > For a start you could drag (thus disable) the > "HelperStack tellAllContents: includeInReverseField"-tile out of its script > to actually see the cells in the ReverseStack after pressing some cell. I should have put a break point in there as well - I put Squeak in an infinite loop all over again. Anyway - I see your trick now! > In overenthusiastic clicking, I delete a ScriptStatusControl and break > the toy :( ('Message not understood' dialog whenever I click on a > number cell.) I decide this is another learning opportunity. A > couple of minutes clicking around and I haven't found out how to give > the broken script a new status control. I googled aound a bit for > docs, but I know too little about Squeak to know what to ask Google. > Next I try to make a new tile script from scratch (monkey see - monkey > do) > > Oops! I accidentally click on a 'send message' (! bang) button, and > Squeak goes into a busy loop. The screen is not updating at all, and > my processsor is at 100% for 3 or 4 minutes. Finally, my processor > load goes back to normal, but still nothing is happening in the Squeak > window. > > If you are not in the browser Ctrl-. could work to interrupt a process - > otherwise it might be the best to just restart and reload... :-/ Without labouring a point that has been discussed many times, this kind of defeats the concepts of persistence of objects in the Squeak image and independence from the host operating system. - if a child had lots of artwork in their project, they would have to save an image or a project file regularly, so they could backtrack in case I come along and break the project. Which is best - project file or changeset or image file? > I still don't know the answers to my first two questions. I > have more sympathy with Chris Cunnington. > > > This project is intended to show (off ;-) what could be done with Etoys and > really pushing its limits. > I guess it is less suited as a general intro, but - who knows? You are right - there is a lot more in here than in the 'Drive a Car' toy. And, you hid the Navigator and Supplies flaps to further confuse a beginner :) But, it would be a good way to learn about ideas like sorting, arrays, and, if I understand it correctly, an event driven approach to applying the same action to multiple objects (this is very fashionable in the current world of Service Oriented Architecture and 'middleware' ... but it probably has general application to computation, problem-solving and domain modelling for children.) _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Free forum by Nabble | Edit this page |