More than one input for a script?

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

More than one input for a script?

R.D. Latimer
I'd like to make a simple drawPolygon script that needs two inputs, one of length of each side and one for number of sides.

The basic prototype is:
 
 drawPolygon (length, sides):
    repeat sides
        forward length
        turn sides/360

With Etoys, It looks like the limit is one input parameter for a script, so that the script would be limited to:

 drawPolygon (sides):
   repeat sides
      forward 100         <-- the user would need to hard code the length of the sides
      turn sides/360

Can I use more than on numerical input in a script?

Thanks,
 Randy Latimer

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

Re: More than one input for a script?

R.D. Latimer
note that drawPolygon should be "turn 360/sides" (below)


On Wed, Aug 31, 2011 at 11:41 AM, R.D. Latimer <[hidden email]> wrote:
I'd like to make a simple drawPolygon script that needs two inputs, one of length of each side and one for number of sides.

The basic prototype is:
 
 drawPolygon (length, sides):
    repeat sides
        forward length
        turn sides/360   <-- turn 360/sides

With Etoys, It looks like the limit is one input parameter for a script, so that the script would be limited to:

 drawPolygon (sides):
   repeat sides
      forward 100         <-- the user would need to hard code the length of the sides
      turn sides/360

Can I use more than on numerical input in a script?

Thanks,
 Randy Latimer


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

Re: More than one input for a script?

Harness, Kathleen
Randy,
Perhaps this project is a partial answer to your questions below:
http://etoysillinois.org/library?sl=1630
Kathleen

From: [hidden email] [[hidden email]] on behalf of R.D. Latimer [[hidden email]]
Sent: Wednesday, August 31, 2011 11:01 AM
To: [hidden email]; Allard, Fred
Subject: Re: [squeakland] More than one input for a script?

note that drawPolygon should be "turn 360/sides" (below)


On Wed, Aug 31, 2011 at 11:41 AM, R.D. Latimer <[hidden email]> wrote:
I'd like to make a simple drawPolygon script that needs two inputs, one of length of each side and one for number of sides.

The basic prototype is:
 
 drawPolygon (length, sides):
    repeat sides
        forward length
        turn sides/360   <-- turn 360/sides

With Etoys, It looks like the limit is one input parameter for a script, so that the script would be limited to:

 drawPolygon (sides):
   repeat sides
      forward 100         <-- the user would need to hard code the length of the sides
      turn sides/360

Can I use more than on numerical input in a script?

Thanks,
 Randy Latimer


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

Re: More than one input for a script?

Karl Ramberg
In reply to this post by R.D. Latimer
Yes, you are limited to one parameter per message send in Etoys.
You can set the length variable before the message send.
Not as functional but works very well.

Karl

On Wed, Aug 31, 2011 at 5:41 PM, R.D. Latimer <[hidden email]> wrote:
I'd like to make a simple drawPolygon script that needs two inputs, one of length of each side and one for number of sides.

The basic prototype is:
 
 drawPolygon (length, sides):
    repeat sides
        forward length
        turn sides/360

With Etoys, It looks like the limit is one input parameter for a script, so that the script would be limited to:

 drawPolygon (sides):
   repeat sides
      forward 100         <-- the user would need to hard code the length of the sides
      turn sides/360

Can I use more than on numerical input in a script?

Thanks,
 Randy Latimer

_______________________________________________
squeakland mailing list
[hidden email]
http://lists.squeakland.org/mailman/listinfo/squeakland



_______________________________________________
squeakland mailing list
[hidden email]
http://lists.squeakland.org/mailman/listinfo/squeakland

