I don't believe online Solitaire games are using a good random shuffle of the deck before dealing a new game. For example, out of 44 successive starts of a game called Super Solitaire, 31 of them started with one or more pair face up, and half of those had two pair or a full house face up. Even more unlikely, all but four of them started with 1 to 3 face cards face up. That just doesn't seem like what you would expect from a random stack to me.
I want to do some study that involves combinations, permutations, odds, and othe statistical concepts that are beyond my mathmatical abilities, and I think PCBASIC is just what I need to do that. I want to first shuffle the cards by arranging the numbers 10 through 62 in as random order as possible. Then I want to display the first seven numbers in the deck. Reshuffle the deck and repeat that 100 times I'll get a good look at the results of truly random shuffling. To really give a real deck of cards a good random shuffle is a lot harder than it sounds. But the Solitaire game is done by a computer, and one expects the results to be exemplary.
The problem is I'm an 89 year old fart, and when I downloaded and looked at the PCBASIC screen all my experience working with BASIC 100 years ago just went blank. I'm looking for a good tutorial or some sample programs or something to get me started (unless some kind soul wants to offer more help).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks so much for the link to the tutorial. I've printed it and started
reading. I was excited when I started reading the section on Getting
Started. I typed in the program and started it running but could find no
way to stop it (no BREAK key on the PC keyboard). Had to just exit the
PWBasic program. I couldn't find any Pause or DELAY instructions so the
only way I could see any action was to insert two print-nothing lines.
I've got so much re-learning to do. The PWBasic screen stinks as a text
editor, which makes me think I'm doing something all wrong. Do I need a
compiler or something?
Just about everything that could go wrong went wrong.
1) Installed notepad++ but couldn't get it to work Gave up, uninstalled it
and went back to using my regular notepad.
2) Opened PC-BASIC but when I enter FILES it instantly rolls out a 4-column
list of over 100 files so quickly that I can never see the start of it to
find out what folder they are in. Tried every way I could think of to
either (1) print only the start of the files or (2) halt printing a
fraction of a second after starting or (3) reduce font size so all lines
appeared on one page, but nothing worked.
3) I can't tell where my PC-BASIC likes to save files, but I finally
realized I don't care. If I just use the SAVE and LOAD commands it's not
important where PC-BASIC does it.
4) When I enter FILES "*.bas" in PC-BASIC the screen shows:
Don't understand any of that. I don't even have a Z drive, let alone
anything with 867 terabytes free. If I search for either of those two
basic files I get web results only, even though I can see both of them in
the complete list of FILES mentioned above.
5) If I enter RUN "hello" in PC-BASIC it just says "File not found" That's
because I never put "hello" in that big folder in the Z drive (or
wherever).
6) I can't paste anything (such as the "hello" file) into PC-BASIC. I
suppose that's because it's running in DOS or command mode or something.
Probably the same reason I can't use the mouse in PC-BASIC. But if I type
it in and hit the F2 key the screen shows the program runs just fine:
RUN [10]hi [20]hit any key to loop or Ctrl-C to quit [30]
Every time you hit a keyboard key it adds another line [20]. (Did you mean
for line 40 to goto 10 instead of 20 so that each loop printed [10] and [20] ?)
Hitting Ctrl_C adds: [30]^c
Break in 30
Ok
So PC-BASIC is working OK. I can't believe there's no way to delete a
bunch of code lines or cut and paste, etc. Most of my work has always
involved timing functions. I tried the stuff Marc posted to get a pause or
delay. The attached picture shows I have that working too. So you guys
have got me off to a good start and I'll try to move forward. What is the
"REGISTER program" referred to?
Advanced Basic (available only to registered users), picks up from that
point and
covers areas such as animation, error trapping and real time event
programming. (Run the REGISTER program for details on how to obtain the
second part.)
Sorry that Notepad++ didn't work in your system. It is an awesome tool. Did you try the 32-bit version or the 64-bit one?
The benefit in finding the location of the drive letter Z: is you can load/save files using other code editors than the one included in PC-BASIC (that is cumbersome to work with any longer code).
PC-BASIC documentation about the driver letter Z: states this:
"If PC-BASIC is started from the start menu shortcut, the current device will be your Documents folder (or My Documents on some versions of Windows).
If PC-BASIC is started from the command prompt, the current device will be set to the current working directory of the command prompt."
So you might want to take a look at your Documents folder. See if you can find those files PYGAME .BAS, RUNE FIR.BAS in it.
Also, remember that if you want to edit the file in a source code editor, you should append the suffix ',a' when saving it in PC-BASIC, like this: save"program.bas",a
Otherwise PC-BASIC will save the program in a tokenized format that can't be edited in other editors.
"Every time you hit a keyboard key it adds another line [20]. (Did you mean
for line 40 to goto 10 instead of 20 so that each loop printed [10] and [20] ?)"
I didn't think clearly about it, but now you have mentioned it, I think it should loop to 10, yes.
"What is the "REGISTER program" referred to?"
I suppose the "REGISTER program" was some executable binary program that was distributed along with that tutorial back in the 1980s or so.
Everton
Last edit: Everton da Silva Marques 2020-05-31
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tried the 64-bit version of notepad++ because that's the OS of my Win10
. I'm going to try it again, both 32-bit and 64-bit.
Interesting your saying look in my documents folder for the files. My
computer says the properties of that folder are 45,193 Files in 3,019
Folders! I've saved at least a half dozen .bas files with PC-BASIC but I
don't see them anywhere. And I don't understand how PC-BASIC can save a
file somewhere in the PC and you can't find it with a search. HOWEVER,
the thing that is driving me nuts right now is that I don't seem to be able
to CHANGE anything. My modus oparandi is write and run a test program, and
when I want to try a small change I edit the change on the PC-BASIC screen,
re-save it, clear the screen, re-load it, and look at its listing to make
sure it is what I saved before I run it again. It never is! Aaaaawwwwww.
So I clear the screen and type in the whole program again instead of just
editing out the little change I wanted to try, give it a new name, save,
reload, and re-list, and most of the time it just repeats the listing
I'm trying to change. Let me guess: I have completely misunderstood
PC-BASIC and it does not allow you to edit a program with it, as for
example the Arduino IDE does.
Sorry to be so stupid about this. One last thing, which I probably knew
back in my DOS days but had forgotten -- filenames seem to be limited to 8
characters. The guys writing the tutorials and all are writing as if their
readers are still active basic users. Wouldn't you think the filename
limitation would be mentioned somewhere? And wouldn't it be elegant if the
designers of PC-BASIC would say something about a 4-word 17-character
filename instead of just truncating it to the first 8 characters and not
telling you? I could swear I heard a muffled "he he" from my computer when
I tried to retrieve one of those files.
Sorry that Notepad++ didn't work in your system. It is an awesome tool.
Did you try the 32-bit version or the 64-bit one?
The benefit in finding the location of the drive letter Z: is you can
load/save files using other code editors than the one included in PC-BASIC
(that is cumbersome to work with any longer code).
PC-BASIC documentation about the driver letter Z: states this:
"If PC-BASIC is started from the start menu shortcut, the current device
will be your Documents folder (or My Documents on some versions of Windows).
If PC-BASIC is started from the command prompt, the current device will be
set to the current working directory of the command prompt."
So you might want to take a look at your Documents folder. See if you can
find those files PYGAME .BAS, RUNE FIR.BAS in it.
"Every time you hit a keyboard key it adds another line [20]. (Did you
mean
for line 40 to goto 10 instead of 20 so that each loop printed [10] and [20] ?)"
I didn't think clearly about it, but now you have mentioned it, I think it
should loop to 10, yes.
"What is the "REGISTER program" referred to?"
I suppose the "REGISTER program" was some executable binary program that
was distributed along with that tutorial back in the 1980s or so.
Which PCBASIC version are you running? I am using 2.0.2. That could account
for differences where files are located.
I think I see the source of your confusion when editing programs in
PCBASIC. PCBASIC closely emulates the GWBASIC editing features that are at
odds with what one would expect nowdays. That's why I recommended Notepad++.
However the trick is, PCBASIC editor only actually updates one FULL line of
the program when you position the cursor over that line and hits RETURN.
Just changing the line on the screen does not update the line.
In other words, the workflow for updating, say, line 150 is to list 150,
change its contents on screen then HIT RETURN while the cursor is over that
line. By hitting RETURN over a line, you are telling PCBASIC it ought to
copy that line from screen to actual program memory.
I tried the 64-bit version of notepad++ because that's the OS of my Win10
. I'm going to try it again, both 32-bit and 64-bit.
Interesting your saying look in my documents folder for the files. My
computer says the properties of that folder are 45,193 Files in 3,019
Folders! I've saved at least a half dozen .bas files with PC-BASIC but I
don't see them anywhere. And I don't understand how PC-BASIC can save a
file somewhere in the PC and you can't find it with a search. HOWEVER,
the thing that is driving me nuts right now is that I don't seem to be able
to CHANGE anything. My modus oparandi is write and run a test program, and
when I want to try a small change I edit the change on the PC-BASIC screen,
re-save it, clear the screen, re-load it, and look at its listing to make
sure it is what I saved before I run it again. It never is! Aaaaawwwwww.
So I clear the screen and type in the whole program again instead of just
editing out the little change I wanted to try, give it a new name, save,
reload, and re-list, and most of the time it just repeats the listing
I'm trying to change. Let me guess: I have completely misunderstood
PC-BASIC and it does not allow you to edit a program with it, as for
example the Arduino IDE does.
Sorry to be so stupid about this. One last thing, which I probably knew
back in my DOS days but had forgotten -- filenames seem to be limited to 8
characters. The guys writing the tutorials and all are writing as if their
readers are still active basic users. Wouldn't you think the filename
limitation would be mentioned somewhere? And wouldn't it be elegant if the
designers of PC-BASIC would say something about a 4-word 17-character
filename instead of just truncating it to the first 8 characters and not
telling you? I could swear I heard a muffled "he he" from my computer when
I tried to retrieve one of those files.
Tommy
Tommy
On Sun, May 31, 2020 at 1:08 PM Everton da Silva Marques
evertonm@users.sourceforge.net wrote:
Hey Tommy,
Sorry that Notepad++ didn't work in your system. It is an awesome tool.
Did you try the 32-bit version or the 64-bit one?
The benefit in finding the location of the drive letter Z: is you can
load/save files using other code editors than the one included in PC-BASIC
(that is cumbersome to work with any longer code).
PC-BASIC documentation about the driver letter Z: states this:
"If PC-BASIC is started from the start menu shortcut, the current device
will be your Documents folder (or My Documents on some versions of
Windows).
If PC-BASIC is started from the command prompt, the current device will be
set to the current working directory of the command prompt."
So you might want to take a look at your Documents folder. See if you can
find those files PYGAME .BAS, RUNE FIR.BAS in it.
"Every time you hit a keyboard key it adds another line [20]. (Did you
mean
for line 40 to goto 10 instead of 20 so that each loop printed [10] and [20] ?)"
I didn't think clearly about it, but now you have mentioned it, I think it
should loop to 10, yes.
"What is the "REGISTER program" referred to?"
I suppose the "REGISTER program" was some executable binary program that
was distributed along with that tutorial back in the 1980s or so.
Everton
The PC-BASIC documentation has the section BASIC survival kit quite near the top, which lists several key combinations to stop a running BASIC program:
Use one of the key combinations Ctrl+Break, Ctrl+Scroll Lock, Ctrl+C or F12+B to interrupt a running program.
Delaying or sleeping can be done with the TIMER function and a WHILE loop. The following line should pause for about 2½ seconds:
10T=TIMER+2.5:WHILETIMER<T:WEND
Last edit: Marc 'BlackJack' Rintsch 2020-05-30
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It should be noted, however, that this is a very poor random number generator: its parameters imply a recurrence period of 224, meaning that after less than 17 million calls RND will wrap around and start running through the exact same series of numbers all over again. RND should not be used for cryptography, scientific simulations or anything else remotely serious.
So maybe GW-BASIC/PC-BASIC isn't the best choice to get “truly random shuffling”. Modern languages or libraries are using a pseudorandom number generator like a mersenne twister or give access to the systems random number generator that usually includes some external entropy from keyboard and mouse usage.
Why the numbers 10 through 62? To me it would make more sense to use the numbers 0 through 51 and calculate value and suit from those with MOD and \.
Instead of generating a quite small number of random samples one could also just generate all 133,784,560 possible combinations of drawing 7 cards from a deck of 52 cards and then analyse those for patterns like pairs, number of face cards, and so on. Shouldn't be a problem for todays hardware. But again, GW-BASIC/PC-BASIC might not be the best tool for this.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here are my final words on the matter. I'm satisfied now that I was completely wrong in my suspicions about Solitaire shuffling, and that statistical probabilities are too complex to "guess" at based on one's feelings.
For the past year I have been grumbling about the free solitaire games available on the internet. My complaint was that the deck was not being given a thorough shuffle before dealing a new game. I based that on what appeared to me to be an unlikely probability of three specific properties of the initial seven face up cards in nearly every hand of Klondike Solitaire: (1) one or more pairs; (2) one or more face cards; and (3) an ace or two about half the time. My paranoid belief was that maybe the game had 100 or more predetermined deck arrangements which were selected in sequence each time a new game was started, with all but the 100th arrangement being impossible to win. That would explain why it was so hard, but not impossible, to win. At startup of the program a random selection would be made of where to start in the sequence of decks. In retrospect, there are too many flaws in this reasoning for its "ugly secret" not to be discovered.
So I set out to test the “randomness" of solitaire dealing. First I gave each card in the deck a unique 2-character ID. The first character is the value of the card: A 2 3 4 ... 9 0 J Q K. The second character is the suit: S(spades) H(hearts) C(clubs) D(diamonds). So the complete deck of 52 cards looks like this:
After editing my card deck from four lines of 13 items each to a single line of 52 items, I selected "Click here to enter a custom list" and pasted the single line deck into the "List of numbers to randomize" box.
I requested 50 selections of seven items each be made, then hit the "Go" button. That simulated dealing 50 Solitaire games, and displayed the seven face-up cards for each as follows:
For the ratio of black to red cards (B/R) I counted the total "S”s (spades) and "C”s (clubs) in a line = “n”. The ratio B/R = n/(7-n).
For the total number of face cards I counted the total “J”s, “Q"s, and "K"s in a line.
For the total number of aces I counted the “A"s in a line.
For the total number of pairs I counted the total number of duplications of the first character in the seven pairs of characters in a line.
It looks like I was totally wrong about Solitaire shuffling. My analysis of fifty dealt hands showed the following:
As you might expect, since half of the cards are black and half are red, the number of black cards dealt is about the same as the number of red cards, with the difference approaching zero as more games are dealt. Of the 350 cards dealt in 50 games, 176 were black and 174 were red. Even so, more than 10% of games started with only one card of one color and six of the other color.
Pairs are to be expected in nearly all Solitaire games. In fifty games, all but four started with one or more pairs, and nearly half started with two or more pairs. There were even three games that started with three-of-a-kind.
Face cards are also to be expected. In the fifty games analyzed, 92 total face cards were dealt, an average of 1.8 per game. Only eight of the fifty hands had no face cards at all, and sixteen games had three or more.
An initial ace should be expected about half the time. Of the fifty games analyzed, 23 were dealt one ace and two were dealt two aces.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I don't believe online Solitaire games are using a good random shuffle of the deck before dealing a new game. For example, out of 44 successive starts of a game called Super Solitaire, 31 of them started with one or more pair face up, and half of those had two pair or a full house face up. Even more unlikely, all but four of them started with 1 to 3 face cards face up. That just doesn't seem like what you would expect from a random stack to me.
I want to do some study that involves combinations, permutations, odds, and othe statistical concepts that are beyond my mathmatical abilities, and I think PCBASIC is just what I need to do that. I want to first shuffle the cards by arranging the numbers 10 through 62 in as random order as possible. Then I want to display the first seven numbers in the deck. Reshuffle the deck and repeat that 100 times I'll get a good look at the results of truly random shuffling. To really give a real deck of cards a good random shuffle is a lot harder than it sounds. But the Solitaire game is done by a computer, and one expects the results to be exemplary.
The problem is I'm an 89 year old fart, and when I downloaded and looked at the PCBASIC screen all my experience working with BASIC 100 years ago just went blank. I'm looking for a good tutorial or some sample programs or something to get me started (unless some kind soul wants to offer more help).
Tommy,
I think you might enjoy this GW-BASIC tutorial:
http://www.o-bizz.de/qbtuts/gw-train/index.htm
If you need any help, please feel free to reach me by email.
Everton
Everton,
Thanks so much for the link to the tutorial. I've printed it and started
reading. I was excited when I started reading the section on Getting
Started. I typed in the program and started it running but could find no
way to stop it (no BREAK key on the PC keyboard). Had to just exit the
PWBasic program. I couldn't find any Pause or DELAY instructions so the
only way I could see any action was to insert two print-nothing lines.
I've got so much re-learning to do. The PWBasic screen stinks as a text
editor, which makes me think I'm doing something all wrong. Do I need a
compiler or something?
Tommy
On Thu, May 28, 2020 at 6:23 PM Everton da Silva Marques evertonm@users.sourceforge.net wrote:
Tommy,
Try this script:
1) Install a source code editor like notepad++: https://notepad-plus-plus.org/
2) Open PC-BASIC and enter the command
FILES
to find what its current folder is.On my system the folder is:
C:\Users\evert\OneDrive\Documents
3) Write this little program below into notepad++ and save it as "hello.bas" in the folder you found out on step 2.
On my system, I saved that BASIC code as
C:\Users\evert\OneDrive\Documents\hello.bas
.4) In PC-BASIC, enter
FILES "*.bas"
to check that it can find the filehello.bas
.5) In PC-BASIC, input
RUN"hello
to executehello.bas
.See also attached images.
Let me know how it turns out.
Everton
Hi Everton,
Just about everything that could go wrong went wrong.
1) Installed notepad++ but couldn't get it to work Gave up, uninstalled it
and went back to using my regular notepad.
2) Opened PC-BASIC but when I enter FILES it instantly rolls out a 4-column
list of over 100 files so quickly that I can never see the start of it to
find out what folder they are in. Tried every way I could think of to
either (1) print only the start of the files or (2) halt printing a
fraction of a second after starting or (3) reduce font size so all lines
appeared on one page, but nothing worked.
3) I can't tell where my PC-BASIC likes to save files, but I finally
realized I don't care. If I just use the SAVE and LOAD commands it's not
important where PC-BASIC does it.
4) When I enter FILES "*.bas" in PC-BASIC the screen shows:
FILES "*.bas"
Z:\
PYGAME .BAS RUNE FIR.BAS
867018432512 Bytes free
Ok
Don't understand any of that. I don't even have a Z drive, let alone
anything with 867 terabytes free. If I search for either of those two
basic files I get web results only, even though I can see both of them in
the complete list of FILES mentioned above.
5) If I enter RUN "hello" in PC-BASIC it just says "File not found" That's
because I never put "hello" in that big folder in the Z drive (or
wherever).
6) I can't paste anything (such as the "hello" file) into PC-BASIC. I
suppose that's because it's running in DOS or command mode or something.
Probably the same reason I can't use the mouse in PC-BASIC. But if I type
it in and hit the F2 key the screen shows the program runs just fine:
RUN
[10]hi
[20]hit any key to loop or Ctrl-C to quit
[30]
Every time you hit a keyboard key it adds another line [20]. (Did you mean
for line 40 to goto 10 instead of 20 so that each loop printed [10] and
[20] ?)
Hitting Ctrl_C adds:
[30]^c
Break in 30
Ok
So PC-BASIC is working OK. I can't believe there's no way to delete a
bunch of code lines or cut and paste, etc. Most of my work has always
involved timing functions. I tried the stuff Marc posted to get a pause or
delay. The attached picture shows I have that working too. So you guys
have got me off to a good start and I'll try to move forward. What is the
"REGISTER program" referred to?
Advanced Basic (available only to registered users), picks up from that
point and
covers areas such as animation, error trapping and real time event
programming. (Run the REGISTER program for details on how to obtain the
second part.)
Tommy
On Fri, May 29, 2020 at 7:45 PM Everton da Silva Marques evertonm@users.sourceforge.net wrote:
Hey Tommy,
Sorry that Notepad++ didn't work in your system. It is an awesome tool. Did you try the 32-bit version or the 64-bit one?
The benefit in finding the location of the drive letter Z: is you can load/save files using other code editors than the one included in PC-BASIC (that is cumbersome to work with any longer code).
PC-BASIC documentation about the driver letter Z: states this:
"If PC-BASIC is started from the start menu shortcut, the current device will be your Documents folder (or My Documents on some versions of Windows).
If PC-BASIC is started from the command prompt, the current device will be set to the current working directory of the command prompt."
So you might want to take a look at your Documents folder. See if you can find those files PYGAME .BAS, RUNE FIR.BAS in it.
Also, remember that if you want to edit the file in a source code editor, you should append the suffix ',a' when saving it in PC-BASIC, like this:
save"program.bas",a
Otherwise PC-BASIC will save the program in a tokenized format that can't be edited in other editors.
I didn't think clearly about it, but now you have mentioned it, I think it should loop to 10, yes.
I suppose the "REGISTER program" was some executable binary program that was distributed along with that tutorial back in the 1980s or so.
Everton
Last edit: Everton da Silva Marques 2020-05-31
Hi Everton,
I tried the 64-bit version of notepad++ because that's the OS of my Win10
. I'm going to try it again, both 32-bit and 64-bit.
Interesting your saying look in my documents folder for the files. My
computer says the properties of that folder are 45,193 Files in 3,019
Folders! I've saved at least a half dozen .bas files with PC-BASIC but I
don't see them anywhere. And I don't understand how PC-BASIC can save a
file somewhere in the PC and you can't find it with a search. HOWEVER,
the thing that is driving me nuts right now is that I don't seem to be able
to CHANGE anything. My modus oparandi is write and run a test program, and
when I want to try a small change I edit the change on the PC-BASIC screen,
re-save it, clear the screen, re-load it, and look at its listing to make
sure it is what I saved before I run it again. It never is! Aaaaawwwwww.
So I clear the screen and type in the whole program again instead of just
editing out the little change I wanted to try, give it a new name, save,
reload, and re-list, and most of the time it just repeats the listing
I'm trying to change. Let me guess: I have completely misunderstood
PC-BASIC and it does not allow you to edit a program with it, as for
example the Arduino IDE does.
Sorry to be so stupid about this. One last thing, which I probably knew
back in my DOS days but had forgotten -- filenames seem to be limited to 8
characters. The guys writing the tutorials and all are writing as if their
readers are still active basic users. Wouldn't you think the filename
limitation would be mentioned somewhere? And wouldn't it be elegant if the
designers of PC-BASIC would say something about a 4-word 17-character
filename instead of just truncating it to the first 8 characters and not
telling you? I could swear I heard a muffled "he he" from my computer when
I tried to retrieve one of those files.
Tommy
Tommy
On Sun, May 31, 2020 at 1:08 PM Everton da Silva Marques evertonm@users.sourceforge.net wrote:
Hi Tommy,
Which PCBASIC version are you running? I am using 2.0.2. That could account
for differences where files are located.
I think I see the source of your confusion when editing programs in
PCBASIC. PCBASIC closely emulates the GWBASIC editing features that are at
odds with what one would expect nowdays. That's why I recommended Notepad++.
However the trick is, PCBASIC editor only actually updates one FULL line of
the program when you position the cursor over that line and hits RETURN.
Just changing the line on the screen does not update the line.
In other words, the workflow for updating, say, line 150 is to list 150,
change its contents on screen then HIT RETURN while the cursor is over that
line. By hitting RETURN over a line, you are telling PCBASIC it ought to
copy that line from screen to actual program memory.
Let me know if this helps.
Everton
Em dom, 31 de mai de 2020 18:41, Tommy Tyler okasional@users.sourceforge.net escreveu:
The PC-BASIC documentation has the section BASIC survival kit quite near the top, which lists several key combinations to stop a running BASIC program:
Delaying or sleeping can be done with the TIMER function and a WHILE loop. The following line should pause for about 2½ seconds:
Last edit: Marc 'BlackJack' Rintsch 2020-05-30
From the notes section of the documentation of the RND function:
So maybe GW-BASIC/PC-BASIC isn't the best choice to get “truly random shuffling”. Modern languages or libraries are using a pseudorandom number generator like a mersenne twister or give access to the systems random number generator that usually includes some external entropy from keyboard and mouse usage.
Why the numbers 10 through 62? To me it would make more sense to use the numbers 0 through 51 and calculate value and suit from those with
MOD
and\
.Instead of generating a quite small number of random samples one could also just generate all 133,784,560 possible combinations of drawing 7 cards from a deck of 52 cards and then analyse those for patterns like pairs, number of face cards, and so on. Shouldn't be a problem for todays hardware. But again, GW-BASIC/PC-BASIC might not be the best tool for this.
Here are my final words on the matter. I'm satisfied now that I was completely wrong in my suspicions about Solitaire shuffling, and that statistical probabilities are too complex to "guess" at based on one's feelings.
For the past year I have been grumbling about the free solitaire games available on the internet. My complaint was that the deck was not being given a thorough shuffle before dealing a new game. I based that on what appeared to me to be an unlikely probability of three specific properties of the initial seven face up cards in nearly every hand of Klondike Solitaire: (1) one or more pairs; (2) one or more face cards; and (3) an ace or two about half the time. My paranoid belief was that maybe the game had 100 or more predetermined deck arrangements which were selected in sequence each time a new game was started, with all but the 100th arrangement being impossible to win. That would explain why it was so hard, but not impossible, to win. At startup of the program a random selection would be made of where to start in the sequence of decks. In retrospect, there are too many flaws in this reasoning for its "ugly secret" not to be discovered.
So I set out to test the “randomness" of solitaire dealing. First I gave each card in the deck a unique 2-character ID. The first character is the value of the card: A 2 3 4 ... 9 0 J Q K. The second character is the suit: S(spades) H(hearts) C(clubs) D(diamonds). So the complete deck of 52 cards looks like this:
AS 2S 3S 4S 5S 6S 7S 8S 9S 0S JS QS KS
AH 2H 3H 4H 5H 6H 7H 8H 9H 0H JH QH KH
AC 2C 3C 4C 5C 6C 7C 8C 9C 0C JC QC KC
AD 2D 3D 4D 5D 6D 7D 8D 9D 0D JD QD KD
Then I found this really neat random number generator program:
https://numbergenerator.org/randomnumbergenerator#!numbers=52&low=10&high=99&unique=true&csv=&oddeven=&start=false&oddqty=0&sorted=false
After editing my card deck from four lines of 13 items each to a single line of 52 items, I selected "Click here to enter a custom list" and pasted the single line deck into the "List of numbers to randomize" box.
I requested 50 selections of seven items each be made, then hit the "Go" button. That simulated dealing 50 Solitaire games, and displayed the seven face-up cards for each as follows:
KC 2H AS 8S 5D 4H 3C
6H AD 3D 6C 7D 4D 7S
3D 0S 4D KS QS 8H 0H
QH 8S JS JH AD KD 6D
6C QC 0H 7D 8S JC KC
QD 3S 7H 3C 7C QS 7D
3C 4H KH 5C KC 5D 2S
KH 8H QH 9H 8C 0H 2H
KH 7S 9S 5C JD 6H KD
7C 2D KC 4D QH 3S AC
0S KC 3C 2D 7D KD 7S
4S 7D 7S 9S 2S 8S QH
KD 6S 5D 4C 3H 5H 0S
7H QS 2S 7S 0S 8D 3H
2S 4C 4H 9H 6C 7D 5S
KH 6D AD 0H QS 8D KC
4S 5S 4D 2D 8D KH 9S
2H 2D 3C JS 3H AC 9H
8C AS QS 6C 6H 2H 5S
AH QC 7C 4H 2S 5C 5D
KD QH 6D 0H 8D 4C 5S
AS 8S 0H AH AD 7S 7C
3C 2S 8H QH KS 5D 2H
0H AC JS 3S 5S 3C 4H
7D KC QC QH AS 6D 2D
4C AD 2D 9C QH 9S 7C
3C 6D 7D 9S AD KS 5D
QH KH 5S 6H 5D 9D KD
7H 7C 9D 8D 8H 7D KH
KC AD QC JS 3S 7S QH
QS KS 5D 0S 6D JC 4S
0S QC JD JC 3H 2C 4S
3S 3H AS 6H 9S 3C 9H
3C 3S 2C 3D 5S 3H 4C
5D 7H 6H 5S 0D 0C 0H
2S QD 3H 9D 9C 5H 7D
6H 7D 8S QD 4H AC 5H
2C 2H AC 4S 8H 5C 5S
JC 5H 0D QH JD KS 4C
6H JD 2D 0C 7C 3S 4H
4C 0D 0C 9S 8H QD 9D
0D QC QH 6D JH 0S 7S
2H KH 9D 9H 7S 3S JC
6C AS 2H 3S 6S 0C KH
5S AC 4C 8D 9D KS QD
0D AS 9D 5H 6H AC QH
0S 3C 5D 6S 0H 2D JC
2H 9D 9S 2D JD AC 6C
AS JS 2C AC 0D 8C 0C
2C 4D QC 0S 3D 6C 7S
I analyzed the dealt hands as follows:
For the ratio of black to red cards (B/R) I counted the total "S”s (spades) and "C”s (clubs) in a line = “n”. The ratio B/R = n/(7-n).
For the total number of face cards I counted the total “J”s, “Q"s, and "K"s in a line.
For the total number of aces I counted the “A"s in a line.
For the total number of pairs I counted the total number of duplications of the first character in the seven pairs of characters in a line.
It looks like I was totally wrong about Solitaire shuffling. My analysis of fifty dealt hands showed the following:
As you might expect, since half of the cards are black and half are red, the number of black cards dealt is about the same as the number of red cards, with the difference approaching zero as more games are dealt. Of the 350 cards dealt in 50 games, 176 were black and 174 were red. Even so, more than 10% of games started with only one card of one color and six of the other color.
Pairs are to be expected in nearly all Solitaire games. In fifty games, all but four started with one or more pairs, and nearly half started with two or more pairs. There were even three games that started with three-of-a-kind.
Face cards are also to be expected. In the fifty games analyzed, 92 total face cards were dealt, an average of 1.8 per game. Only eight of the fifty hands had no face cards at all, and sixteen games had three or more.
An initial ace should be expected about half the time. Of the fifty games analyzed, 23 were dealt one ace and two were dealt two aces.