# Any resources on how to generate a random board? (Project)

There are lots of possibilities for interesting random board generation, and I encourage creativity about this.

However, if you don't want to come up with your own idea, here's one approach you could try:

Instead of choosing independent random values for each Tile, which can cause big jumps up and down, let's make it so that each tile is closer to the values of its neighboring tiles, which will result in a smoother landscape.

For the top row of the grid, start with a random elevation in the top-left corner, and then for each tile going along the top row, add a random number between -N and N to the elevation of the tile to it's left.

For the left-most column, do the same thing, but going down starting from the top-left corner.
Then, fill in the rest of the grid, where each tile's elevation comes from adding a random number (between -N and N) to the average of the heights of the two tiles that are above and left of it.

One more complication: when adding the number between -N and N, if the result goes below 0, then set it to 0, or if it goes above the maximum tile elevation, then set it to the maximum, so that your tile elevations never go outside of the allowed range.

Another option would be start with totally uniform random values at each grid square, but then run a smoothing filter (e.g. setting every tile's elevation to become the average of the elevations from its neighboring tiles) over the grid a few times. This should also result in a smoother but still random landscape.

Another approach is to have code that generates "features" (like little mountains, valleys, roads, etc), and run those feature-generating codes several times at several different random locations on a board that starts out as flat originally.

answered by (508 points)
+4

Thank you!

We used the built in Random class to set each tile's height to a random value and made sure to run through each tile to change the height to a random value.

answered by (2k points)
+4

Thank you!