script.jpeg (66K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: More than one input for a script?

Steve Thomas
In reply to this post by Harness, Kathleen
When teaching "drawing polygons/40 mathematical shapes challenge" I usually have kids draw a triangle, then a square, then a pentagon.  I then ask them to look at the three scripts they used to draw these shapes and ask what they notice about them, what is the same and what is different?

They usually pick up on the only difference is the turn value and length values.  I then introduce them to variables and ask them to create "one script to rule them all"  Which usually leads to an aha and cool moment.

I like the Etoys challenge method of introducing this where the scripting tiles for "repeat", "turn by" and "forward by" are on the playfield.

An excellent introduction to this is to have the kids program themselves before they program the computer.  I sometimes start off by having them program me to "walk a square".  Then when the say "turn" or "turn right" I turn by a non 90 degree amount or make a complete 360 degree turn, which usually invites giggles and "No that's not what I meant" Then I talk about the importance of using specific language. After they program me and have that experience I ask them to program each other. You can use sidewalk chalk as the pen as well.


The Scratch team had a great idea where they made "cards" (on 8.5 x 11 pieces of paper/card stock) with different scripting tiles the the kids could use to create the "program".

Stephen

On Wed, Aug 31, 2011 at 12:09 PM, Harness, Kathleen <[hidden email]> wrote:
Randy,
Perhaps this project is a partial answer to your questions below:
http://etoysillinois.org/library?sl=1630
Kathleen

From: [hidden email] [[hidden email]] on behalf of R.D. Latimer [[hidden email]]
Sent: Wednesday, August 31, 2011 11:01 AM
To: [hidden email]; Allard, Fred
Subject: Re: [squeakland] More than one input for a script?

note that drawPolygon should be "turn 360/sides" (below)


On Wed, Aug 31, 2011 at 11:41 AM, R.D. Latimer <[hidden email]> wrote:
I'd like to make a simple drawPolygon script that needs two inputs, one of length of each side and one for number of sides.

The basic prototype is:
 
 drawPolygon (length, sides):
    repeat sides
        forward length
        turn sides/360   <-- turn 360/sides

With Etoys, It looks like the limit is one input parameter for a script, so that the script would be limited to:

 drawPolygon (sides):
   repeat sides
      forward 100         <-- the user would need to hard code the length of the sides
      turn sides/360

Can I use more than on numerical input in a script?

Thanks,
 Randy Latimer


_______________________________________________
squeakland mailing list
[hidden email]
http://lists.squeakland.org/mailman/listinfo/squeakland



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

Re: More than one input for a script?

Steve Thomas
In reply to this post by Harness, Kathleen
Randy,

Moving covnersation to squeakland list so others can comment.
See my comments below on your latest email.

A lot of what I believe you are trying to do in Etoys (based on your example NetLogo script) can be done, but it needs a seperate email to respond.

Stephen

On Fri, Sep 2, 2011 at 11:02 AM, Avigail Snir <[hidden email]> wrote:

From: R.D. Latimer [mailto:[hidden email]

Sent: Friday, September 02, 2011 7:40 AM
To: Avigail Snir
Cc: Harness, Kathleen; Allard, Fred


Subject: Re: [squeakland] More than one input for a script?

 

Thank you Avigail for sharing these projects.  They look great, they'll be helpful in our program.

I'm not sure why the programming team for Etoys has limited the number of inputs to scripts. 

Most likely to maintain simplicity would be my guess.
 

A script can be seen as a procedure in a programming language. Also It would also be nice if these scripts could return values, then there could be 'function' scripts.  So in that sense, Etoys eventually may get to a limitation when connecting with other computer languages available.

BYOB/Scratch has incorporated procedures/functions into Scratch via programmable blocks - which for me are analogous to Etoys scripts.

What you say makes sense for functional programming languages.  Etoys was inspired by Alan Kay's work on the Dynabook and smalltalk and thus was designed to be object oriented. Now Alan's definition of object oriented is very different from the common understanding,  I would highly recommend Alan's talk at HPI .  Etoys is built on first principles with the goal of being able to build "anything" from a small set of first principle objects.


In Etoys is there a data structure for lists/arrays of data? 

Etoys uses the concept of a collection which is more powerful than the Scratch and BYOB use of lists in that anything can be in a collection.  You can use a Holder (which is a specialized version of a playfield) to iterate through objects (holders, books, pages and world are all specialized versions of playfield which support the collection category).

That said you also have the full power of sqeuak underneath. Simply click on the menu icon in the script editor and click "show code textually" and you can see the Squeak version of the code.  Unfortunately the translation is only one way you can go from tiles to text, but not text to tiles.

BYOB's speed slows down when accessing lists of data, at least from what I've seen so far.  THat can be a limitation, the speed issue. 

For example, if I want to play a melody from a long list of note values, the speed of accessing parts of the list is important for the rhythm of the melody.
Also, sorting a list of numbers can be slow in BYOB. 

Check this thread from the squeakland mail list which discusses playing musical notes in Etoys.  Bert has a nice solution and shows the script and use of a Holder.


Thanks again for helping out,
Randy

On Thu, Sep 1, 2011 at 7:39 PM, Avigail Snir <[hidden email]> wrote:

Hi Randy,

My name is Avigail Snir and I am a member of the Etoys Illinois team.

Regarding your mail to Kathleen Harness: I think that 2 features of Etoys will help you get most of the things you mentioned:

variables: One can create new variables for an object (e.g. value for "forward by" or for "turn by") by clicking the "V" on the top of the viewer (brown background) . this variables can replace any numeric value just by dragging it over the location in the script one wish it to be (drag while cursor is on the name of the variable, not by the assignment long green arrow).

The value of this variables, and any others can be changed directly at the viewer, or at a watcher one can produce. For watchers look at the build in Help guide  in the MENU section. To open the Help guide click the "?" up in the Navigator. Every section has many entries. Every such entry is in the format of a small 4 page book.

 

Random numbers are available to replace any numerical value. You can find out how to use them at the ScriptTile section of the Help guide.

 

In the Help guide, under Object Catalog you will find instructions for use of the readymade slider. The slider is now available when you open the supplies box in the navigator, at the time the guide was written, you had to look for it in the Object Catalog.

 

Sample of projects that are using this features:

A canon with sliders for Gravity, Angle and Speed of the ball:

http://etoysillinois.org/library?sl=1626&viewProject

A guided inquiry into the geometry of Forward and Turn, with full analysis.

http://etoysillinois.org/files/Geometry%20of%20Fand%20T%202%20_3_.pdf

The Etoys project that correspond to it is:  http://etoysillinois.org/library?sl=241&viewProject

Draw Polygons:  http://etoysillinois.org/library?sl=1621&viewProject

Create a Spider Web:  http://etoysillinois.org/library?sl=1864&viewProject

Leap Frog:  http://etoysillinois.org/library?sl=841

 

For thought provoking small projects:

Something About Gravity  http://etoysillinois.org/library?sl=566

Some Things About Bouncing Part 1:  http://etoysillinois.org/library?sl=1002

 

 

This is a long list and I am not sure it answers some/any of your questions.

Please feel free to ask more, or contact me to set time for  a Skype meeting.

 

Avigail

 

 

From: Harness, Kathleen [mailto:[hidden email]]
Sent: Thursday, September 01, 2011 12:06 PM
To: R.D. Latimer
Cc: Allard, Fred; Snir, Avigail
Subject: RE: [squeakland] More than one input for a script?

 

Hi Randy,
Etoys has is rich in programming features, tools and menus and is powerful and very flexible. Do you intend to use the projects as models of one that students will create or as models where they will use your pre-built projects for experiments?

Are you teaching elementary/middle school/high school? Are you a math teacher with an interest in programming or a CS teacher? It sounds like you are trying many OOPL languages and having fun doing it.

The example you sent can be done in Etoys. I am copying Avigail Snir who works with me at EtoysIllinois and she may be better able to guide you in making these models.  We have found that Etoys has very few limits within the software but that the more experienced the programmer the more the assets can be exploited. For example, StarLogo TNG is very strong at modeling with many agents but Etoys can do the same with siblings or by using the Particles found in the Object Catalog. Particles is a special set of tiles that can be used to make massively parallel particle simulations.

I wonder, have you had time to read the Quick Guides? I think many of your gerneral questions are answered in the introductions that they provide to basic tools, tiles, and techniques.  Also, the Library Collection has some projects similar to the ones you are describing and they could be downloaded, mixed, remixed and saved on you machine to use as you wish. The CS4HS projects do not have lesson materials (yet) but the projects can be downloaded and Viewers and scripts can be examined. They use more advanced math and more sophisticated script constructions.

The K-5 Technology Passport projects have lesson plans that I wrote for teachers with no previous experience with programming. The CS4K5 projects have similar lesson plans for the same audience but are a different set of project examples.
Regards,
Kathleen


From: R.D. Latimer [[hidden email]]
Sent: Thursday, September 01, 2011 9:03 AM
To: Harness, Kathleen
Cc: Allard, Fred


Subject: Re: [squeakland] More than one input for a script?

Hi Kathleen,
 Here's a sample NetLogo spinpolygon program, this is one of the programs Fred and I used last spring with the kids.  There's lots to talk about and analyze here.

  I'm working on an Etoys version, but Etoys may not have some of the programming features available. 
  Setup and Clearscreen, clears everything and creates the turtle objects in random locations.
  Go draws 'spinning' polygons with the number of sides and length of each side set by the sliders on the interface
  Flowers - has each turtle draw 5 'spinning' polygons in random locations
  RandomFlowers - each turtle draws 2 'spinning' polygons with random numbers of sides and random side lengths.

Thanks again,
Randy Latimer 
 

to setup
  clear-all
  crt numberofturtles
  ask turtles [clearscreen]
end

to clearscreen
  penup
  setxy random-xcor random-ycor
  set heading 90
  pendown
end

to go
  ask turtles [
    set color rgb random 256 random 256 random 256
    spinpolygon sides sidelength 20
  ]
end

to flowers
  ask turtles [
    repeat 5 [
    leap random-xcor random-ycor
    set color rgb random 256 random 256 random 256
    spinpolygon sides sidelength 20
    ]
  ]
end

to randomflowers
  ask turtles [
    repeat 2 [
      leap random-xcor random-ycor
      set color rgb random 256 random 256 random 256
      spinpolygon (random 9 + 3) (random 3 + 2) (random 10 + 4)
    ]
  ]
end

to square [len]
  repeat 4 [fd len rt 90]
end

to polygon [numsides len]
  repeat numsides [fd len lt 360 / numsides]
end

to spinpolygon [numsides len times]
  repeat times [polygon numsides len lt 360 / times]
end

to spinpolygoncolor [numsides len times]
  repeat times [set color rgb random 256 random 256 random 256
    polygon numsides len lt 360 / times]
end

to leapposition
  ask turtles [leap random-xcor random-ycor]
end

to leap [x y]
  penup
  setxy x y
  pendown
end

On Thu, Sep 1, 2011 at 9:40 AM, R.D. Latimer <[hidden email]> wrote:

Thanks again for your help Kathleen, this is very nice of you to help out with these project files.
Do you you have BYOB/Scratch and NetLogo on your computer?  I can send you example projects Fred and I are working with, and that we used last Spring '11.
http://byob.berkeley.edu/
http://ccl.northwestern.edu/netlogo/

I'll send you a sample NetLogo program shortly, "spinpolygons"

Randy

 

On Thu, Sep 1, 2011 at 9:37 AM, R.D. Latimer <[hidden email]> wrote:

These folks are nice with their help...

 

On Wed, Aug 31, 2011 at 3:35 PM, Harness, Kathleen <[hidden email]> wrote:

Randy,
See attached project, I think it is what you are describing. I added a few comments and a diagram of the angle that does the work. I am familiar with Scratch and with StarLogo TNG. The EtoysIllinois team is consulting on a grant at MIT with those software educators to write curriculum that is parallel from one to the other in a set of projects that introduce programming to middle and high schools students. It is familiar and alien territory at the same time, isn't it.
Regards,
Kathleen


From: R.D. Latimer [[hidden email]]
Sent: Wednesday, August 31, 2011 11:38 AM
To: Harness, Kathleen; Allard, Fred


Subject: Re: [squeakland] More than one input for a script?

 

Hi Kathleen,
 (I hesitated sending the jpg to all squeakland list)
Here's what I'm trying to do, this is a jpg of the project in BYOB/Scratch
(I can send a link to their page if you need it)

I think I can duplicate all of this in EToys, except for the need for 2 inputs - the first is the side length, the second is the number of sides.
So in this example I'm drawing a 12 sided polygon with a length 50 for each side.

So I could put a call to this drawPolygon inside of a loop, and change the number of sides and length of sides, for example randomizing each, and I'd get pictures of many different kinds of polygons - lengths and numbers of sides.

In the Etoys example, this is similar, except the user needs to change sides and length of sides each time, rather than the program being able to generate various polygons.
Randy

On Wed, Aug 31, 2011 at 12:09 PM, Harness, Kathleen <[hidden email]> wrote:

Randy,
Perhaps this project is a partial answer to your questions below:
http://etoysillinois.org/library?sl=1630
Kathleen


From: [hidden email] [[hidden email]] on behalf of R.D. Latimer [[hidden email]]
Sent: Wednesday, August 31, 2011 11:01 AM
To: [hidden email]; Allard, Fred
Subject: Re: [squeakland] More than one input for a script?

note that drawPolygon should be "turn 360/sides" (below)

On Wed, Aug 31, 2011 at 11:41 AM, R.D. Latimer <[hidden email]> wrote:

I'd like to make a simple drawPolygon script that needs two inputs, one of length of each side and one for number of sides.

The basic prototype is:
 
 drawPolygon (length, sides):
    repeat sides
        forward length
        turn sides/360   <-- turn 360/sides

With Etoys, It looks like the limit is one input parameter for a script, so that the script would be limited to:

 drawPolygon (sides):
   repeat sides
      forward 100         <-- the user would need to hard code the length of the sides
      turn sides/360

Can I use more than on numerical input in a script?

Thanks,
 Randy Latimer

 

 

 

 

 

 



_______________________________________________
squeakland mailing list
[hidden email]
http://lists.squeakland.org/mailman/listinfo/squeakland