Home
Project Folders
Teacher Resources
Student Resources
How Do I?
Literacy
MWForum
Site Map
Search
Our Team

MWForum Message [Date Index] [Threads] [Authors] [Attachments] [Subscribe]

[Thread Prev] [Thread Next]

To: mwforum@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Subject: Re: MIA, Ask an Expert: dice counts
From: Seymour Papert <papert@xxxxxxxxxxxxx>
Date: Thu, 18 May 2006 15:12:35 -0400

I am resending the following because it might seem mysterious to =anyone who has not followed the previous interchanges
about the problem.


What I wrote is addressed to someone I think called Damian who posed a problem that you will find at the bottom of this message.
-----------------


More comments on the dice roll problem that might give you something to think about:

Taken literally Susan's solution is a correct solution to a different problem than the one I thought you were posing. I thought you wanted the procedure to tell you how many rolls actually happened up to the time a complete set was achieved.

But the great thing about programming is that this does not make her solution "wrong." Even if it does not quite do what (I think) you wanted, it still has a good idea in it, which you can adapt to solve the problem that you wanted to solve.

But you have to add another idea as well: in some way you must count the number of rolls that have been done up to the time the thing stops.

I won't deprive you of the fun of doing this yourself.

Seymour

P.S.
You might find it interesting to accompany me through the following thought steps that came after I wrote the above:


First thought: I can't remember whether STOPALL exists in LogoWriter or whether it came in with MicroWorlds. If not Damian would get into a bit of trouble. So0 I wondered how he could get out of it.
Second thought: Always ask: what would be the simplest way out of the trouble?
Third step: What would happen if he just removed STOPALL from Susan's suggested procedure?
Fourth: Interesting guess---- even if STOPALL does exist in LogoWriter, the procedure it would print the same with or without the STOPALL .instruction.. but what would be happening inside the computer would be different !
(I don't have LogoWriter near where I am and so I haven't tried this /// I'm just guessing ..or thinking .. or whatever you call it.
I hope someone tries this and discusses what happened)


Worth pondering.

P.P.S. Since I have gone on about this longer than I meant to I think I should take the trouble to make quite clear how i interpreted Damian and Susan:

I read Susan as suggesting that Damian's diceroll procedure be changed to

to diceroll :n
prep
repeat :n [dice if (and :one > 0 :two > 0 :three > 0 :four > 0 :five > 0
:six > 0) [pr (se [After ] :n [ rolls I have a complete set] )] ]
end

to dice
make "roll random 6
if :roll = 0 [make "one :one + 1]
if :roll = 1 [make "two :two + 1]
if :roll = 2 [make "three :three + 1]
if :roll = 3 [make "four :four + 1]
if :roll = 4 [make "five :five + 1]
if :roll = 5 [make "six :six + 1]
end

to prep
make "one 0
make "two 0
make "three 0
make "four 0
make "five 0
make "six 0
end

Try it with a few inputs like diceroll 100, diceroll 50, diceroll 3 in two forms -- one as it stands, the other after removing the stopall.

Susan Einhorn wrote:

This following solution works for LogoWirter and MicroWorlds.

You could use the primitive "and". And reports true if ALL its inputs are
true (compare this to "or" which reports true if ANY of its inputs are
true). Here's one idea:


Add the instruction:

If (and :one > 0 :two > 0 :three > 0 :four > 0 :five > 0 :six > 0) [pr (se
[After ] :n [ rolls I have a complete set] ) stopall]


Add this inside the brackets of your repeat instruction.

repeat :n [dice if (and :one > 0 :two > 0 :three > 0 :four > 0 :five > 0
:six > 0) [pr (se [After ] :n [ rolls I have a complete set] ) stopall] ]


That's somewhat difficult to read, so you could make it a subprocedure:

To decide
If (and :one > 0 :two > 0 :three > 0 :four > 0 :five > 0 :six > 0)
[pr (se [After ] :n [ rolls I have a complete set] ) stopall]
end

Then your repeat line will be more readable:

repeat :n [dice decide]

Note, this stops all the procedures. You didn't say if this is what you
wanted to do, but, if not, there are ways to keep the dice rolling.


Susan


-----Original Message-----
From: mwforum-admin@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
[mailto:mwforum-admin@xxxxxxxxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Ask an
Expert - Question
Sent: Thursday, May 18, 2006 10:27 AM
To: mwforum@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Subject: [MWForum] MIA, Ask an Expert: dice counts


This is an automatic message sent from the web form at:
http://mia.openworldlearning.org/mwforum.htm

from: Damian <dnicetin@xxxxxxxxxxxx>
date: Thu May 18 01:03:37 2006

Hello

I have a question.. I have written the following program to simulate the
results from a dice roll and it works fine..


to dice
make "roll random 6
if :roll = 0 [make "one :one + 1]
if :roll = 1 [make "two :two + 1]
if :roll = 2 [make "three :three + 1]
if :roll = 3 [make "four :four + 1]
if :roll = 4 [make "five :five + 1]
if :roll = 5 [make "six :six + 1]
end

to diceroll :n
make "one 0 make "two 0 make "three 0 make "four 0 make "five 0 make "six 0
repeat :n [dice]
print "one print :one
print "two print :two
print "three print :three
print "four print :four
print "five print :five
print "six print :six
end


My problem is, that I want to change this procedure so that it counts the
number of rolls that it takes before I get the values 1, 2, 3, 4, 5 and 6
(i.e a complete set of numbers, but not necessarily in numerical order)


HELP!!!, Im stuck. are there any Logowriter Guru's out there that can help?





*****************************
OpenWorld Learning
http://www.openworldlearning.org





  • Previous by thread: RE: MIA, Ask an Expert: dice counts
  • Next by thread: Re: MIA, Ask an Expert: dice counts

  • To save an attachment to your computer, PC users should right-click (Mac users, click and hold the mouse button) on the link and then choose 'save target as' from the pop-up menu. A window will then pop up in which you can choose a location for the file.


    © copyright 2001 - 2008