[MWForum]Coin flipping project
Daniel Ajoy
mwforum@lists.mathcats.com
Wed, 06 Apr 2005 16:56:43 -0500
You were almost there. I just removed the brackets:
setheadscount [headscount + 1]
and left it like:
setheadscount headscount + 1
the following code should work:
to flip
ifelse coin = "heads [recordheads][recordtails]
settotalflips totalflips + 1
end
to coin
if 1 = random 2 [output "heads]
output "tails
end
to recordheads
money, setsh "heads
setheadscount headscount + 1
end
to recordtails
money, setsh "tails
settailscount tailscount + 1
end
to startup
headscount, cleartext insert 0
tailscount, cleartext insert 0
totalflips, cleartext insert 0
end
Daniel
OpenWorld Learning
http://mia.openworldlearning.org
On 7 Apr 2005 at 7:44, GrahamWilliams@caulfieldgs.vic.edu.au wrote:
> Could someone please help me sort out the problems with the attached
> project.? My students are investigating probability through both
> 'concrete' activities [ i.e. They're flipping real coins squillions of
> times ] and virtual experiments =- the idea being to compare the two
> outcomes. I'm trying to write procedures which will cause the
> turtle/coin [ called < money > in the project ] to flip constantly ,
> until the procedure is stopped . I want to record a total count of the
> 'heads' [ < headscount > ] , a total record of the 'tails' [ <
> tailscount >] and a total of all the flips [ < totalflips > ] . I've
> made 3-textboxes and labelled them headscount tailscount
> totalflips and I'm trying to direct data about the results of the
> flips into the 3 separate text-boxes but at the moment all I'm doing is
> directing the words < headscount + 1 > < tailscount + 1 > and
> <totalflips + 1 > into the textboxes . The annoying thing is that at
> one stage during the time I've spent on this project I did actually
> manage to direct data [ numbers of heads and numbers of tails ] into 2
> of the text-boxes . I'm sure this was more serendipitous than good
> management because as I tried to tweak the procedure to get numbers for
> the totalflips I lost the plot and ended-up with the problem I now face.
> Also, I'd like to slow things down so that as the cumulative totals are
> recorded in each of the 3 text-boxes, the numbers are able to be read .
> I'd greatly appreciate any help because I'm very much a beginner '
> programmer' . I'm working in Microworlds PRO on Windows XP. . Graham
> Williams <<COIN FLIPS.mw2>>
>