---------------

FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC   Ref: EDM00000 Date: 09/14/97
From: DAVID WILLIAMS                                        Time: 10:50am
\/To: ROBERT FORTUNE                                      (Read 1 times)
Subj: Scramble

-> Nonsense. Your version is no better than mine or the other one that
-> was posted weeks ago. And I will not be drawn into that useless
-> debate
-> on how random computer randomness is. If that is your intention,
-> don't
-> bother.
Oooh! Snarky!
No. It has nothing to do with the randomness or otherwise of RND. Your
routine messes up its own randomness by permitting the characters that
have already been randomized to be targets of further swaps.
It's a bit difficult to explain, but easy to demonstrate. Start with a
simple string such as "abc". There are six possible orders into which
the characters can be shuffled, which should occur with equal
frequencies over a long term. So, for example, write a little program
that will do, say, 600 trials, starting with "abc" each time, and will
count the numbers of times the six possible outcomes occur. Of course,
they should each happen 100 times, give or take just a few for random
fluctuations. But, with your routine, they will occur widely different
numbers of times. My routine, on the other hand, will produce each of
the outcomes just about 100 times.
Try it!
                             dow
--- PCBoard (R) v15.3 (OS/2) 5
 * Origin: FidoNet: CAP/CANADA Support BBS : 416 287-0234 (1:250/710)
---------------

FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC   Ref: EDM00001 Date: 09/14/97
From: DAVID WILLIAMS                                        Time: 10:57am
\/To: ROBERT FORTUNE                                      (Read 1 times)
Subj: Scramble

-> Here we have potentially useless code if and when the random number
-> generated is the same as the variable X% in which case the letter is
-> being swapped with itself which makes no logical sense at all. If
-> you're swapping a letter with itself, why bother using a swap routine
-> at all?
This is true, but not very interesting. Yes, an IF could be used to
check that the two characters are different before they are swapped.
However, no harm is done by swapping them anyway. In fact, omitting the
IF may make the code run faster, depending on such things as the length
of the string. Evaluating an IF takes time, comparable to that taken by
executing a swap.
-> There isn't a single comment in your code to explain what your code
-> is
-> supposed to be doing. Programs or code with no comments is worthless.
True. But surely any programmer could figure out such simple code
without having to have his hand held.
The code *works*, which makes it far from "worthless".
-> Your code is no better than mine or the other person's who also
-> posted a prompt reply (your reply is more than a month later and
-> isn't
-> any better).
->   You may shuffle cards like that in your mind, but it is physically
-> impossible to shuffle a card with itself when shuffling a deck of
-> cards. That might even be illegal in a real-world video card game
-> where real money is at stake.
I don't follow this conference much. I'm beginning to realize why...
My code *is* better, because it does the randomization properly. The
other routines don't. If you don't believe me, try it and see, with a
routine such as I just suggested in a previous message.
                                dow
--- PCBoard (R) v15.3 (OS/2) 5
 * Origin: FidoNet: CAP/CANADA Support BBS : 416 287-0234 (1:250/710)
---------------

FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC   Ref: EDM00002 Date: 09/15/97
From: RONALD SCHLEGEL                                       Time: 04:58pm
\/To: ROBERT FORTUNE                                      (Read 1 times)
Subj: Scramble

Robert,
 
RF> DW>Nope. This does, indeed, scramble the word, but *not* into a
RF> Nonsense. Your version is no better than mine or the other one that
RF> DW>I just posted a message with a "proper" way to do it.
RF> And see my *proper* reply to that.
 
Guys, guys...<g>. Please...I started this thread. I also tried both 
versions. In my particular application, both gave me the same desired 
results & no difference in speed. So, you both are correct...:) I just 
appreciate the help I got...didn't mean to start an argument.
 
-Ron
 
 * RM 1.31 3129 * JOEL ROBINSON IS DEAD! -- Tom Servo
--- TriToss (tm) Professional 11.0 - #229
 * Origin: * Dynasty BBS * The Home of Crazy Nights Software * (1:110/1065.0)
---------------

FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC   Ref: EDM00003 Date: 09/15/97
From: ROBERT FORTUNE                                        Time: 07:21pm
\/To: DAVID WILLIAMS                                      (Read 1 times)
Subj: Scramble

