Discuss Scratch

masterdancerdoge
Scratcher
9 posts

Random Map Generator

Anybody has a idea on how to make a random map generator like Civilization Vl? I need it for my game.
commieolive
Scratcher
14 posts

Random Map Generator

Well, a start would be to make the map a grid of squares of some size, these could be clones or individual sprites, although that would be really tedious. You could then make each one choose between being land or water at the start, based on how far they are to the center- the further, the more likely to be water. With this base you could then add things like continents or rivers or things like that but what I described would be good for a really rudimentary start.
masterdancerdoge
Scratcher
9 posts

Random Map Generator

Can you explain a bit more? Thanks.
commieolive
Scratcher
14 posts

Random Map Generator

A decent way to do it would be to have a list of all the squares on the map that can either be 1, for water, or 0, for grass. Make a formula that randomizes all the squares, but makes it more likely for squares near the center to be grass and ones near the edge to be water. This will create an island-looking thing. You can then experiment to see what other features you can add.
WhaleF1NN
Scratcher
13 posts

Random Map Generator

I would implement a tile sheet using lists, with 0 representing air maybe, 1 ground and 2 water.
Basic Design:

whenclickeddeleteallofMaprepeatNumberOfItemsInGrid/Sceneadd0toMap

If you want to see more tile sheet using lists i am currently working on a tetris game using one: Tetris Game Look at the “Make Board” Custom Block to see how I did it.

Last edited by WhaleF1NN (March 6, 2025 15:12:19)

masterdancerdoge
Scratcher
9 posts

Random Map Generator

Thank you. I will try to use this.
Penthusiast
Scratcher
25 posts

Random Map Generator

masterdancerdoge wrote:

Anybody has a idea on how to make a random map generator like Civilization Vl? I need it for my game.

Look into something called wave function collapse. It's a fairly simple concept, and it works well for map generation. The general idea is at first, each cell can be any tile. You pick a random tile for a cell, and with predefined rules on which tiles can be next to which tiles, you continue narrowing it down - and picking at random if there's more then one acceptable tile, until all the cells have been assigned a tile.

Powered by DjangoBB