# Blackjack

Show 80 post(s) from this thread on one page
Page 3 of 5 First 12345 Last
• 08-26-2004
The Brain
:)
• 08-26-2004
MMD_Lynx
Me? maybe. dunno.
and it's not going very well right now. i had to make my own swap function for my card structure, and it's not working.

i have this BASIC book that has a cool equation thing that gives the suit and value of a card from just one number. it seemed pretty cool but not very useful for a blackjack game.

this is kinda what i have.
Code:

```struct card {   int value; //2 thru Ace   int suit; //self explanatory.   int score; //value in bj. }; typedef card CARD; void swap(CARD x, CARD y); class Deck {   private:       int place; //what card the deck is on.   public:       CARD cards[51]; //52 cards. (you need 51 there cuz of 0 - 51 is 52 numbers.       Deck();       shuffle(); //more stuff. }; Deck::shuffle() {   int j;   for(int i = 0; i<52; i++)   {       j = random(52);       swap(cards[i], cards[j]);   } } swap(CARD x, CARD y) {   CARD temp;   //blah blah   //here i set the values of x to temp   //the values of y to x   //and the values of temp to y }```
that's pretty much what i have.
NOTE: it wasn't copied directly.
• 08-26-2004
The Brain
???
you have a chicken in your pants....?!??? :confused:
• 08-26-2004
MMD_Lynx
Yes. (and it hurts)
Yep! :D
im looking thru billions of posts on this board to try and figure out a way to fix my shuffle function.

i was really gettin' into this project. I even made a FLOWCHART. *gasp*

Un burro sabe mas que tu. Heh heh heh.
• 08-26-2004
PJYelton
Quote:

Me? maybe. dunno.
and it's not going very well right now. i had to make my own swap function for my card structure, and it's not working.
If the code is just like what you have written, I think the swap function isn't working because you are passing the cards by value. The swap function creates two new CARD variables, swaps them, then destroys them when the function is done. Change
Code:

`void swap(CARD x, CARD y);`
to
Code:

`void swap(CARD &x, CARD &y);`
Also, it should be cards[52] not cards[51]. The number sets aside the amount of memory to allocate, NOT the highest index. So cards[52] allocates memory for 52 cards numbered 0-51.
• 08-28-2004
MMD_Lynx
yah i figured that out that day :) my dad helped me. now im working on dealing out the cards. hopefully it will work. im kinda doing a text rpg and blackjack at the same time (but im working on blackjack more).
• 08-28-2004
The Brain

i think it would be cool if you could incorporate blackjack in your RPG...

or maybe an RPG inside your game of blackjack...? :D
• 08-29-2004
MMD_Lynx
and i realized something...
character numbers 3 thru 6 are the suits...yay!
Brain: I wish I could teach u women. i don't think anyone can ('cept maybe a woman)
• 08-29-2004
The Brain
i don't think women can even teach women :confused:
• 08-29-2004
MMD_Lynx
Quote:

Originally Posted by The Brain
i don't think women can even teach women :confused:

true dat.
in this song on one of my CDs it says "play it back in slow motion so I may understand the complex infrastructure known as the female mind"

here's code for the suit thing
Code:

```#include <iostream.h> const char suit[4] = {3, 4, 5, 6}; const char *rank[13] = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"}; int main(void) {         for(int i=0; i<4; i++)   {           for(int j=0; j<13; j++)       {               cout<<suit[i]<<rank[j]<<" ";       }   }   return 0; }```
• 08-29-2004
The Brain
will const char suit[4] = {3, 4, 5, 6}; work without using ' ' char notation

ex:

const char suit[4] = {'3', '4', '5', '6'};
• 08-29-2004
Prelude
>will const char suit[4] = {3, 4, 5, 6}; work without using ' ' char notation
It will if your system prints the heart, diamond, club, and spade for values 3, 4, 5, and 6. ;)
• 08-29-2004
The Brain
outstanding. :cool:
• 08-29-2004
PJYelton
If anybody is interested, here are a couple of classes I wrote last year sometime dealing with cards, deck of cards, and card hands. Among other useful methods, they are set up to print pretty pictures, well as pretty as ASCII art goes anyways! You guys are welcome to use them, just don't take credit for them lol :D The petter-color.h file is used for the colors so be sure to include it.
• 08-29-2004
The Brain
:)
code looks really good.. a bit technical.. but much bueno. :)

couldn't get it to compile though.....

Deleting intermediate files and output files for project 'cards - Win32 Debug'.
--------------------Configuration: cards - Win32 Debug--------------------
Compiling...
cards.cpp
fatal error C1083: Cannot open source file: 'C:\Documents and Settings\Owner\Local Settings\Temp\Temporary Directory 1 for cards.zip\cards.cpp': No such file or directory
Error executing cl.exe.

cards.exe - 1 error(s), 0 warning(s)
Show 80 post(s) from this thread on one page
Page 3 of 5 First 12345 Last