card* initshoe(int c) { cno = c; card *s; s = (card *)malloc(sizeof(card) * c); /*now i will initialise the deck*/ initdeck(cno, s); return s; }
void initshoe(shoe *s, int dno) { s->arr = (deck *)malloc(sizeof(deck) * dno); int i = 0; while(i < dno) { initdeck(&(s->arr[i])); i++; } s->dno = dno; s->deckno = 0; }
void * simulator(void * v) { uint32_t ngames = ((uint32_t *)v)[0]; uint32_t * ohs = (uint32_t *)malloc(2*(np-1)*sizeof(uint32_t)); uint32_t cs[7], myas[7], cs0, cs1, result, result1, i, j, k; uint32_t mycounters[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // int mywins = 0, mydraws = 0; deck * d = newdeck(); for (i=0; i<kc; i++) { pick(d, as[i]); myas[i] = as[i]; } for (i=0; i<ngames; i++) { int64_t score; initdeck(d, 52-kc); for (j=0; j<2*(np-1); j++) ohs[j] = draw(d); for (j=kc; j<7; j++) myas[j] = draw(d); for (j=0; j<7; j++) cs[j] = myas[j]; sort(cs); score = eval7(cs); result = WIN; for (j=0; j<np-1; j++) { cs[0] = ohs[2*j]; cs[1] = ohs[2*j+1]; for (k=2; k<7; k++) cs[k] = myas[k]; sort(cs); result1 = comp7(cs, score); if (result1 < result) result = result1; if (result == LOSS) break; } mycounters[result]++; mycounters[hand(score)]++; } pthread_mutex_lock(&tlock); for (i=0; i<12; i++) { counters[i] += mycounters[i]; } pthread_mutex_unlock(&tlock); free(ohs); free(d); return NULL; }