Re: Randomness + Pause/Delay?

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

Re: Randomness + Pause/Delay?

Michael Rice-3
I ported my morphic app to Etoys and it does indeed work differently (randomly) now each time I bring it up.. The app simulates a simple game with two players taking turns putting their colored blocks (blue and red) upon one of two towers, randomly selected. The game ends when both towers are topped with the same color.

In a playfield, the playGame pseudocode script:

TEST towers topped with same color blocks
  YES initialize game to starting conditions
  NO blueAction
        redAction
 

But the two scripts, blueAction and redAction, in sequence, appear to happen simultaneously. Is there a delay mechanism, like a marktime tile, that could separate two scripts by a specified number of ticks? If not, are there any plans for one?

Michael



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

Re: Randomness + Pause/Delay?

dcorking
On Thu, Apr 7, 2011 michael rice  wrote:

>
> But the two scripts, blueAction and redAction, in sequence, appear to happen simultaneously.
> Is there a delay mechanism, like a marktime tile, that could separate two scripts by a specified
> number of ticks? If not, are there any plans for one?

I saw these two posts last year. They might help:

http://lists.squeakland.org/pipermail/etoys-dev/2010-October/005888.html

http://lists.squeakland.org/pipermail/etoys-dev/2010-October/005887.html
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Randomness + Pause/Delay?

Michael Rice-3
Thanks.

One forgets it's not a real-time simulation.

Michael

--- On Fri, 4/8/11, David Corking <[hidden email]> wrote:

From: David Corking <[hidden email]>
Subject: Re: [Newbies] Re: Randomness + Pause/Delay?
To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
Date: Friday, April 8, 2011, 2:01 PM

On Thu, Apr 7, 2011 michael rice  wrote:

>
> But the two scripts, blueAction and redAction, in sequence, appear to happen simultaneously.
> Is there a delay mechanism, like a marktime tile, that could separate two scripts by a specified
> number of ticks? If not, are there any plans for one?

I saw these two posts last year. They might help:

http://lists.squeakland.org/pipermail/etoys-dev/2010-October/005888.html

http://lists.squeakland.org/pipermail/etoys-dev/2010-October/005887.html
_______________________________________________
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 + Pause/Delay?

Steve Thomas
In reply to this post by Michael Rice-3
Sound interesting is the Etoys project posted anywhere?

On Thu, Apr 7, 2011 at 5:47 PM, michael rice <[hidden email]> wrote:
I ported my morphic app to Etoys and it does indeed work differently (randomly) now each time I bring it up.. The app simulates a simple game with two players taking turns putting their colored blocks (blue and red) upon one of two towers, randomly selected. The game ends when both towers are topped with the same color.

In a playfield, the playGame pseudocode script:

TEST towers topped with same color blocks
  YES initialize game to starting conditions
  NO blueAction
        redAction
 

But the two scripts, blueAction and redAction, in sequence, appear to happen simultaneously. Is there a delay mechanism, like a marktime tile, that could separate two scripts by a specified number of ticks? If not, are there any plans for one?

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 + Pause/Delay?

Bert Freudenberg
In reply to this post by Michael Rice-3
Well, often in Etoys you need a slight shift in perspective to make the solution fit a lot better. Approaches from other systems do not always map well.

E.g., a typical approach to implement PacMan would be to have PacMan object with a script to eat peas. In Etoys it's a lot easier for each pea to have a script checking if it was eaten.

So if you could let us know, in high-level terms, what the intended behavior is, we might be able to come up with ideas how to do that in Etoys.

- Bert -

On 08.04.2011, at 21:40, michael rice wrote:

Thanks.

One forgets it's not a real-time simulation.

Michael

--- On Fri, 4/8/11, David Corking <[hidden email]> wrote:

From: David Corking <[hidden email]>
Subject: Re: [Newbies] Re: Randomness + Pause/Delay?
To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
Date: Friday, April 8, 2011, 2:01 PM