RF> Nonsense. Your version is no better than mine or the other one that
RF> was posted weeks ago. And I will not be drawn into that useless
RF> debate on how random computer randomness is. If that is your intention,
RF> don't bother.
DW>Oooh! Snarky!
DW>No. It has nothing to do with the randomness or otherwise of RND. Your
DW>routine messes up its own randomness by permitting the characters that
DW>have already been randomized to be targets of further swaps.
   As can happen when shuffling a deck of cards. Oftentimes when
   shuffling a deck of cards some of the same cards are shuffled more
   than once. Absolutely nothing wrong there. It seems to me that you
   *think* you can control the degree of randomness used. You're wrong.
     The real test is to use the code in complete programs. I have done
   that and from a lot of experience I can say that no one can predict
   what card will come up next in my programs (which use a similar shuffle
   routine to the one I posted).
DW>It's a bit difficult to explain, but easy to demonstrate. Start with a
DW>simple string such as "abc". There are six possible orders into which
DW>the characters can be shuffled, which should occur with equal
DW>frequencies over a long term. So, for example, write a little program
   *You think* you can control the degree of randomness. You cannot.
    Prove me wrong if you disagree.
DW>that will do, say, 600 trials, starting with "abc" each time, and will
DW>count the numbers of times the six possible outcomes occur. Of course,
DW>they should each happen 100 times, give or take just a few for random
DW>fluctuations. But, with your routine, they will occur widely different
DW>numbers of times. My routine, on the other hand, will produce each of
DW>the outcomes just about 100 times.
DW>Try it!
    What you said above proves my point. A routine that does not
   statistically average out over time so that every outcome appears
   an equal number of times is better than a predictable routine where
   each outcome comes out an equal number of times over time. Think
   about that.
 * OLX 2.1 TD * Say the best, think the rest!
--- PCBoard (R) v15.3/M 10
 * Origin: MoonDog BBS  RIME NetHub Brooklyn,NY (1:278/15)
---------------

FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC   Ref: EDM00004 Date: 09/17/97
From: DAVID WILLIAMS                                        Time: 10:18am
\/To: ROBERT FORTUNE                                      (Read 1 times)
Subj: Scramble

->   What you said above proves my point. A routine that does not
-> statistically average out over time so that every outcome appears
-> an equal number of times is better than a predictable routine where
-> each outcome comes out an equal number of times over time. Think
-> about that.
Well, this is a strange point! The conventional definition of "random"
includes the concept that non-degenerate outcomes should be equally
probable, which means that they should come up equally frequently over a
long term. (The business about "non-degenerate" has to do with
indistinguishable outcomes that can be reached in several ways. It's not
an important factor in our discussion.) You are suggesting that it is
somehow better for this equi-probability *not* to occur. Hmmm.... I
guess you wouldn't take this so far as to say that the best "randomizer"
is one that always produces the exact same order every time, for example
the same order as the one in which the characters (or other things) were
originally in! Such a routine would have the advantage of being
extremely easy to write!
There are plenty of realistic applications in which any (known)
deviation from equi-probability could have serious consequences. For
example, the pay-outs in various gambling games are calculated so the
house makes a long term profit, which makes casinos profitable. If
equi-probability were not to occur in whatever "randomizing" mechanism
is involved, and if the players were to know which outcomes were most
probable, they could make a consistent profit, and drive the house into
bankruptcy.
There are some legal consequence, too. For example, cars are supposed to
be picked at random for certain kinds of spot-checks by police - for the
drivers' alcohol levels, etc.. If it could be shown that the randomizer
picks some cars more often than others, there would be legal cause to
nullify huge numbers of convictions. This could be chaotic!
Anyway, if you are agreeing that your character shuffling routine *does*
produce some outcomes more often than others, defying the conventional
idea of randomness, and that mine does not, then I think we are in
sufficient agreement for us to stop cluttering this conference with this
discussion. Feel free to send me private netmail, if you want, at
1:250/710.
                             dow
--- PCBoard (R) v15.3 (OS/2) 5
 * Origin: FidoNet: CAP/CANADA Support BBS : 416 287-0234 (1:250/710)
---------------

FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC   Ref: EDM00005 Date: 09/17/97
From: DAVID WILLIAMS                                        Time: 10:20am
\/To: RONALD SCHLEGEL                                     (Read 1 times)
Subj: Scramble

