Random(3) often returns 1
Mark Schonewille
m.schonewille at economy-x-talk.com
Thu Jun 8 09:25:52 EDT 2006
Hello,
I think Sarah is right, lines may end up with equal random numbers.
However, my test results show another weird phenomenon.
on mouseUp
put "0,0,0" into myCounter
repeat 10
repeat 1000
add 1 to item random(3) of myCounter
end repeat
put myCounter && sum(myCounter) & return after myList
put "0,0,0" into myCounter
end repeat
put myList
end mouseUp
test results:
330,328,329 987
316,315,317 948
325,326,326 977
337,337,339 1013
349,350,349 1048
327,327,325 979
348,348,347 1043
355,356,355 1066
330,330,329 989
335,335,334 1004
There is a bug somewhere, which causes these weird results. The
following works fine:
on mouseUp
put "0,0,0" into myCounter
repeat 10
repeat 1000
put random(3) into x
add 1 to item x of myCounter
end repeat
put myCounter && sum(myCounter) & return after myList
put "0,0,0" into myCounter
end repeat
put myList
end mouseUp
with these test results:
312,344,344 1000
338,344,318 1000
313,343,344 1000
320,344,336 1000
291,338,371 1000
339,303,358 1000
337,324,339 1000
328,338,334 1000
322,331,347 1000
305,354,341 1000
I don't know whether this might affect the sort function or any other
application of random numbers, besides using them in repeat loops.
Best,
Mark
--
Economy-x-Talk
Consultancy and Software Engineering
http://economy-x-talk.com
http://www.salery.biz
Download ErrorLib at http://economy-x-talk.com/developers.html and
get full control of error handling in Revolution.
Op 8-jun-2006, om 14:16 heeft Thomas McCarthy het volgende geschreven:
>
> Has anyone noticed this?
> I have two games that sort a container (three lines, one line is
> the answer) by random the number of lines. The "answer" should be
> in any one of the three resulting lines, but is overwhelmingly in
> the first
>
> any thoughts?
> tm
More information about the use-livecode
mailing list