On Thu, Apr 7, 2011 michael rice  wrote:

>
> But the two scripts, blueAction and redAction, in sequence, appear to happen simultaneously.
> Is there a delay mechanism, like a marktime tile, that could separate two scripts by a specified
> number of ticks? If not, are there any plans for one?

I saw these two posts last year. They might help:

http://lists.squeakland.org/pipermail/etoys-dev/2010-October/005888.html

http://lists.squeakland.org/pipermail/etoys-dev/2010-October/005887.html



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

Re: Randomness + Pause/Delay?

Michael Rice-3
In reply to this post by Michael Rice-3
Here's the Etoys app. Load and press Go button and it will continue game where two players take turns randomly selecting a tower on which to place a blue or red block, each game concluding when both towers are topped with block of the same color.

As you can see, redAction and blueAction appear to happen simultaneously. Ergo, the wish for a means to delay for a tick or two between the two actions.

Michael

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

From: Bert Freudenberg <[hidden email]>
Subject: Re: [Newbies] Re: Randomness + Pause/Delay?
To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
Date: Saturday, April 9, 2011, 6:33 AM

Well, often in Etoys you need a slight shift in perspective to make the solution fit a lot better. Approaches from other systems do not always map well.

E.g., a typical approach to implement PacMan would be to have PacMan object with a script to eat peas. In Etoys it's a lot easier for each pea to have a script checking if it was eaten.

So if you could let us know, in high-level terms, what the intended behavior is, we might be able to come up with ideas how to do that in Etoys.

- Bert -

On 08.04.2011, at 21:40, michael rice wrote:

Thanks.

One forgets it's not a real-time simulation.

Michael

--- On Fri, 4/8/11, David Corking <lists@...> wrote:

From: David Corking <lists@...>
Subject: Re: [Newbies] Re: Randomness + Pause/Delay?
To: "A friendly place to get answers to even the most basic questions about Squeak." <beginners@...>
Date: Friday, April 8, 2011, 2:01 PM

On Thu, Apr 7, 2011 michael rice  wrote:

>
> But the two scripts, blueAction and redAction, in sequence, appear to happen simultaneously.
> Is there a delay mechanism, like a marktime tile, that could separate two scripts by a specified
> number of ticks? If not, are there any plans for one?

I saw these two posts last year. They might help:

http://lists.squeakland.org/pipermail/etoys-dev/2010-October/005888.html

http://lists.squeakland.org/pipermail/etoys-dev/2010-October/005887.html



-----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

Etower1.001.pr (332K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Randomness + Pause/Delay?

Michael Rice-3
In reply to this post by Bert Freudenberg
Delay can be accomplished with "follow path."

1) Put an ellipse morph at 100@100
2) Give it a path from present location straight up to top of screen.
3) Create script named "delay" for ellipse
       Ellipse do menu item follow existing path
       Ellipse x <- 100
       Ellipse y <- 100
4) Put a rectangle morph at bottom center of screen
5) Create script for rectangle
       Ellipse delay
       Rectangle forward by 5

Click on ! to execute rectangle script. Ellipse follows path and returns to 100@100, delaying move of rectangle.

Michael

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

From: Bert Freudenberg <[hidden email]>
Subject: Re: [Newbies] Re: Randomness + Pause/Delay?
To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
Date: Saturday, April 9, 2011, 6:33 AM

Well, often in Etoys you need a slight shift in perspective to make the solution fit a lot better. Approaches from other systems do not always map well.

E.g., a typical approach to implement PacMan would be to have PacMan object with a script to eat peas. In Etoys it's a lot easier for each pea to have a script checking if it was eaten.

So if you could let us know, in high-level terms, what the intended behavior is, we might be able to come up with ideas how to do that in Etoys.

- Bert -

On 08.04.2011, at 21:40, michael rice wrote:

Thanks.

One forgets it's not a real-time simulation.