-> Guys, guys...<g>. Please...I started this thread. I also tried both
-> versions. In my particular application, both gave me the same desired
-> results & no difference in speed. So, you both are correct...:) I
-> just appreciate the help I got...didn't mean to start an argument.
Don't worry! We're not going to come to blows. Actually, I supect we're
both rather enjoying it.
Anyway, the discussion is pretty much over now, I think.
                           dow
--- PCBoard (R) v15.3 (OS/2) 5
 * Origin: FidoNet: CAP/CANADA Support BBS : 416 287-0234 (1:250/710)
---------------

FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC   Ref: EDM00006 Date: 09/11/97
From: FRANK COX                                             Time: 01:05am
\/To: ROWAN_CROWE                                         (Read 1 times)
Subj: Odd-Ball code...:)

 FC>> INCR TWIRLEY   ' would be slightly faster
 > If Powerbasic is reasonably "smart", both lines would 
 > probably generate identical machine code (assuming it's an 
 > integer).
I just tried it.  The .EXE file 18,256 bytes long in both cases, as follows:
x%=1
incr x%
and
x%=1
x%=x%+1
DOS FC.EXE shows about a dozen differences in the .EXE, though, for whatever 
reason.
--- Msgedsq 2.2e
 * Origin: THE BIG ELECTRIC CAT  Melville Sask   *SDS*  *PDN* (1:140/53)
---------------

FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC   Ref: EDM00007 Date: 09/12/97
From: ROBERT FORTUNE                                        Time: 06:39pm
\/To: DAVID WILLIAMS                                      (Read 1 times)
Subj: Scramble

RF> SUB Scramble (Word$)
RF> LOS% = LEN(Word$)       ' the Length Of String passed
RF> IF LOS% < 3 THEN        ' added 9/12/1997
RF>    PRINT "String\word too short!"
RF>    EXIT SUB
RF> END IF
RF> FOR I% = 1 TO LOS%
RF>   DO
RF>    SP% = INT(RND * LOS%) + 1   ' swap pointer (into the Word$ string)
RF>   LOOP UNTIL SP% <> I%         ' no sense swapping character with self
RF>   Temp$ = MID$(Word$, I%, 1)   ' store this character temporarily
RF>   MID$(Word$, I%, 1) = MID$(Word$, SP%, 1)  ' and do the swap
RF>   MID$(Word$, SP%, 1) = Temp$  ' reassign char from stored temp char
RF> NEXT I%
RF> END SUB
DW>Nope. This does, indeed, scramble the word, but *not* into a strictly
DW>random order. If you do it a large number of times, you will find that
DW>some output orders come up more often than others.
   Nonsense. Your version is no better than mine or the other one that
   was posted weeks ago. And I will not be drawn into that useless debate
   on how random computer randomness is. If that is your intention, don't
   bother.
DW>I just posted a message with a "proper" way to do it.
   And see my *proper* reply to that.
-Robert Fortune
 * OLX 2.1 TD * Jesus loves you.  Everyone else thinks you're an idiot.
--- PCBoard (R) v15.3/M 10
 * Origin: MoonDog BBS  RIME NetHub Brooklyn,NY (1:278/15)
---------------

FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC   Ref: EDM00008 Date: 09/13/97
From: RONALD SCHLEGEL                                       Time: 04:38pm
\/To: FRANK COX                                           (Read 1 times)
Subj: Odd-Ball code...:)

FC> I just tried it.  The .EXE file 18,256 bytes long in both cases, as
FC> follows:
FC> DOS FC.EXE shows about a dozen differences in the .EXE, though, for
FC> whatever
 
Think maybe it's like a "roadmap"? You can take several different routes 
& still arrive at the same place at the same time...:)
 
-Ron
 
 * RM 1.31 3129 * Jurassic Park ** 12 species in Amber.
--- TriToss (tm) Professional 11.0 - #229
 * Origin: * Dynasty BBS * The Home of Crazy Nights Software * (1:110/1065.0)
---------------

FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC   Ref: EDN00000 Date: 09/18/97
From: ROBERT FORTUNE                                        Time: 02:41pm
\/To: DAVID WILLIAMS                                      (Read 1 times)
Subj: Scramble

