### Helllo,guys,the bug of 21point poker game

I have made a small game in 21point poker for player vs bot.However,the bot always draw the same point with player,how can I fix this issue?

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190`` `````` #include #include #include #include typedef struct{ char suit[256]; char no[256]; int count; }card; drawcard(card *c){ int i,j,n=0,array[256]; srand(time(NULL)); i=rand()%52+1; array[n++]=i; for(j=0;j0&&i<=13){ strcpy(c->suit,"Spades"); } else if(i>13&&i<=25){ strcpy(c->suit,"Hearts"); } else if(i>25&&i<=40){ strcpy(c->suit,"Diamonds"); } else if(i>40&&i<=52){ strcpy(c->suit,"Clubs"); } switch(i%13+1){ case 1: strcpy(c->no,"[1]"); c->count=1; break; case 2: strcpy(c->no,"[2]"); c->count=2; break; case 3: strcpy(c->no,"[3]"); c->count=3; break; case 4: strcpy(c->no,"[4]"); c->count=4; break; case 5: strcpy(c->no,"[5]"); c->count=5; break; case 6: strcpy(c->no,"[6]"); c->count=6; break; case 7: strcpy(c->no,"[7]"); c->count=7; break; case 8: strcpy(c->no,"[8]"); c->count=8; break; case 9: strcpy(c->no,"[9]"); c->count=9; break; case 10: strcpy(c->no,"[10]"); c->count=10; break; case 11: strcpy(c->no,"[J]"); c->count=11; break; case 12: strcpy(c->no,"[Q]"); c->count=12; break; case 13: strcpy(c->no,"[K]"); c->count=13; break; } } } } int main(){ card card; char fr,t,ht=5,bt=5,htt=5,btt=5;/*when the bot"s accumlated point larger than 12,the btt will become 0,when player don"t want to draw the card,the htt will become 1/when bot/player accumalted point exceed 21,the bt/pt will become4*/ int hc=0,bc=0;/*human count,bot count*/ int i; printf("Welcome to play 21point poker\n"); printf("-------------------------------\n"); while(1){ printf("Would you like to start first?[Y/N]]"); scanf("%c",&fr); getchar(); if(fr=='Y'){ t=1; break; } else if(fr=='N'){ t=0; break; } printf("\n"); } while(1){ while(1){ if(t==1){ printf("It is your round\n"); drawcard(&card); hc+=card.count; printf("You have drawn %s %s\n",card.suit,card.no); printf("Now your point is accumlated to %d\n",hc); t=0; break; } else if(t==2){ printf("Do you want to draw?[Y/N]"); scanf("%c",&t); getchar(); if(t=='Y'){ drawcard(&card); hc+=card.count; printf("You have drawn %s %s\n",card.suit,card.no); printf("Now your point is accumlated to %d\n",hc); t=0; if(hc>21){ ht=4; htt=1; } if(btt==0){ t=2; } break; } else{ printf("You don't want to draw the card\n"); t=0; htt=1; break; } } else if(t==0){ if(bc<=12){ printf("It is bot round\n"); drawcard(&card); bc+=card.count; printf("The bot have drawn %s %s\n",card.suit,card.no); printf("Now the bot point is accumlated to %d\n",bc); t=2; if(htt==1){ t=0; } if(bc>21){ bt=4; btt=0; } break; } else{ btt=0; break; } } } if(btt==0&&htt==1){ if(hc==bc){ printf("Draw\n"); } else if(hc>bc&&hc<=21||bt==4){ printf("Human win"); } else if(bc>hc&&bc<=21||ht==4){ printf("Bot win"); } break; } } }``````
While ne555 is absolutely correct and your code should be simplified a lot more, perhaps with more functions and arrays, your immediate problem (I think) is probably that you call `srand(time(NULL));` after every drawcard().