HexMap is a map generation software that creates realistic maps out
of tiles that are hexagonal shaped. This software is completely
JavaScript based, and utilizes React to cut down on duplicated code
and maintain state of the map itself. React makes it extremely
simple to only regenerate the map when we need to, speeding up the
website.
Users can utilize the settings on the left hand side to edit the map
to their needs. Width and height settings control how many hexagons
wide and tall the map is. Users can decide what tile types they want
to include in their map. Events can be added to the map, like bandit
camps or ore veins.
This software was created for two reasons: I love the maps that
Civilization 5/6 generate, and I wanted software to mimic that and I
wanted to learn React. This project was a fantastic way to satisfy
both needs.
Map generation, especially in games like Civilization 5/6, can be
extremely complicated. However, it doesn't have to be. My first map
generation algorithm just randomly assigned a tile type (i.e.
Desert, Mountain, Plain, etc.) to each tile of an n*n map. The maps
that a generated aren't very realistic, but it does get the job
done.
My current algorithm builds off of the random map. First, I generate
two random numbers, one associated with moisture level, and another
associated with altitude. After that, I want to take into account
each tiles' neighbors, and take an average of each neighbors'
altitude and moisture level, then assign those values to the tile
I'm currently on. This essentially "smooths out" the map, ensuring
the map doesn't go from desert, to swamp, to desert, etc. (or, it at
least makes it less likely).
This algorithm could definitely be improved, and I have a few plans
in the future to do that. I want to take into account ocean level
and allow the user to control what percentage the ocean consists of
in the map. Adding different biomes makes the map more complex,
which is always welcome. Rivers and roads are another land formation
that I want to add.