Simple Coin toss program

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

Simple Coin toss program

R.D. Latimer
Hi- trying to simulate a coin toss.  I'm putting two objects in a holder - a circle and a star.
I created two variables in the Holder, circleCounter and starCounter (one for heads, one for tails)

I assign the cursor of the Holder a random 1 or 2.

I don't know how to check the position of the cursor.  The simplest way would just be:
 Test if cursor value == 1...

 but I don't see that as a menu option.

So I'm trying:
Test if graphic at cursor == Circle ...  How do I do this - check the value of the graphic or item at the cursor in a holder?

The default value for "Test Holder's graphic at cursor..." is neither the circle or the star, how do I insert either of those two
images into the Test?

Or can I just test the value of the cursor somehow? (Is it a 1 or a 2)

By the way, I've done this in Scratch, it seems easier to put together initially, but the speed is an issue.
For alot of 'spins' - like 1000 or more, it may take in terms of minutes to finish.  I think Etoys will be faster.

Also - can I output the results to a data file?  It'd be nice to graph the results.

In Scratch, I put the results into data lists, these can be exported to .txt files with a right click on the list.

Thanks for your help,
Randy Latimer


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

Re: Simple Coin toss program

Yoshiki Ohshima-2
At Tue, 11 Oct 2011 13:02:09 -0400,
R.D. Latimer wrote:

>
> Hi- trying to simulate a coin toss.  I'm putting two objects in a holder - a circle and a star.
> I created two variables in the Holder, circleCounter and starCounter (one for heads, one for tails)
>
> I assign the cursor of the Holder a random 1 or 2.
>
> I don't know how to check the position of the cursor.  The simplest way would just be:
> Test if cursor value == 1...
>
> but I don't see that as a menu option.

  In the Holder's Viewer, there is a category called "collections" and
there is a tile called "Holder's cursor".  If you drop it to the
Test part of test, you get the comparison there and you can change '>'
to '='.

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

Re: Simple Coin toss program

Steve Thomas
In reply to this post by R.D. Latimer
I made a Coin Toss project that starts with an Etoys challenge for you to build your own coin toss race. You could ask kids what to run a bunch of races, compare results and if they noticed anything about the way the coins move.

I also played around with how to help folks find certain tiles on page 2 using Event Theatre. The problem with this approach is it doesn't work when you switch languages (because it records mouse position)  Would be nice to have some way to add a "how to find this tile" mechanism, for etoys challenges and for folks looking at other peoples scripts. Perhaps an <alt><click> to help show where to find it.

Also on the last page is a visual that you can "scroll" to see the pattern of heads/tails.  It broke down when I made the playfield length ~10,000 (the stamped, images re-arranged when I started scrolling.

Stephen



On Tue, Oct 11, 2011 at 1:02 PM, R.D. Latimer <[hidden email]> wrote:
Hi- trying to simulate a coin toss.  I'm putting two objects in a holder - a circle and a star.
I created two variables in the Holder, circleCounter and starCounter (one for heads, one for tails)

I assign the cursor of the Holder a random 1 or 2.

I don't know how to check the position of the cursor.  The simplest way would just be:
 Test if cursor value == 1...

 but I don't see that as a menu option.

So I'm trying:
Test if graphic at cursor == Circle ...  How do I do this - check the value of the graphic or item at the cursor in a holder?

The default value for "Test Holder's graphic at cursor..." is neither the circle or the star, how do I insert either of those two
images into the Test?

Or can I just test the value of the cursor somehow? (Is it a 1 or a 2)

By the way, I've done this in Scratch, it seems easier to put together initially, but the speed is an issue.
For alot of 'spins' - like 1000 or more, it may take in terms of minutes to finish.  I think Etoys will be faster.

Also - can I output the results to a data file?  It'd be nice to graph the results.

In Scratch, I put the results into data lists, these can be exported to .txt files with a right click on the list.

Thanks for your help,
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