void initArea(Area* a, unsigned int n)
{
unsigned int living_cells, max_living_cells, y, x;
living_cells = 0;
max_living_cells = n;
srand(time(NULL));
while (living_cells <= max_living_cells)
{
x = (rand() % (a->xsize));
y = (rand() % (a->ysize));
a->cells[y][x] = ALIVE;
living_cells++;
}
}
I'm trying to make some of my dead cells alive with rand(), but when I have to make for example 50 alive cells, this code always gives little bit less. Why?
Aucun commentaire:
Enregistrer un commentaire