TUXDB - LINUX GAMING AGGREGATE
 NEWS TOP_PLAYED GAMES ITCH.IO CALENDAR CHAT WINE SteamDeck
 STREAMERS CREATORS CROWDFUNDING DEALS WEBSITES ABOUT
 PODCASTS REDDIT 

 

SUPPORT TUXDB ON KO-FI

MENU

ON SALE

New Twitch streamer aggregation implemented (#FuckTwitch) due to Twitch's API issues (more info on my Discord )


Name

 MicroTown 

 

Developer

 Snowy Ash Games 

 

Publisher

 Snowy Ash Games 

 

Tags

 Strategy 

 

Singleplayer 

 

 Early Access 

Release

 2019-08-30 

 

Steam

 € £ $ / % 

 

News

 28 

 

Controls

 Keyboard 

 

 Mouse 

 

Players online

 n/a 

 

Steam Rating

 Very Positive 

Steam store

 https://store.steampowered.com/app/931270 

 
Public Linux depots

 MicroTown Linux [82.11 M] 




LINUX STREAMERS (0)




EA Update #24 - Map Generator 1/3

This update replaces the game's island map generator with a new more robust and expandable version.



I had two primary goals for the new level generator. Firstly, to bring it up to at least the same level as the old generator - but do this with a modular, extendable and configurable approach. And secondly, to fix the biggest problems with the old one - excessive unusable land, poor scaling with world sizes, bad coastal shapes and many minor issues.

There is a lot to talk about designing a complex system like this. I won't go into a huge essay about my software architecture here. There are many reasons why I'm doing the things I'm doing even if they oftentimes feel like over-engineering convoluted solutions to simple problems. But I will go over the most important parts.

Due to Steam post limit, I had to split this up into three parts. This post will focus on the overview and general approach, and the goal of the generator. The other two parts will go through specific generation steps: Post #2 and Post #3.

[h2]Iteration[/h2]

The hardest part of making a complex parametrized system is testing and iterating its results. The faster I can preview my changes and the easier I can understand the impact of these changes, the faster I can work on it and by extension produce better results.

This is my best friend:



To accomplish fast iteration, the system has to be designed with this in mind from the start.

A map generator makes hundreds of decisions when building a map from high-level choices (for example, the number of biomes) to specific low-level choices (for example, number of trees per tile). Usually, these are encoded as direct and indirect parameters that I can quickly tweak to achieve the desired results.

The difficulty comes from having lots of parameters and wanting to understand their impact at the same time, which means previewing the difference they make to the map generation. And this is a difficult problem because any changes that happen after the relevant ones can obscure the results. Most parameters have a huge range of possible values and only a narrow band of value produce desirable (or even usable) results.

So I want to preview not just the final result, but every step of the way. To do that, I am splitting the generator's logic into discrete steps or "passes" so that I can look at the independent output(s) of any pass in the sequence.

It is also critically important that the result preview is visual. This may sound like an obvious criterion, but implementing clear and useful previews takes significant additional time and effort. It is thus a longterm strategy, which means it has all the pitfalls of additional code to implement and maintain.



Another important consideration is coding the generator, not just running it. The last thing I want is to break everything by making changes. Implementing separate passes will take more time but not nearly as much time as having to rewrite large parts of the code if I interconnect everything. If I mess up some pass, then I will likely only break its inputs and outputs to the previous and next passes. And realistically I am almost guaranteed to rewrite, remove, add or majorly change many of the passes because I simply don't know how exactly they will work.

And one final and often overlooked benefit is personal motivation. Actually seeing the system work after every change is a huge boost to my motivation. It's the difference between just making something work and investing that extra polishing time. In a large system like this, small details quickly compound.

[h2]Passes[/h2]

I would like to describe every step the generator takes, because I personally find it all very interesting and I could talk about it for hours. Unfortunately, this will end up with a hundred pages long post (and about 20 times over the Steam post limit). So I will try to summarize the most important steps and parts. And even with me being "brief", it is still about 3 times over the post limit. So as I'm splitting the update into three posts - this one (broad overview) and two step-by-step overviews of the generation process: Post #2 and Post #3.

[h2]Scaling[/h2]

One thing I barely considered for the old generator is scaling parameters with the generated world size. This is where the huge sand areas of the old generator in the large maps come from. And this is actually a much more difficult problem than it seems, which needs to be "baked into" logic from the start. Every variable that controls something size-dependent for the generator must decide how it behaves with different map sizes and I need to be able to quickly control it. In fact, there must actually be all the variables to control size-dependent features (for example, I cannot scale parts of a noise map without scaling everything). For example, I would want to specify that a beach is 2 tiles wide or 5% of map size, or 3% of map area, etc. Choosing an incorrect value or approach might work fine for the reference size, but may produce terrible result for different sizes.

So when specifying parameters, I make sure to specify (and preview) how they scale:



Generally, the options are "static", "linear" and "exponential" (with inverse variants). Static mean the same value for all sizes - e.g. number of spawn locations. Linear means it scales with the map size (width) - e.g. allowed water edge distance. And exponential means it scales with the map area - e.g. number of stone deposits.

And when testing the generator, I can run any combination to verify that they all work correctly:



[h2]Major changes[/h2]

As mentioned, this update is not meant to majorly change the gameplay beyond (A) fixing and adjusting most problems with the old generator and (B) those changes that are best done now to avoid too much disruption later. So there are still a few bigger changes that do impact gameplay:

Rocks no longer spawn all over the place, but rather in discrete patches focused towards one area of the map (this preview is from the tiny map, because I cannot get a better screenshot from a large map to demonstrate the idea clearly):



Furthermore, rocks now come in 4 variants - Rocks, Coal Vein, Iron Ore Vein and Limestone Vein, with their respective deposits only spawning there:



Consequently, the Mines now need to be placed on the appropriate type of rock:



(That is one chonker of a tooltip... I haven't really come up with a way to shorten it either other than having 8 separate lines.)

Sand and Beach are now different tiles. Minable and usable Sand now spawn in discrete clumpy patches. Beaches spawn along the coast (sometimes in clumps) and they cannot be mined.



They look a bit empty (again, because I did not want to expand the scope of the update), but there is potential to add something here.

Overall, the island shape has somewhat changed. The generator attempts to "fit a hex shape" into the game area, with a roughly-expected distance to edges, but still some larger coastal variation (I explain the various constraints in the other posts). A more "extreme" example of an island that is basically a hex:



The coastline of the island is also much cleaner. There are no extended peninsulas or closed bays - the vast majority of the map should be accessible. But there can still be significant variation of the coastline. Again, a more "extreme" example with lots of "shapeness":



Most islands end up somewhere in between the two, leaning towards more varied coast.

I also added a new grass type for some visual variety and as a proof of concept that I can vary vegetation:



Which kind of lead to discussing the possibilities...

[h2]Potential[/h2]

One of the main goals of the new level generator was to be able to extend it in linear time. In other words, add new stuff quickly. This means there are a lot of things I can now add to the map that I previously couldn't. Some are very easy, some are more difficult, some are impractical. For example, I won't be making multiple islands (impractical), but I can easily add more biomes (easy) or cool features like a river or two (difficult). The great thing is that I am not limited to any particular single algorithm that has to somehow produce all the results in bulk - the generator consists of many individual steps and I have a lot of freedom to add and modify those.

A particular direction I want is to specialize and utilize different parts of the map, so that the terrain shapes the village more than it currently does (i.e. not at all). For example, you might have a swamp in one end that is needed for medicinal plants or flood plains in another part, where crops grow best, and so on. Following this, I might be able to force some production chains to actually need transportation from their production location to their processing location rather than having everything clumped together.

Another big potential feature is allowing player customization for the generated map. For example, forest density, deposit amount, climate bias, etc. I haven't implemented any of this, but I have kept this in the back of my mind when designing systems. I basically comes down to having user values selecting or adjusting one or more generation parameters.

Finally, I could potentially add--if not full replayability with different climate zones and resources--then at least enough differences between maps and their layout to not all look the same.

So this is all something that I'm looking forward to (admittedly, I am also exhausted having spent so much time on the generator.) I won't even speculate on what I want to add next, because there are just so many possibilities. In fact, deciding what to add and--more importantly--what not to add is in itself a big design decision/direction.

[h2]Unity engine[/h2]

I am currently using Unity engine for the game. You my have heard about the recent Unity trust debacle. I won't go into details here, but the main point is that I do not wish to continue using the engine. Unfortunately, MicroTown is many years into development and strongly tied with the engine's features. This makes porting to a different engine very difficult and time consuming. I don't know if I can realistically invest that much time into this. I spent a couple weeks investigating engines and experimenting to see what such a transition would require. For now, I am still undecided. But it's likely I'll have to stay with the current engine.

[h2]Future plans[/h2]

I had to really stop myself from starting to add more features to the level generator. It has already turned out to be the largest "feature" that I have ever worked on. And the final touches and fixes again took way longer than I anticipated.

I wish I could have split this update into multiple parts over past year or so. But unfortunately this is one of those "all or nothing" features. I cannot implement half the generator or even 90% of the generator - it has to be all of it. So updates have been, shall we say, a bit slow (in addition to some other real-life stuff). So I tried to work on it 50/50 mixed with other features/updates, but that hasn't really been a good approach. I will definitely avoid splitting major workloads like that in the future.

So, hopefully, I will be making several "terrain updates" adding something to the generator and either adding or modifying something in related gameplay.

[h2]Full changelog[/h2]

Changes

Implemented new level generator algorithm
Overall terrain shape is now properly based on a hexagonal shape, but there is more coastal variation and most landmass is slightly further from the edge of the map, but with more variation
Terrain is now constructed in a more cell-like pattern, where "cells" correspond to biomes/regions, such as meadows or forests. Trees and other props will have way fewer unnatural "stretches" and "clumps". These "regions" will tend to be more uniform and connect more naturally.
Islands overall shape will avoid generating with no coastline variation or excessive water or land
Island now has several larger "climate" or "biome" sections that somewhat alter its layout and features - a part of the island has more forests, a part has more plains and a part has more rocks along with other slight vegetation biases.
Deep Water to Shallow Water transitions are now smoother
Water will not have excessive "patches" anymore
Coastline is less jagged now and fewer extended unusable peninsulas or bays will spawn
Add Switchgrass, a type of grass that spawns in Grassland
Rename "Flower" to Marigold
Add generic Flower concept
Vegetation (Tree layout, types, tile variation, and Shrubbery/Marigold) layout are all now based on a separate noise patterns to avoid unnatural patterning
Add new tile Beach that replaces Sand along the coastline, not suitable for quarrying
Coastal tiles have much less Sand (that is, fewer Beach tiles) now
Sand, Clay and Rocks now spawn in dedicated patches and cover much less of the terrain
Patches of Rocks, Clay and Sand won't spawn next to similar patches anymore
Rocks patches will spawn more in "rocky biome" and will generally include all the ores in that region (although they will still spawn randomly elsewhere)
Clay patches now only spawn further inland
Sand patches only spawn closer to coastline
Several larger Beach locations now spawn randomly along the coast
Rocks now have resource vein variants - Coal Vein, Iron Ore Vein and Limestone Vein (and their excavated variants - Excavated Coal Vein, Excavated Iron Ore Vein and Excavated Limestone Vein)
Coal Mine, Iron Ore Mine, Lime Mine can now only be built on their resource tile variant, while Stone Mine can be built on plain Rocks
Spawn point is now randomly offset from the middle of the map
Spawn region is now clear of obstructing terrain
Spawn region will always have some free-standing rocks around it
Spawn region will only be set in "regular" climate avoiding inconvenient terrain for starting
Patches with resources will avoid spawning in poorly-accessible unbuildable locations, like surrounded by water or unbuildable terrain
Animal Habitats now spawn based on distance to coast rather than distance to map edge/center making for more uniform spawning and avoiding unreachable locations
Animal Habitats now pre-spawn properly instead of appearing one at a time after the world starts
All the internal properties of level generation now scale with the world size appropriate to their purpose. For example, larger worlds do not get larger beaches or excessive rock patches while smaller worlds still contain sufficient rock patches. Terrain features, like biomes stay proportionally-sized.
World generation will no longer stall UI (some other operations will also have fewer UI stalling portions)
Older saves with Mines will have their tiles converted to respective resource tile
Older saves will have empty stone patches randomly converted to resource patches
Add worker self-delivery max distance indicator "circle" when building or selecting buildings
Add the worker self-delivery max distance value to several relevant tooltips
Item deliveries during carrier shortage will allow self-deliveries, ignoring regular priorities and proportions, but not not stalling/failing to deliver
HUD delivery info tooltip will also show self-delivery count

Fixes

Selecting Observer would not show the empty icons above observable building until they had done at least some work
Fix worker self-deliveries not working above dedicated carrier max delivery distance
Fix workers delivering 2 or 3 items of their building's output to storage removing/replacing them from the building as worker
HUD delivery info tooltip showing the wrong number of available (idle) carriers and some other slight inconsistencies due to self-deliveries
Fix props attempting to transform while a worker is using them, for example a sapling rotting while being harvested by an arborist (and this invalid combo causing games saved at this moment to fail to load)

Balancing

New terrain generation alters various gameplay elements

Rudy
Snowy Ash Games


[ 2023-10-24 14:35:28 CET ] [ Original post ]