Skip to main content
Bounty Awarded with 50 reputation awarded by jcora
added 111 characters in body
Source Link
David Gouveia
  • 25k
  • 5
  • 88
  • 127
// Default probabilities // Equal chance of tree and rock, no enemies   |-----|-----|-----|-----|-----| |T=50 |T=50 |T=50 |T=50 |T=50 | |R=50 |R=50 |R=50 |R=50 |R=50 | |E=0 |E=0 |E=0 |E=0 |E=0 | |-----|-----|-----|-----|-----| |T=50 |T=50 |T=50 |T=50 |T=50 | |R=50 |R=50 |R=50 |R=50 |R=50 | |E=0 |E=0 |E=0 |E=0 |E=0 | |-----|-----|-----|-----|-----| |T=50 |T=50 |T=50 |T=50 |T=50 | |R=50 |R=50 |R=50 |R=50 |R=50 | |E=0 |E=0 |E=0 |E=0 |E=0 | |-----|-----|-----|-----|-----| 

You'd pick one cell at random and change the values of that cell to Tree = 10%20%, Rock = 0%, Enemy = 90%80%. Then do the same for rocks. You can also use a radius of cells if you like to make the transitions smoother. You'll end up with something like:

// Added two random clusters: // One enemy cluster on the bottom right // One rock cluster on the top left   |-----|-----|-----|-----|-----| |T=0 |T=30 |T=50 |T=50 |T=50 | |R=100|R=70 |R=50 |R=50 |R=50 | |E=0 |E=0 |E=0 |E=0 |E=0 | |-----|-----|-----|-----|-----| |T=30 |T=40 |T=50 |T=80 |T=70 | |R=70 |R=60 |R=50 |R=10 |R=0 | |E=0 |E=0 |E=0 |E=10 |E=30 | |-----|-----|-----|-----|-----| |T=50 |T=50 |T=50 |T=70 |T=20 | |R=50 |R=50 |R=50 |R=0 |R=0 | |E=0 |E=0 |E=0 |E=30 |E=80 | |-----|-----|-----|-----|-----| 
// Default probabilities // Equal chance of tree and rock, no enemies |-----|-----|-----|-----|-----| |T=50 |T=50 |T=50 |T=50 |T=50 | |R=50 |R=50 |R=50 |R=50 |R=50 | |E=0 |E=0 |E=0 |E=0 |E=0 | |-----|-----|-----|-----|-----| |T=50 |T=50 |T=50 |T=50 |T=50 | |R=50 |R=50 |R=50 |R=50 |R=50 | |E=0 |E=0 |E=0 |E=0 |E=0 | |-----|-----|-----|-----|-----| |T=50 |T=50 |T=50 |T=50 |T=50 | |R=50 |R=50 |R=50 |R=50 |R=50 | |E=0 |E=0 |E=0 |E=0 |E=0 | |-----|-----|-----|-----|-----| 

You'd pick one cell at random and change the values of that cell to Tree = 10%, Rock = 0%, Enemy = 90%. Then do the same for rocks. You can also use a radius of cells if you like. You'll end up with something like:

// Added two random clusters: // One enemy cluster on the bottom right // One rock cluster on the top left |-----|-----|-----|-----|-----| |T=0 |T=30 |T=50 |T=50 |T=50 | |R=100|R=70 |R=50 |R=50 |R=50 | |E=0 |E=0 |E=0 |E=0 |E=0 | |-----|-----|-----|-----|-----| |T=30 |T=40 |T=50 |T=80 |T=70 | |R=70 |R=60 |R=50 |R=10 |R=0 | |E=0 |E=0 |E=0 |E=10 |E=30 | |-----|-----|-----|-----|-----| |T=50 |T=50 |T=50 |T=70 |T=20 | |R=50 |R=50 |R=50 |R=0 |R=0 | |E=0 |E=0 |E=0 |E=30 |E=80 | |-----|-----|-----|-----|-----| 
// Default probabilities // Equal chance of tree and rock, no enemies   |-----|-----|-----|-----|-----| |T=50 |T=50 |T=50 |T=50 |T=50 | |R=50 |R=50 |R=50 |R=50 |R=50 | |E=0 |E=0 |E=0 |E=0 |E=0 | |-----|-----|-----|-----|-----| |T=50 |T=50 |T=50 |T=50 |T=50 | |R=50 |R=50 |R=50 |R=50 |R=50 | |E=0 |E=0 |E=0 |E=0 |E=0 | |-----|-----|-----|-----|-----| |T=50 |T=50 |T=50 |T=50 |T=50 | |R=50 |R=50 |R=50 |R=50 |R=50 | |E=0 |E=0 |E=0 |E=0 |E=0 | |-----|-----|-----|-----|-----| 

