Ranking Poker Hands
#16
(10-13-2022, 04:24 AM)mnrvovrfc Wrote:
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.
But does it matter if they are the same value? Obviously, there would not be a swap, but other swaps wouldn't be affected, and if there were only a small number of elements, the whole swap sequence could be looped a few times to ensure thorough mixing.
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.) Big Grin
Reply


Messages In This Thread
Ranking Poker Hands - by bplus - 10-11-2022, 05:52 AM
RE: Ranking Poker Hands - by PhilOfPerth - 10-11-2022, 07:00 AM
RE: Ranking Poker Hands - by bplus - 10-11-2022, 01:15 PM
RE: Ranking Poker Hands - by PhilOfPerth - 10-13-2022, 02:20 AM
RE: Ranking Poker Hands - by Pete - 10-11-2022, 08:54 AM
RE: Ranking Poker Hands - by bplus - 10-11-2022, 01:21 PM
RE: Ranking Poker Hands - by TerryRitchie - 10-11-2022, 02:11 PM
RE: Ranking Poker Hands - by Pete - 10-12-2022, 09:03 AM
RE: Ranking Poker Hands - by TerryRitchie - 10-12-2022, 01:44 PM
RE: Ranking Poker Hands - by Pete - 10-13-2022, 02:33 AM
RE: Ranking Poker Hands - by bplus - 10-11-2022, 02:20 PM
RE: Ranking Poker Hands - by bplus - 10-12-2022, 03:05 PM
RE: Ranking Poker Hands - by Pete - 10-12-2022, 03:52 PM
RE: Ranking Poker Hands - by TerryRitchie - 10-13-2022, 02:35 AM
RE: Ranking Poker Hands - by Pete - 10-13-2022, 05:45 AM
RE: Ranking Poker Hands - by mnrvovrfc - 10-13-2022, 04:24 AM
RE: Ranking Poker Hands - by PhilOfPerth - 10-13-2022, 04:42 AM
RE: Ranking Poker Hands - by bplus - 10-13-2022, 12:31 PM
RE: Ranking Poker Hands - by bplus - 10-13-2022, 01:37 PM
RE: Ranking Poker Hands - by Pete - 10-13-2022, 03:47 PM
RE: Ranking Poker Hands - by TempodiBasic - 10-15-2022, 07:44 PM
RE: Ranking Poker Hands - by TempodiBasic - 10-15-2022, 07:49 PM



Users browsing this thread: 21 Guest(s)