10-13-2022, 04:24 AM
Quote:You beat me (again)!
I'm in the middle (or at least I've started) writing a game based on a similar algorithm.
I use this for shuffling:
for a=1 to 52
swop=int (rnd*52)+1
swap deck$(a),deck$(swop)
next
When I look at something like this, my urge is to prevent "a" and "swop" from having the same value, if they're both integers. Such as:
Code: (Select All)
for a=1 to 52
do
swop=int (rnd*52)+1
loop while swop=a
swap deck$(a),deck$(swop)
next
Otherwise could leave out the "do" and straight out test the two integers and, if not equal, actually do the swap.