/* Oh, well. Time to replace all the bridge code. */ #include static long seed; initshuf() { FILE *file; /* get seed */ file = fopen("seed.dat","r"); fscanf(file,"%f",&seed); sprintf("%f",&seed); fclose(file); srand48(seed); /* so it's a double? */ return; } exitshuf() { FILE *file; double drand48(); /* put seed */ file = fopen("seed.dat","w"); fprintf(file,"%.15lf",drand48()); fclose(file); return; } shuffle(deck) int *deck; { int i; int to,temp; double drand48(); initshuf(); for (i=55;i>=0;i--) { to = drand48() * i; temp = deck[to]; deck[to] = deck[i]; deck[i] = temp; } exitshuf(); return; } /* shuffle the three hands other than keep [0,3] */ shuf3(deck,keep) int *deck,keep; { int i; int to,temp; double drand48(); for (i=0;i= keep*13)) to = 39 + to % 13; temp = deck[to]; deck[to] = deck[i]; deck[i] = temp; } for (i=(keep+1)*13;i<52;i++) { to = drand48() * 39; if ((to < (keep+1)*13) && (to >= keep*13)) to = 39 + to % 13; temp = deck[to]; deck[to] = deck[i]; deck[i] = temp; } return; }