Michael

--- On Fri, 4/8/11, David Corking <lists@...> wrote:

From: David Corking <lists@...>
Subject: Re: [Newbies] Re: Randomness + Pause/Delay?
To: "A friendly place to get answers to even the most basic questions about Squeak." <beginners@...>
Date: Friday, April 8, 2011, 2:01 PM

On Thu, Apr 7, 2011 michael rice  wrote:

>
> But the two scripts, blueAction and redAction, in sequence, appear to happen simultaneously.
> Is there a delay mechanism, like a marktime tile, that could separate two scripts by a specified
> number of ticks? If not, are there any plans for one?

I saw these two posts last year. They might help:

http://lists.squeakland.org/pipermail/etoys-dev/2010-October/005888.html

http://lists.squeakland.org/pipermail/etoys-dev/2010-October/005887.html



-----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 + Pause/Delay?

Bert Freudenberg
That just freezes the world during the path following. Which I would consider a bug - in the Etoys image, path following happens simultaneously with all other animations.

Adding such a delay would be trivial, just have a textual script with something like "(Delay forSeconds: 1) wait". But that would not be a substitute for a real "wait" tile. It does not just stop the script it is in, but *every* script in the whole system.

- Bert -

On 10.04.2011, at 16:34, michael rice wrote:

Delay can be accomplished with "follow path."

1) Put an ellipse morph at 100@100
2) Give it a path from present location straight up to top of screen.
3) Create script named "delay" for ellipse
       Ellipse do menu item follow existing path
       Ellipse x <- 100
       Ellipse y <- 100
4) Put a rectangle morph at bottom center of screen
5) Create script for rectangle
       Ellipse delay
       Rectangle forward by 5

Click on ! to execute rectangle script. Ellipse follows path and returns to 100@100, delaying move of rectangle.

Michael

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

From: Bert Freudenberg <[hidden email]>
Subject: Re: [Newbies] Re: Randomness + Pause/Delay?
To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
Date: Saturday, April 9, 2011, 6:33 AM

Well, often in Etoys you need a slight shift in perspective to make the solution fit a lot better. Approaches from other systems do not always map well.

E.g., a typical approach to implement PacMan would be to have PacMan object with a script to eat peas. In Etoys it's a lot easier for each pea to have a script checking if it was eaten.

So if you could let us know, in high-level terms, what the intended behavior is, we might be able to come up with ideas how to do that in Etoys.

- Bert -

On 08.04.2011, at 21:40, michael rice wrote:

Thanks.

One forgets it's not a real-time simulation.

Michael

--- On Fri, 4/8/11, David Corking <<a rel="nofollow" ymailto="mailto:lists@dcorking.com" target="_blank" href="x-msg://2225/mc/compose?to=lists@dcorking.com">lists@...> wrote:

From: David Corking <<a rel="nofollow" ymailto="mailto:lists@dcorking.com" target="_blank" href="x-msg://2225/mc/compose?to=lists@dcorking.com">lists@...>
Subject: Re: [Newbies] Re: Randomness + Pause/Delay?
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://2225/mc/compose?to=beginners@lists.squeakfoundation.org">beginners@...>
Date: Friday, April 8, 2011, 2:01 PM

On Thu, Apr 7, 2011 michael rice  wrote:

>
> But the two scripts, blueAction and redAction, in sequence, appear to happen simultaneously.
> Is there a delay mechanism, like a marktime tile, that could separate two scripts by a specified
> number of ticks? If not, are there any plans for one?

I saw these two posts last year. They might help:

http://lists.squeakland.org/pipermail/etoys-dev/2010-October/005888.html

http://lists.squeakland.org/pipermail/etoys-dev/2010-October/005887.html



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

Re: Randomness + Pause/Delay?

Michael Rice-3
Yeah, I was surprised (shocked?) it didn't work in Etoys. Oh, well...

MIchael


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

