QBASIC PROGRAMMING FOR CARD COUNTING MATH PROJECT

Ask questions about projects relating to: computer science or pure mathematics (such as probability, statistics, geometry, etc...).

Moderators: MelissaB, kgudger, Ray Trent, Moderators

Re: HI

Postby davidkallman » Sun Nov 04, 2007 7:17 pm

Hi domplain not tall,

Thanks for your reply. As I mentioned in my post, some places to start are:

http://www.computer-books.us/basic_2.php
Free download of the popular book - QBASIC Tutorial

http://www.petesqbsite.com/sections/tut ... ners.shtml
Beginner's tutorials

If these don't work for you, I would suggest looking at the other sites output by supplying "QBASIC Tutorial" to google, with emphasis on "beginners". (I forgot to ask if you had any prior programming experience. If you do, you might be able to go with a more advanced tutorial.)
Cheers!

Dave
davidkallman
Former Expert
 
Posts: 675
Joined: Thu Feb 03, 2005 3:38 pm

QBasic Card Counting - see URGENT: Mathematics on this Forum

Postby LewisWhaley » Sun Nov 25, 2007 4:13 pm

Hi Cardcounter.

Most of the required QBasic code needed for this project can be found
in an old Post,
URGENT: Mathematics Programming
in this Math & Computer Science Forum.

Let me know if you have any questions about this.

Good Luck! :D
Best Regards,

Lewis Whaley
Ask an Expert Forum
Science Buddies
LewisWhaley
Former Expert
 
Posts: 181
Joined: Wed Aug 31, 2005 2:47 pm
Occupation: Retired - Information Technology Software Development and Systems Support since 1969.
Project Question: n/a
Project Due Date: n/a
Project Status: Not applicable

Postby LewisWhaley » Mon Nov 26, 2007 2:19 am

Hi again Cardcounter.

The following is a "cut and paste" of a card counting
QBasic program that I helped another student with in 2005:

_________________

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

Posted: Sun Oct 09, 2005 8:37 pm Post subject:

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

Hi ZeroTakenaka.

Here is the latest skeleton for you to use.
You need to use REM statements to document
your Changes.
Programs like this tend to "Evolve" and it is real easy
to lose your place if you have many copies around.

This should be close to what you are trying to accomplish.
Try different ways to "Count" the Next Card Number,
like adding 2 instead of 1 or subtracting 2 instead of 1
or use a Random Number for the Card Number showing,
like:
n = RND(r) - 1 or n = RND(r) + 1
instead of
n = r - 1 or n = r + 1
You will just have to change the variable "n" in different ways
until you find a good algorithm that works closest
to providing the best number of matches.

New Program:

=======
REM: Card Counting Analysis Program
REM: Program Written:
REM: 10-09-2005 09:12 AM EDT
REM: Change Log:
REM: 10-09-2005 08:12 PM EDT Add and print Total Counts for Match / Unmatch.

REM: 10-05-2005 07:23 PM EDT Add Output File for Saved Results.
REM:
REM:

CLS

DEFINT A-Z

a = 0
b = 0
c = 0
n = 0
amatch = 0
bmatch = 0
cmatch = 0
aunmatch = 0
bunmatch = 0
cunmatch = 0

TextFileName = "C:\ZTaka01.txt"

Open TextFileName For Output As #1


RANDOMIZE TIMER

FOR x = 1 TO 10000
r = INT(RND * 13) + 1
p = n
n = r
IF r > 7 THEN n = r - 1: a = a + 1: IF p = n THEN amatch = amatch + 1
IF r = 7 THEN b = b + 1: IF p = n THEN bmatch = bmatch + 1
IF r < 7 THEN n = r + 1: c = c + 1: IF p = n THEN cmatch = cmatch + 1
Record = Record + 1
Result$ = "Record_" + Record +"Card Showing " + r + " Card Count Next Card " + n
PRINT #1,Result$
PRINT Result$
REM: Comment Now: PRINT "Card Showing "; r; " Card Count Next Card "; n
PRINT "Press any Key to continue or type x to Stop.": INPUT a$
IF a$ = "x" OR a$ = "X" THEN GOTO GameOver
a$ = ""
NEXT

GameOver:

aunmatch = a - amatch
bunmatch = b - bmatch
cunmatch = c - cmatch


PRINT
PRINT "Total number of Cards : "; x
PRINT
PRINT "Card > 7 Number of times : "; a; " Matched: "; amatch; " Unmatched: "; aunmatch
PRINT "Card = 7 Number of times : "; b; " Matched: "; bmatch; " Unmatched: "; bunmatch
PRINT "Card < 7 Number of times : "; c; " Matched: "; cmatch; " Unmatched: "; cunmatch
CLOSE
END

=======

Note - The following similar Counts are displayed at the END of program.


Total number of Cards : 101

Card > 7 Number of times : 46 Matched: 8 Unmatched: 38
Card = 7 Number of times : 9 Matched: 2 Unmatched: 7
Card < 7 Number of times : 45 Matched: 2 Unmatched: 43
=======

--------------------------------------------------------------------------------
_________________

Let me know if you have any questions.

Good Luck! :D
Best Regards,

Lewis Whaley
Ask an Expert Forum
Science Buddies
LewisWhaley
Former Expert
 