You'd pick one cell at random and change the values of that cell to Tree = 20%, Rock = 0%, Enemy = 80%. Then do the same for rocks. You can also use a radius of cells if you like to make the transitions smoother. You'll end up with something like:

// Added two random clusters: // One enemy cluster on the bottom right // One rock cluster on the top left   |-----|-----|-----|-----|-----| |T=0 |T=30 |T=50 |T=50 |T=50 | |R=100|R=70 |R=50 |R=50 |R=50 | |E=0 |E=0 |E=0 |E=0 |E=0 | |-----|-----|-----|-----|-----| |T=30 |T=40 |T=50 |T=80 |T=70 | |R=70 |R=60 |R=50 |R=10 |R=0 | |E=0 |E=0 |E=0 |E=10 |E=30 | |-----|-----|-----|-----|-----| |T=50 |T=50 |T=50 |T=70 |T=20 | |R=50 |R=50 |R=50 |R=0 |R=0 | |E=0 |E=0 |E=0 |E=30 |E=80 | |-----|-----|-----|-----|-----| 
added 111 characters in body
Source Link
David Gouveia
  • 25k
  • 5
  • 88
  • 127
|-----|-----|-----|-----|-----| --- | | | | | | | | | | | | | | | | | | | | | |-----|-----|-----|-----|-----| | | | | | | | |  | | | | | | | Map Height | | | | | | | |-----|-----|-----|-----|-----| | | | | | | | | | | | | | | | | | | | | | | |-----|-----|-----|-----|-----| ---  |-----------------------------| Map Width 

Then for each cell in that grid you generate a random probability for each type of entity existing in that tile. This is where you can add some entity specific clustering.

// Default probabilities // Equal chance of tree and rock, no enemies |-----|-----|-----|-----|-----| // Same values everywhere |T=50 | .. | |  | |T=50 |T=50 |T=50 |T=50 | |R=50 | | |  | |R=50 |R=50 |R=50 |R=50 | |E=0 |  |  | |E=0 |E=0 | |E=0 |E=0 | |-----|-----|-----|-----|-----| | | .. | | ||T=50 |T=50 |T=50 |T=50 |T=50 | | | | | ||R=50 |R=50 |R=50 |R=50 |R=50 | | | | ||E=0 |E=0 |E=0 | |E=0 |E=0 | |-----|-----|-----|-----|-----| | | | .. | ||T=50 |T=50 |T=50 |T=50 |T=50 | | | | | ||R=50 |R=50 |R=50 |R=50 |R=50 | | | | ||E=0 |E=0 |E=0 | |E=0 |E=0 | |-----|-----|-----|-----|-----| 
// Added two random clusters: // One enemy cluster on the bottom right // One rock cluster on the top left |-----|-----|-----|-----|-----| // Only filled a few of the values but you get the point |T=20 |T=50 | | |T=0 | |T=30 |T=50 |T=50 |T=50 | |R=80|R=100|R=70 |R=50 |  | | |R=50 |R=50 | |E=0 |E=0  |  | |E=0 | |E=0 |E=0 | |-----|-----|-----|-----|-----| | | .. | | ||T=30 |T=40 |T=50 |T=80 |T=70 | | | | | |R=70 ||R=60 |R=50 |R=10 |R=0 | | | | | |E=0 |E=0 | |E=0 |E=10 |E=30 | |-----|-----|-----|-----|-----| | | ||T=50 ..|T=50 |T=50 |T=70 |T=10|T=20 | | | | |R=50 |R=50 |R=50 |R=0 |R=0 | | | |E=0 | |E=0 |E=0 |E=30 |E=90|E=80 | |-----|-----|-----|-----|-----| 
|-----|-----|-----|-----|-----| | | | | | | | | | | | | | | | | | | |-----|-----|-----|-----|-----| | | | | | | | | | | | | | | | | | | |-----|-----|-----|-----|-----| | | | | | | | | | | | | | | | | | | |-----|-----|-----|-----|-----| 

Then for each cell in that grid you generate a random probability for each type of entity. This is where you can add some entity specific clustering.

