Thanks, fixed. I think my table is identical to yours, except I consider tile 0 to have an island in the center, and then have a separate water tile.
I like your stage setup very much. I wouldn't have thought of your grass addition to the blob, which I think illustrates an important point about it's behaviour. I'd love to know how you are randomly picking your tile47 tiles - you've included some combinations (specifically narrow water channels), that never appear when you are considering the tiles as trying to border a spaced defined by whole tiles.
Also like the inclusion of some geomorphic tiles, where all tiles can border any other ones.
Glad you like it :-)
Here is the step by step method. I just kept it as simple and as random as possible.
This diagram may help. It shows a layout of just 12 blue tiles, 4 wide by 3 high (the black outlines). The centre of each tile is a yellow square. Each tile has 4 corners (red circles) and 4 edges (green rectangles).
1/ Create an array to hold the random data (white lines). You can see that each cell of the array holds a tile corner, edge or centre. It needs to be 'twice plus 1' the width and height of the tiles. So for 4x3 tiles it is 9x7 cells.
2/ Fill each cell with a random '0' or '1'.
Note each tile 'covers' 9 cells. We can ignore the central cell. (It will always be drawn as a 'blob' of land). So we need 2^8 which is 256 different tiles. This is too many. But we can reduce it to just 47 different tiles by the following clever method:
For each tile, if the edge is a '0' then make both the corners, either side of the edge a '0' as well. So…
3/ Step through the array, just visiting the tile centres. You only need to check the top and left edge of each tile. If this is '0' then set both corners either side to '0'.
// if top = 0: topLeft = 0, topRight = 0
// if left = 0: topLeft = 0, bottomLeft = 0
4/ This leaves right column and bottom row of the array unchecked. You can correct this, or simply set all array border cells to '0', which creates an island-in-the-ocean design.
Finally, calculate the index for each tile. The tile47 image shows the weightings used, which by convention 'scan' from topLeft to bottomRight.
5/ Step through the array again, just visiting the tile centres. Add up the corner and edge cells with the following weightings:
// index = topLeft + 2*top + 4*topRight + 8*left + 16*right + 32*bottomLeft + 64*bottom + 128*bottomRight
You should end up with an index of one of 48 numbers. This represents the correct tile to be used.
And that's it.
When randomly filling the array, it's best to choose more 1's than 0's, as many 1's are 'lost'. I added a balance control so you can alter the land mass between 50% and 90%. At 100% it's all land and 0% all water.
Boris -it's interesting that you think there are too many 'narrow water channels'. I'm picking the tiles randomly by the above method, so they must just 'naturally' appear between tiles. If you roll your mouse over the [Stage] a red square outlines each tile. Or choose label to show tile index numbers.
I must admit I was expecting more solid areas of unbroken land to form. I thought I could create an alternative lookup table to control this, but it's not possible.
Will now try splitting the edge and corner cells, so each can have a different balance of 0's and 1's. Should be able to reduce the land 'fingers'. Not sure if it will work...