void *MakeLevs(void *ThreadNum){ int *NumPointer = (int *)ThreadNum; int LoopStart = *NumPointer * (NumLevs/NumThreads); int i = 0; uint32_t *Pgen= &gens[*NumPointer]; //printf("The *gen of thread %d is:%d \n",*NumPointer,*Pgen); for (i=LoopStart; i<LoopStart+NumLevs/NumThreads; i++) { struct Room rs[100]; int lenrs=0; int *Plenrs = &lenrs; int ii; for (ii=0;ii<50000;ii++){ MakeRoom(rs,Plenrs,Pgen); if(lenrs==99){ break; } } struct Tile ts[2500]; for (ii=0;ii<2500;ii++){ ts[ii].X=ii%TileDim; ts[ii].Y=ii/TileDim; ts[ii].T=0; } for (ii=0;ii<lenrs;ii++){ Room2Tiles(&(rs[ii]),ts); } struct Lev l; memcpy(l.rs,rs,sizeof(rs)); memcpy(l.ts,ts,sizeof(ts)); l.lenrs=lenrs; ls[i]=l; //lenLS++; } }
int main(int argc, char* argv[]) { clock_t start, stop; start = clock(); int v = atoi(argv[1]); printf("The random seed is: %d \n", v); srand(v); uint32_t gen = v; uint32_t *Pgen= &gen; int i; struct Lev ls[100]; int lenLS=0; for (i=0; i<100; i++) { struct Room rs[100]; int lenrs=0; int *Plenrs = &lenrs; int ii; for (ii=0;ii<50000;ii++){ MakeRoom(rs,Plenrs,Pgen); if(lenrs==99){ break; } } struct Tile ts[2500]; for (ii=0;ii<2500;ii++){ ts[ii].X=ii%TileDim; ts[ii].Y=ii/TileDim; ts[ii].T=0; } for (ii=0;ii<lenrs;ii++){ Room2Tiles(&(rs[ii]),ts); } struct Lev l; memcpy(l.rs,rs,sizeof(rs)); memcpy(l.ts,ts,sizeof(ts)); l.lenrs=lenrs; ls[lenLS]=l; lenLS++; } struct Lev templ; templ.lenrs=0; for(i=0;i<100;i++){ if(ls[i].lenrs>templ.lenrs) templ=ls[i]; } PrintLev(&templ); stop = clock(); long clocks_per_ms = CLOCKS_PER_SEC/1000; printf("%ld\n", (stop - start)/clocks_per_ms); return 0; }