Vote count:
0
I'm trying to generate a random 2D grid that is procedurally generated from the [x, y] coordinates (as opposed to pre-generating a 2D array of numbers). The reason for this is that the map is potentially huge, and there is a good possibility that much of the grid will not actually be needed.
Here's what I have so far:
double value_at(Grid *grid, int seed, int x, int y) {
srand(seed + x + y * grid->width);
return (double)rand() / (RAND_MAX + 1.0);
}
It's generating grids properly, however I'm seeing a lot of regularities in the output:
You can see that there is a sort of "grain" that sends lines moving diagonally through the output.
I'm doing some research on it but I'm having some trouble finding ways to do this. Does anybody have an idea on how to get the grids to be a bit more "random"?
asked 1 min ago
Dynamic random grid
Aucun commentaire:
Enregistrer un commentaire