From: Bert Freudenberg <[hidden email]>
Subject: Re: [Newbies] Re: Randomness + Pause/Delay?
To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
Date: Sunday, April 10, 2011, 1:49 PM

That just freezes the world during the path following. Which I would consider a bug - in the Etoys image, path following happens simultaneously with all other animations.

Adding such a delay would be trivial, just have a textual script with something like "(Delay forSeconds: 1) wait". But that would not be a substitute for a real "wait" tile. It does not just stop the script it is in, but *every* script in the whole system.

- Bert -

On 10.04.2011, at 16:34, michael rice wrote:

Delay can be accomplished with "follow path."

1) Put an ellipse morph at 100@100
2) Give it a path from present location straight up to top of screen.
3) Create script named "delay" for ellipse
       Ellipse do menu item follow existing path
       Ellipse x <- 100
       Ellipse y <- 100
4) Put a rectangle morph at bottom center of screen
5) Create script for rectangle
       Ellipse delay
       Rectangle forward by 5

Click on ! to execute rectangle script. Ellipse follows path and returns to 100@100, delaying move of rectangle.

Michael

--- On Sat, 4/9/11, Bert Freudenberg <bert@...> wrote:

From: Bert Freudenberg <bert@...>
Subject: Re: [Newbies] Re: Randomness + Pause/Delay?
To: "A friendly place to get answers to even the most basic questions about Squeak." <beginners@...>
Date: Saturday, April 9, 2011, 6:33 AM

Well, often in Etoys you need a slight shift in perspective to make the solution fit a lot better. Approaches from other systems do not always map well.

E.g., a typical approach to implement PacMan would be to have PacMan object with a script to eat peas. In Etoys it's a lot easier for each pea to have a script checking if it was eaten.

So if you could let us know, in high-level terms, what the intended behavior is, we might be able to come up with ideas how to do that in Etoys.

- Bert -

On 08.04.2011, at 21:40, michael rice wrote:

Thanks.

One forgets it's not a real-time simulation.

Michael

--- On Fri, 4/8/11, David Corking <[hidden email]> wrote:

From: David Corking <[hidden email]>
Subject: Re: [Newbies] Re: Randomness + Pause/Delay?
To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
Date: Friday, April 8, 2011, 2:01 PM

On Thu, Apr 7, 2011 michael rice  wrote:

>
> But the two scripts, blueAction and redAction, in sequence, appear to happen simultaneously.
> Is there a delay mechanism, like a marktime tile, that could separate two scripts by a specified
> number of ticks? If not, are there any plans for one?

I saw these two posts last year. They might help:

http://lists.squeakland.org/pipermail/etoys-dev/2010-October/005888.html

http://lists.squeakland.org/pipermail/etoys-dev/2010-October/005887.html



-----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 + Pause/Delay?

Bert Freudenberg
In reply to this post by Michael Rice-3
On 09.04.2011, at 13:28, michael rice wrote:

Here's the Etoys app. Load and press Go button and it will continue game where two players take turns randomly selecting a tower on which to place a blue or red block, each game concluding when both towers are topped with block of the same color.

As you can see, redAction and blueAction appear to happen simultaneously. Ergo, the wish for a means to delay for a tick or two between the two actions.

Michael

The Etoys way would be to do the red and blue actions in alternating ticks. E.g.



However, the *real* Etoys way would be to let the Etoys objects do their work. Your approach is very procedural. It uses many variables and functions instead of objects. It even does the layout in code, calculating x,y coordinates etc.

I am attaching a project that does pretty much the same as yours, but does not need a single variable, and has only 3 simple scripts with about 3 lines each.

- Bert -



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