RF>   What you said above proves my point. A routine that does not
RF> statistically average out over time so that every outcome appears
RF> an equal number of times is better than a predictable routine where
RF> each outcome comes out an equal number of times over time. Think
RF> about that.
DW>Well, this is a strange point! The conventional definition of "random"
DW>includes the concept that non-degenerate outcomes should be equally
DW>probable, which means that they should come up equally frequently over a
DW>long term. (The business about "non-degenerate" has to do with
    Keep in mind that the study of statistics was created to try to
   understand and find order where there supposedly isn't any order.
   It isn't an exact science and should not be used or thought of as such.
   By imposing this definition that all possible outcomes should come
   out an equal number of times, and since you said that is what you found
   with your routine, you should be concerned not overjoyed. Remember,
   we want the most random routine, not the routine that produces a
   pattern of outcomes more quickly over time.
    What your argument seems to be is that if your routine, for the
   most part, produces orderly "textbook" outcomes over time, it is better.
    I'm saying that if my routine does not or takes longer before any
   pattern is seen it may just mean that my routine is better in that
   no pattern is seen over time or my routine produces random outcomes
   for a longer period of time before any pattern is seen. Not that I
   believe that. I suspect that both routines over time are very likely
   equal in their ability to produce random outcomes.
DW>indistinguishable outcomes that can be reached in several ways. It's not
DW>an important factor in our discussion.) You are suggesting that it is
DW>somehow better for this equi-probability *not* to occur. Hmmm.... I
    You should make certain that you run both routines more than
   600 times and see if that changes the results. Maybe one routine
   produces more random outcomes before a pattern begins to develop.
   Also keep in mind that BASIC's randomness is not the best possible.
    As far as this thread goes you would have to post the complete code
   that you are using to test the routines so that I can run them here
   and you should also post your findings. I've learned that anyone can
   claim anything and so I need to be able to duplicate your findings
   before I ever agree with you that your routine is more random.
DW>guess you wouldn't take this so far as to say that the best "randomizer"
DW>is one that always produces the exact same order every time, for example
DW>the same order as the one in which the characters (or other things) were
DW>originally in! Such a routine would have the advantage of being
DW>extremely easy to write!
   No. Random means that any arrangement of outcomes is possible.
DW>There are plenty of realistic applications in which any (known)
DW>deviation from equi-probability could have serious consequences. For
DW>example, the pay-outs in various gambling games are calculated so the
DW>house makes a long term profit, which makes casinos profitable. If
DW>equi-probability were not to occur in whatever "randomizing" mechanism
DW>is involved, and if the players were to know which outcomes were most
DW>probable, they could make a consistent profit, and drive the house into
DW>bankruptcy.
   Having written several complete card game BBS doors (at least one
   which was published with a book on BBSs) I know a little about
   programming card games using QB\PDS.
    In the case of Video Poker, the card deck is shuffled between each
   round of poker so each new deal is dealt from a fresh deck of cards.
   "After the draw, win or lose, the machine deals the next hand from
   a full deck." - Video Poker Mania! by Dwight & Louise Crevelt.
   In my Blackjack game I opted to deal thru one complete deck. I did
   that so that no one could use the game with real money since card
   counters can defeat the house by counting cards. I wanted the game
   to be only entertainment.
DW>There are some legal consequence, too. For example, cars are supposed to
DW>be picked at random for certain kinds of spot-checks by police - for the
DW>drivers' alcohol levels, etc.. If it could be shown that the randomizer
DW>picks some cars more often than others, there would be legal cause to
DW>nullify huge numbers of convictions. This could be chaotic!
   I doubt that happens in the real world. Police, like everyone else,
   will use their experience when doing their job.
DW>Anyway, if you are agreeing that your character shuffling routine *does*
DW>produce some outcomes more often than others, defying the conventional
DW>idea of randomness, and that mine does not, then I think we are in
DW>sufficient agreement for us to stop cluttering this conference with this
DW>discussion. Feel free to send me private netmail, if you want, at
DW>1:250/710.
DW>                             dow
   As I see it you are claiming victory by saying that your random routine
   follows "the conventional idea of randomness" where each outcome comes
   out a fairly equal number of times over a period of time.
    I'm saying that it is wrong to believe that there should be a pattern
   in random outcomes. That there is a pattern (over time) with any random
   generator man can create is due to our inability to create a perfect
   random generator.
    This conference is very slow so I see no problem with this little
  thread.
-Robert
 * OLX 2.1 TD * C-C-C-C-Caffeine, a programmers best f-f-f-friend ...
--- PCBoard (R) v15.3/M 10
 * Origin: MoonDog BBS  RIME NetHub Brooklyn,NY (1:278/15)