Hi Everyone,
I'm writing a blackjack game for c and my users turn works fine. The array I made has an index of 52. I'm "shuffling" the deck with srand and everything seems to work other than the computer's turn. I'm making a limit that the computer will only draw cards up until it gets an accumulated sum larger than 15.
When I run the program, the computer's turn keeps going and going and going. I've tried several different loop structures and condition statements but it keeps doing the same thing. Can anyone else see what error there is that is causing this?? I'd really really appreciate any input at all!
here's the code for the user and computer:
Thanks a ton!!Code:} int Users_Turn(int deck[]) { int card; int totalscore=0; int score; int choice; choice=Continue(); while(totalscore<21 && choice==1) { card=Draw_One_Card(deck); Display_Card(card); score=Score_Card(card); totalscore=totalscore+score; printf("\n\nYour total score so far in this hand is: %i\n\n", totalscore); if (totalscore>21) printf("Sorry you lose this round you owe me a peanut!HAHAHA"); else choice=Continue(); } while(totalscore<21 && choice==2) { Computer_Turn(deck); } return totalscore; } int Computer_Turn(int deck[]) { int card; int totalscore=0; int score; int finalscore; if(totalscore<15) { card=Draw_One_Card(deck); Display_Card(card); score=Score_Card(card); totalscore=totalscore+score; printf("\n\n My total score so far in this hand is: %i\n\n", totalscore); } else finalscore=totalscore; return finalscore; }
-Melodia



LinkBack URL
About LinkBacks



