Reworking local map generation

As you might know, the current local map is visualized based on four 100×100 pngs where the red, green and blue channel stand for different things. However, this means that everything is grid-based and doesn’t look natural. This is why I’m working on a new map generator.

In the new map generator, each map has a base texture that is the most common ground covering thing. Currently there are only two, sand and grass, but it is likely that in the future that there will be 7 ground types: bedrock, loam, silt loam, clay loam, sandy loam, sandy clay and silt. Currently terrain types vary pixel by pixel and there is a high chance that the next pixel will inherit the type of the one above it or to the left of it, forming clusters.

In the new map generation code, I have a function called “snake”. It causes slithering lines of pngs that overlap with each other. Large changes in direction are less likely than small ones, which prevents it from constantly flicking back and forth. My test maps are currently 1000×700 pixels, but the ones that will be used in the game will be bigger in the database. You will only be able to see a small area at a time, though. On the test map, it generates 1 to 10 snakes of sand or grass depending on which one of them is used as base material. Currently grass is the base and sand is on top, but it’s easy to swap these around.


Then it generates trees and bushes starting from the back and advancing in rows that are 20 pixels high. The tree density is selected at random. In the database, new trees can be added on any row because when the data is called, it will be arranged by y and x so that it always starts from the back.

I also have sprites drawn for rocks and boulders, but I haven’t added them to the simulation yet.

In the database, data will have element type, x, y and layer. The layers are ground, ground cover and objects that stick out.

It will be possible to click on trees and bushes to select them for cutting. I have also tested this. In the test, the outline of a tree is in the upper corner because aligning trigger areas with the actual trees would require knowing their coordinates and in the test, the outline is mapped out before the map itself is generated. In the future, each tree will be clickable.

Hover over the upper left corner to see the highlight shape in effect

This is utilizing a JQuery library called ImageMapster by James Treworgy.

It is a bit unclear how farming will work in the new system, but my idea is that you will be able to convert shapes your character is on top of into fields and they will look different. Then you can automate planting, weeding and harvesting. One problem is there can be overlapping tiles, so it should only take the combined covered area into account as farmland instead of overlap being counted twice. Another option would be to stamp farmland on top of the base ground and set a maximum overlap distance that is allowed. If each map only has one base soil type, it could be assumed that all fields also shared that when turned. An exception is clay, because it’s unrealistic that there would be whole maps that are entirely filled with clay. Clay should come in small clusters and once you dig it up, the underlying soil or bedrock is revealed and the clay is gone.

Certain resources will be bound to individual trees and bushes, so if you cut down a fruit tree, you get the ripened fruit as well as the wood, but after this you can no longer harvest from this tree. Trees will produce more fruit in a system that is bound to the seasons, so organic resources will be renewable. You will be able to select a harvesting radius and automate your gathering. NPC groups will consume food such as fruit and berries every day and also automatically gather it. If an NPC group runs out of food, it will migrate away, so it’s probably going to be up to you to ensure that they won’t exhaust the local resource deposits. You can teach NPCs to farm and farming will be more effective than foraging.

I haven’t yet decided how big the local maps will be. The new system will allow them to be of different sizes, but since the snake function can go to areas that were already previously explored, it shouldn’t be used after exploration has started. Trees and rocks can be generated on the fly, so it would be possible to generate local maps that are 10’000 by 10’000 pixels and only generate trees on the area that has been viewed. This would save space in the database. I’m just a bit concerned that even a single map could contain up to 300k objects, and how much space would this take to store. Currently saving the data for one location takes ~117kb. I suspect that if we generate the whole map every time someone explores a location, it will take even more than this. If I get 1000 players and each of them explores 100 local maps, this will be 100k local maps. Are this many necessary? Certainly not. But people will explore just because it’s possible. So it should make them forget about places no one has visited in ages. Speaking from experience, even 10k different local maps is a waste because nobody will be able to appreciate them. So local maps should be temporary unless settled, and if you forget about it, it won’t be the same when someone explores it the second time. Since the contents are affected by the world map, you would be unlikely to tell the difference. The tree density will be the same, the grassy areas will be in different spots but the ratios will remain the same. It’s fairly irrelevant where a single tree is located in a forest.


Ilona Ward


Leave a Reply