473,385 Members | 1,331 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problems creating 8 deck card shoe in Basic

1
Hi: I have been trying to create an eight deck card "shoe" (as used in casino games such as Blackjack and Baccarat), but have run into some problems. I do not have much programming experience, and so I tried the following rather inefficient code using multi-dimensional arrays. Each hand in baccarat contains between 4 and 6 cards, so if 410 cards is reached or exceeded, the program attempts to reshuffle all cards. The problem is duplicate cards for some ranks and an insufficient number for others on all runs. Suits are irrelevant in baccarat and so weren't addressed. Any ideas on whether the following code is fixable, or do I need to start again with a whole new algorithm? OS is Win2000. Many thanks! -Gambler.

[code]

55 dim card(52,8)
60 dim value(52,8)
65 for x = 1 to 52
70 for y = 1 to 8
75 card(x,y) = x
84 next y
85 next x
90 for x = 1 to 52
100 for y = 1 to 8
110 c = int(rnd(52)*100)
115 d = int(rnd(8)*100)
120 if d > 8 or d = 0 then 115
125 if c > 52 or c = 0 then 110
130 GOSUB [assigncardvalues]
135 card(c,d) = 0
140 next y
145 next x
150 GOSUB [dealhand]
155 GOSUB [displayhands] 'not shown
160 GOSUB [printcount] 'not shown
165 GOSUB [handoutcome] 'not shown
170 if cardnum >= 410 then goto 55 'variable initialized in [dealhands]

[assigncardvalues]
if c mod 13 = 1 then value(x,y) = 2
if c mod 13 = 2 then value(x,y) = 3
if c mod 13 = 3 then value(x,y) = 4
if c mod 13 = 4 then value(x,y) = 5
if c mod 13 = 5 then value(x,y) = 6
if c mod 13 = 6 then value(x,y) = 7
if c mod 13 = 7 then value(x,y) = 8
if c mod 13 = 8 then value(x,y) = 9
if c mod 13 = 9 then value(x,y) = 10
if c mod 13 = 10 then value(x,y) = 10
if c mod 13 = 11 then value(x,y) = 10
if c mod 13 = 12 then value(x,y) = 10
if c mod 13 = 0 then value(x,y) = 1
RETURN

[code]
Sep 28 '06 #1
0 1297

Sign in to post your reply or Sign up for a free account.

Similar topics

23
by: JC | last post by:
I am very new to programming and learning on my own. Why do I keep getting duplicate values using this code? I want to shuffle a deck of 52 cards. The logic seems right to me. Randomize For...
6
by: CaseyB | last post by:
If I wanted to create a game like Solitaire that would first randomly shuffle a deck of cards, I figured out that all I had to use is the Random() class or rnd and make sure I use the Randomize...
10
by: Arun Nair | last post by:
Can any one help me with this im not getting it even after reading books because there is not much of discussion anywhere a> Implement a calss that represents a playing card. The class should...
11
by: Jeff | last post by:
het gang. Happy Holidays and stuff. Here is what I am wanting to do, but need some guidance as hwo to start in the right direction. using sql db on ms server i have players sign up for a...
4
by: Pratik | last post by:
For the time being, I'm doing a simple swap method for my deck of cards using the random number generator in cstdlib. I've created a dynamic array of a type class Card. When I go to shuffle it and...
6
by: JNeko | last post by:
Hello all, awesome site! I guess I am technically not a beginner in JAVA, but from my code you would not realize it! I don’t expect anyone to help me with this, but I figure I might as well as try...
1
by: cerise | last post by:
I'm using a Linked list stack with objects. I figured out the reason for my earlier problem (where I couldn't access "rank" and "suit" from one of the objects in my stack), and it was because my...
1
by: Vneha | last post by:
import java.util.*; public class Deck { public static int numSuits = 4; public static int numRanks = 13; public static int numCards = numSuits * numRanks; private Card...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.