blackjack sounds possible...and i know how to make the characters for the types of cards... hmmm, not a bad idea but it will be kinda hard... oh well its worth a try, ill get back to you guys with a progress report
blackjack sounds possible...and i know how to make the characters for the types of cards... hmmm, not a bad idea but it will be kinda hard... oh well its worth a try, ill get back to you guys with a progress report
Paro
im in the process of building a blackjack game, but i must admit... it is much harder than i thought possible...
a few problems:
1) Aces can be 1 or 11
2) when it comes out as 12 (queen), i made it automatically be worth 10 (which it should be) but i dont know how to make it so it outputs a Q... or maybe i say
but if i did that it would add up horribly... is there any way to make it so 'Q' is worth 10 when i add it up?if(card1==12)
card1=='Q';
thanks for help in advance
Paro
Do you mind if I rewrite your program and post a copy as my own? I'm interested in seeing how well I can do for modifying it and make it "better" in my eyes. First year programming, myself.
hehe, do whatever you want with it. your talking about the ones at the top right? if so, its no problem
Paro
Was actually talking about the ones that started this thread. hehe... I'm working on the dice thing myself, using Member Functions and structs. Works nicely here at class.
Hey paro, you can either use parallel arrays or a struct, but the struct is much cleaner. And the toughest part is making an efficient shuffle. I did this program after about 2 months of C++, so it's definetly possible.
I doubt that, unless your school has problems with the APCS curriculum.Originally posted by Unregistered
first year in high shcool and thats your semester project?! wow you guys must progress slow as hell our school does stuff with stacks and binary search trees,advanced algorithms and the like...
Raven:
yea, those were the programs i was talking about. feel free to do whatever you want with the code and use it to your advantage, this site has helped me with many problems so it's the least i could do
Paro
tim:
we just learned the basics of structs last week, and this week we are learning Classes...
the basics of arrays are not until next chapter
(note: this was 2 months ago when i made that program )
Paro
um, anyone notice how unbelievably large this thread has gotten? over half my posts are on this thread alone...
anyways,
does anyone have a simple way to make it so an ACE in blackjack can be worth 1 or 11?
in blackjack sometimes you have 5 cards because they are all low... well, i need some way to make it so you cant have 5 of the same card, and so the odds of your card appearing twice is more unlikely then it is to be a different card...
blackjack is so unbelievably hard to do im frazzled...
why do i always have to make my programs harder to do than i can handle? the idea was just so it would be a simple blackjack game, and its turning into a nightmare
Paro
Well to begin, try to think up a good shuffling algorithm. I've thought up 3 already and I'm working on a fourth using linked lists. If you do a real shuffle and actually make a deck, the same card will never appear twice. Use suits, it makes it look better. And by the way, this will be REALLY FREAKIN HARD without arrays. So go ahead and learn those first.
Hehe, I remember the first program I really "tried" at was a game of 21. It was absolute crap- global variables and worse, it didn't even allow you to actually "play" the game...
Code:#include <iostream.h> #include <stdio.h> #include <conio.h> #include "randoma.h" int ucard; int dcard; int ccard; int PlayGame(); void UpdateCount(int result, int &wins, int &losses, int&draws); char AskRepeat(); void Report(int wins, int losses, int draws, int ng); int main() { int wins = 0, losses = 0, draws = 0; char answer; int nogame = 0; do { int result; nogame++; result = PlayGame(); UpdateCount(result, wins, losses, draws); answer= AskRepeat(); ucard = 0; dcard = 0; ccard = 0; } while ((answer != 'N') && (answer != 'n')); Report(wins, losses, draws, nogame); return(0); } int PlayGame() { int ncard = 0; int i = 0; cout << "How many card do you want? "; cin >> ncard; cout << endl << "You: "; for (i = 0; i != ncard; i++) { ccard= (random(10)+1); ucard+=ccard; cout << " " << ccard; } cout << " = " << ucard; cout << endl << "Computer: "; for (i = 0; i != 3; i++) { ccard= (random(10)+1); dcard+=ccard; cout << " " << ccard; } cout << " = " << dcard; cout << endl; int tog = 0; if (dcard < 22 && ucard < 22) { if (dcard == ucard) tog = 1; if (dcard > ucard) tog = 2; if (ucard > dcard) tog = 3; } if (dcard > 21) tog = 4; if (ucard > 21) tog = 5; if (dcard > 21 && ucard > 21) tog = 6; if (tog == 1 || tog == 6) cout << "\nOoh, a tie!\n"; if (tog == 2 || tog == 5) cout << "\nHeh, you lose.\n"; if (tog == 3 || tog == 4) cout << "\nYay! You win!\n"; return (tog); } void UpdateCount(int result, int&wins, int&losses, int&draws) { switch (result) { case 1: draws++; break; case 2: losses++; break; case 3: wins++; break; case 4: wins++; break; case 5: losses++; break; case 6: draws++; break; } } char AskRepeat() { char tstr; while (tstr != 'y' && tstr != 'Y' && tstr != 'n' && tstr != 'N') { cout << "\n Play again (Y/N)? "; cin >> tstr; if (tstr != 'Y' && tstr != 'y' && tstr != 'n' && tstr != 'N') { cout << "Please enter yes or no." << endl; } } return (tstr); } void Report(int wins, int losses, int draws, int ng) { system("cls"); cout << "\n" << "Your wins = " << wins << endl; cout << "Computer wins = " << losses << endl; cout << "Draws = " << draws << endl; cout << "Total games = " << ng << endl; cout << '\n'; return; }
paro,
you were asking if there was a simpler way to make
it so an ACE in blackjack can be worth 1 or 11,
well i was thinking something like this, i hope
it helps:
ACE = 11
SUM = the sum of all the cards, ACE being 11
if SUM > 21 then ACE = 1
check SUM again
if SUM > 21 you lose
thought by me in a yippy!,
rmullen i tried your program, but i dont have the header file "randoma.h" could you show the code for that so i can try out your prog?
Paro