
-----------------------------------
compudave
Wed Nov 12, 2003 8:04 pm

Chances of stopping
-----------------------------------
Can anyone help me out by explaining how to incorporate a chance of stopping a count loop. For exanple how to get a counted loop to have a 50% of stopping before it reaches 10.

-----------------------------------
Chimaera
Wed Nov 12, 2003 8:10 pm


-----------------------------------
well all you really have to do is make an exit when statement with a randint



for i: 1..10
var num : int
randint (num,1,2)
exit when num = 2
count := count+1
if count = 10
then put "Hurray, you hit 10"
end if
end for
if num = 2
then put "Aw shucks, you beat me to the punch. ;_;"
end if


Well that's basically the code you need, but why would you WANT to stop your forloop before it hits 10?

-----------------------------------
Karam
Wed Nov 12, 2003 8:59 pm


-----------------------------------
hehe dave got it before u lol  :lol: 


var num : real
randomize
for count : 1 .. 10
    rand (num)
    exit when num 