Posts: 181
Joined: Wed Aug 31, 2005 2:47 pm
Occupation: Retired - Information Technology Software Development and Systems Support since 1969.
Project Question: n/a
Project Due Date: n/a
Project Status: Not applicable

Postby hhemken » Tue Nov 27, 2007 12:19 pm

Hi domplain not tall,

Could you tell us a bit about you and your computer? Have you ever programmed before? Do you already know how to do things in QBasic? What cpu. memory size, disk space, and operating system does your computer have?

That will help us tailor our advice and help better.
Heinz Hemken
Mentor
Science Buddies Expert Forum
hhemken
Expert
 
Posts: 262
Joined: Mon Oct 03, 2005 3:16 pm

Re: QBASIC PROGRAMMING FOR CARD COUNTING MATH PROJECT

Postby Dr. Bruce Weaver » Sat Dec 29, 2007 1:51 am

Hi,

You may have moved on to other choices by now but I thought that I'd put in my two cents about languages.

There is no 'right' computer language any more than there is a 'right' tool in the tool box; it depends on the task at hand. Unfortunately, in the world of programming, certain languages tend to the 'in' language and are recommended in place of all other choices. Before choosing what language to use, decide what the problem is and for what purpose the language was designed for. You can drive a nail with a pair of pliers but it really isn't the right tool for the job.

Perl, Python, Tcl, and Ruby were designed as scripting languages and are useful in web page creation, doing computer system work, and rearranging data or passing data between other programs.

Java is designed to run programs on other folks computers, across the internet and is designed so that it cannot do any damage to the target machine.

C, and it's object-oriented relative C++, is a low- to mid-level language. C was designed to design computer systems and C++ added something called 'classes' of variables. These are languages that let you manipulate computer behavior.

FORTRAN is a high-level language favored by folk who want to do serious 'number crunching' such as weather prediction, fluid dynamics, astrophysics, and quantum physics. That is, it is used by scientists and engineers to do problems that involve extensive calculations.

QBasic is an unsupported version of the BASIC language, designed, like Pascal, for learning to program.

Most of these languages can be used for other purposes. Many, like Perl, have evolved to include other capabilities so that folks who used them could broaden their uses.

Almost any language can be used to perform most tasks. I have not mentioned some of the most frequently used languages, used by businesses and other folks who store manipulate large amount of data like your credit card transactions.

On QBasic: Personally, I find QBasic quite useful. I can write quick, small programs to do one-time calculations or manipulate text. For example, I currently use a QBasic program to log standardized details of scientific observations that I make with my instruments. I recently used it to calculate the apparent size of dust grains in the tails of comets. I like it because the cycle between writing it and running it is very short and the syntax is very simple. I've also used it with great success in teaching programming. It is a natural for your card counting program.
Wm. Bruce Weaver, Ph.D.
Monterey Institute for Research in Astronomy
Dr. Bruce Weaver
Former Expert
 
Posts: 33
Joined: Wed Sep 08, 2004 12:21 pm

Re:

Postby jeffer » Sat Dec 11, 2010 6:27 am

davidcastagna wrote:Also, now that I look at this closer, it looks like you also have what is known as an "Infinite Loop".

Look at what happens if the computer picks the number R=5, 4 times. The first 4 times, everything is fine and you will jump out of the DO/LOOP because of the "IF D = 1 OR D = 2 .... THEN EXIT DO".

But what happens if the computer pick R=5 for a fifth time. This time the "IF D = 1 OR D = 2 .... " will be FALSE and the computer will do "ELSE GOTO 99" instead of "THEN EXIT DO". This will make the computer go back to the label "99:" and execute there again.

Now this looks like it should work fine to randomly select 52 random card selections. However, think about what happens if all of the variables A, B, C, D, E, F, G, H, I, k, M, Q and S are all equal to 4.


I hope your post is right. Your solution is pretty good. :P
jeffer
 
Posts: 4
Joined: Wed Dec 01, 2010 10:07 am
Occupation: Engineering & cyclist
Project Question: About dermatology
Project Due Date: Dermatology and dental problem
Project Status: I am conducting my research

Re: QBASIC PROGRAMMING FOR CARD COUNTING MATH PROJECT

Postby robertreavis » Mon Dec 27, 2010 12:44 pm

A bug in your program? So what, I make mistakes too. I spent weeks finding simple little errors that were just sitting there like a snake ready to bite. NASA has had some monumental errors that were software bugs, like crashing a rocket because the feedback-loop calculation was positive instead of negative. I wrote a program once that worked properly the first time, a once in a lifetime event and I have written hundreds of routines and comlete programs. All but that one required repairs.
robertreavis
Former Expert
 
Posts: 89
Joined: Wed Aug 31, 2005 6:58 pm

Re: QBASIC PROGRAMMING FOR CARD COUNTING MATH PROJECT

Postby davidkallman » Mon Dec 27, 2010 2:43 pm

There are also standalone programs called debuggers that (not surprisingly) help you debug your program. For more details check the wikipedia page for debuggers at:
http://en.wikipedia.org/wiki/Debugger

Cheers!

Dave
Cheers!

Dave
davidkallman
Former Expert
 
Posts: 675
Joined: Thu Feb 03, 2005 3:38 pm

Previous

Return to Grades 9-12: Math and Computer Science

Who is online

Users browsing this forum: Exabot [Bot] and 3 guests