|-----|-----|-----|-----|-----| // Same values everywhere |T=50 | .. | |  |  | |R=50 | | |  |  | |E=0 |  |  |  | | |-----|-----|-----|-----|-----| | | .. | | | | | | | | | | | | | | | | |-----|-----|-----|-----|-----| | | | .. | | | | | | | | | | | | | | | |-----|-----|-----|-----|-----| 
|-----|-----|-----|-----|-----| // Only filled a few of the values but you get the point |T=20 |T=50 | |  |  | |R=80 |R=50 |  | |  | |E=0 |E=0  |  |  | | |-----|-----|-----|-----|-----| | | .. | | | | | | | |  | | | | | |  | | |-----|-----|-----|-----|-----| | | | .. |T=70 |T=10 | | | |  |R=0 |R=0 | | |  | |E=30 |E=90 | |-----|-----|-----|-----|-----| 
|-----|-----|-----|-----|-----| --- | | | | | | | | | | | | | | | | | | | | | |-----|-----|-----|-----|-----| | | | | | | | |  | | | | | | | Map Height | | | | | | | |-----|-----|-----|-----|-----| | | | | | | | | | | | | | | | | | | | | | | |-----|-----|-----|-----|-----| ---  |-----------------------------| Map Width 

Then for each cell in that grid you generate a probability for each type of entity existing in that tile. This is where you can add some entity specific clustering.

// Default probabilities // Equal chance of tree and rock, no enemies |-----|-----|-----|-----|-----| |T=50 |T=50 |T=50 |T=50 |T=50 | |R=50 |R=50 |R=50 |R=50 |R=50 | |E=0 |E=0 |E=0 |E=0 |E=0 | |-----|-----|-----|-----|-----| |T=50 |T=50 |T=50 |T=50 |T=50 | |R=50 |R=50 |R=50 |R=50 |R=50 | |E=0 |E=0 |E=0 |E=0 |E=0 | |-----|-----|-----|-----|-----| |T=50 |T=50 |T=50 |T=50 |T=50 | |R=50 |R=50 |R=50 |R=50 |R=50 | |E=0 |E=0 |E=0 |E=0 |E=0 | |-----|-----|-----|-----|-----| 
// Added two random clusters: // One enemy cluster on the bottom right // One rock cluster on the top left |-----|-----|-----|-----|-----| |T=0 |T=30 |T=50 |T=50 |T=50 | |R=100|R=70 |R=50 |R=50 |R=50 | |E=0 |E=0 |E=0 |E=0 |E=0 | |-----|-----|-----|-----|-----| |T=30 |T=40 |T=50 |T=80 |T=70 | |R=70 |R=60 |R=50 |R=10 |R=0 | |E=0 |E=0 |E=0 |E=10 |E=30 | |-----|-----|-----|-----|-----| |T=50 |T=50 |T=50 |T=70 |T=20 | |R=50 |R=50 |R=50 |R=0 |R=0 | |E=0 |E=0 |E=0 |E=30 |E=80 | |-----|-----|-----|-----|-----| 
Source Link
David Gouveia
  • 25k
  • 5
  • 88
  • 127

From your picture there seems to be a bit of randomness and clustering. Here's a way to do something similar without using noise.

You could start by dividing the playing field into sections. For instance, in the image above you could have divided it into a 5x3 grid.

|-----|-----|-----|-----|-----| | | | | | | | | | | | | | | | | | | |-----|-----|-----|-----|-----| | | | | | | | | | | | | | | | | | | |-----|-----|-----|-----|-----| | | | | | | | | | | | | | | | | | | |-----|-----|-----|-----|-----| 

Then for each cell in that grid you generate a random probability for each type of entity. This is where you can add some entity specific clustering.

For example you could start by filling everything with some default probabilities: Tree = 50%, Rock = 50%, Enemy = 0%

|-----|-----|-----|-----|-----| // Same values everywhere |T=50 | .. | | | | |R=50 | | | | | |E=0 | | | | | |-----|-----|-----|-----|-----| | | .. | | | | | | | | | | | | | | | | |-----|-----|-----|-----|-----| | | | .. | | | | | | | | | | | | | | | |-----|-----|-----|-----|-----| 

And then let's consider that you'd like your map to have exactly one cluster of enemies, and one zone with higher concentration of rocks.

You'd pick one cell at random and change the values of that cell to Tree = 10%, Rock = 0%, Enemy = 90%. Then do the same for rocks. You can also use a radius of cells if you like. You'll end up with something like:

|-----|-----|-----|-----|-----| // Only filled a few of the values but you get the point |T=20 |T=50 | | | | |R=80 |R=50 | | | | |E=0 |E=0 | | | | |-----|-----|-----|-----|-----| | | .. | | | | | | | | | | | | | | | | |-----|-----|-----|-----|-----| | | | .. |T=70 |T=10 | | | | |R=0 |R=0 | | | | |E=30 |E=90 | |-----|-----|-----|-----|-----| 

Finally, with this information in place, you only need to decide the maximum number of entities there can be in any cell (i.e the density of the cell) and start adding entities in random positions and using the probabilities above to decide the type of each of them.

This will provide you with a nice mix of randomness, and at the same time clustering based on the rules you define when filling in the probabilities grid.