I'm creating a blackjack card counting simulator in c++ and I'm starting off by making the program choose from the number of cards avaviable. I have assinged each card with a starting value of 4(execpt for 10 and clothed cards as they all have the same value) as there's 4 of each number in a complete deck. However I want these numbers to go down as a card is drawn. For example if I draw a 3 I want the value of three's to go from 4 to 3. Thank you. Code:
#include<iostream>
#include<time.h>
int acecard = 4;
int twocard = 4;
int threecard = 4;
int fourcard = 4;
int fivecard = 4;
int sixcard = 4;
int sevencard = 4;
int eightcard = 4;
int ninecard = 4;
int tencard = 16;
//shows how many of each card there is
int cards[10] = { acecard, twocard, threecard, fourcard, fivecard, sixcard, sevencard, eightcard, ninecard, tencard };
//stores all the card in an array
int cardpick()
{
srand(time(NULL));
int Ranindex = rand() % 10;
return cards[Ranindex];//picks random card from array
}
int main()
{
return cardpick();
}
I tried to use if functions via something like this:
srand(time(NULL));
int Ranindex = rand() % 10;
int update = cards[Ranindex];//picks random card from array
if (update = acecard)
{
acecard -= 1;
}
However since most cards have the same starting value it would make the value go down for the card no matter what card was drawn. Thank you.