PastedGraphic-10.png (14K) Download Attachment
RedVsBlue.003.pr (74K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Randomness + Pause/Delay?

Michael Rice-3
Nice and clean compared to my "procedural" code (and variables). Would make it much simpler to add a third tower (same endgame conditions), while my code would require a complete rewrite.

I wasn't aware that the Etoys playfield has a timer. Perfect for taking turns.

Thanks.

Michael


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

From: Bert Freudenberg <[hidden email]>
Subject: Re: [Newbies] Re: Randomness + Pause/Delay?
To: "michael rice" <[hidden email]>
Cc: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
Date: Monday, April 11, 2011, 6:40 AM

On 09.04.2011, at 13:28, michael rice wrote:

Here's the Etoys app. Load and press Go button and it will continue game where two players take turns randomly selecting a tower on which to place a blue or red block, each game concluding when both towers are topped with block of the same color.

As you can see, redAction and blueAction appear to happen simultaneously. Ergo, the wish for a means to delay for a tick or two between the two actions.

Michael

The Etoys way would be to do the red and blue actions in alternating ticks. E.g.


However, the *real* Etoys way would be to let the Etoys objects do their work. Your approach is very procedural. It uses many variables and functions instead of objects. It even does the layout in code, calculating x,y coordinates etc.

I am attaching a project that does pretty much the same as yours, but does not need a single variable, and has only 3 simple scripts with about 3 lines each.

- Bert -


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

Re: Randomness + Pause/Delay?

Bert Freudenberg
In reply to this post by Michael Rice-3
"action" is a script of the red and blue rectangles. You find it in the viewer's "scripts" category for e.g. the red rectangle.

"player at cursor" is a tile of the "AllPlayers" holder. You find it in the viewer's "collections" category. (or type in the search box).

Constructing a complex tile in Etoys goes from the concrete to the more abstract. You start giving specific instructions and then generalize.

So at first, you place that "Red | action" tile in your script. Then you can test if that is working.

Later, you replace the "Red" receiver tile with the "AllPlayers | player at cursor". You drag it from the viewer onto the "receiver pad" of the "Red | action" tile.

Now, instead of always performing the "Red" object's "action", it runs the "action" script of whatever object is the current one inside of the "AllPlayers" holder.

You have to make sure yourself that the objects in "AllPlayers" actually have a script named "action", otherwise an error will occur. The type system of Etoys only prevents that e.g. you drop a color where a number is expected.

This "outside-in" construction of complex tiles works naturally when you "invent" the script yourself step-by-step by experimenting. When you only see the result, it can be perplexing how to construct it. The sequence is executed from left to right, but made from right to the left. That's why for arithmetic expressions there is the little "extend" arrow to the right (but you still need to build nested expressions outside-in).

- Bert -

On 15.04.2011, at 03:32, michael rice wrote:

I give up. Where (how) do you get the

AllPlayer's | player at cursor | action tile

shown at the bottom of the attachment?

Michael






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

Re: Randomness + Pause/Delay?

dcorking
On Fri, Apr 15, 2011 at 10:37 AM, Bert Freudenberg <[hidden email]> w=
rote:
...
> Constructing a complex tile in Etoys goes from the concrete to the more a=
bstract. You start giving specific instructions and then generalize.
> So at first,=A0you place that "Red | action" tile in your script. Then yo=
u can test if that is working.
> Later, you replace the "Red" receiver tile with the "AllPlayers |=A0playe=
r at cursor". You drag it from the viewer onto the "receiver pad" of the=A0=
"Red | action" tile.
...
> This "outside-in" construction of complex tiles works naturally when you =
"invent" the script=A0yourself step-by-step by experimenting. When you only=
 see the result, it can be perplexing how to construct it. The sequence is =
executed from left to right, but made from right to the left. That's why fo=
r arithmetic expressions there is the little "extend" arrow to the right (b=
ut you still need to build nested expressions outside-in).

This outside-in method, as well as the ability to send a message to
all players in a collection, are important tools for advanced tile
scripts. Do we have a
tutorial covering this in the Squeakland documentation? If not, I
suggest we use Bert's scripts and explanation as the basis for the
first draft.

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