📜 ⬆️ ⬇️

Generation of large cards in a remake of the game "Caesar III (c)"

If you are a lover of the game "Caesar III", then you probably noticed that with what diligence and attention to trivia the campaign maps were made, and the free mode too. Natural landscapes on which the player builds a “new Rome” look quite realistic (as part of the game): streams flow into rivers and lakes, rivers flow through the entire map, and “immortal” sheep roam in the forests, sometimes wandering into the meadows and making it difficult to build farm, seagulls circling over the accumulation of fish, and sometimes an unlucky sailor sails along the river on the remains of a ship. The rock massifs are surrounded by trees, and the ground is covered with a carpet of lush green grass. All this wonderful image has a flaw, the size of the map does not exceed 160x160 tiles, in the article I will tell how I did the generation of maps of large sizes.



The original game does not support large maps, so all the experiments were conducted in the framework of the CaesarIA project (open-source clone Caesar III (c)) . The support of the big cards in the remake was from the very beginning, but before reading a good article on using the diamond-square method in building landscapes , it was not possible to load any cards besides those that went with the game or were made by fans. Having understood the direction in which to move, I came across another article on the generation of landscapes , which finally convinced me of the reality of using this method to automatically create a map.

The result of the original algorithm will be an array of points with heights, associating the height with color, we get such a map.
')
image

Colors have corresponding meanings:
- blue color corresponds to water with great depth,
- brighter will mean water near the coast,
- yellow will be the coast
- green means grass and flat areas,
- a deep green forest will be displayed,
- gray and dark gray, small and high mountains, respectively.

When adapting the results of work to the specifics of the landscape of the game, I had to revise the interpretation of some values ​​and settings, but in general, these data are suitable for further processing. Now you can display the obtained values ​​on the map of the city, for a start I will only change the water tiles and leave the rest unpainted.

image

After pouring water tiles, you can fill the grass, forest and mountains. Now the generated map is more like a regular one.



The remaining large part of the map is supposed to be covered with high mountains, but then it will become impassable for people, so instead of high mountains I again use plain tiles. On the resulting map, the areas adjacent to the water remained unfilled.



When filling in these areas, you will have to take into account the position of your neighbors in order to choose the right texture for a particular tile. The game has the following types of textures for the beach oriented:
- on North:
- to the East:
- South:
- to the west:

Such tiles are determined by the location of the water tiles relative to the tile for which the calculation is performed. For example, a north oriented coast tile may have a water tile only in the north, northeast, and northwest directions, and combinations thereof. Similarly, we perform calculations for the rest of the coast tiles and do not touch the others. The result will be a coastline without corner tiles.

image

The next step is to find the corner tiles that were skipped in the previous step. Such tiles have triples of neighbors (water) in the direction of north-> northeast-> east, east-> southeast-> south, and analogous ones. To display the angles of the coast, the game has the following textures: By placing them we get almost complete map.

image

Now there are tiles on the water and on the ground that were not processed in the previous stages. Tiles that are surrounded by earth on all sides also carry to the ground, and those that are surrounded by water - respectively, to the water. Tiles of the coast are simultaneously considered both water and land. It now remains to supplement the map with the road, so that the settlers could come and rivers to diversify the general landscape.

imageimage

Generating a 500x500 tile map takes a little time, but still significantly more than loading ready-made maps. Below I posted a screenshot of a large map, the size of which is 3800x1880 pixels. On such a map, you can add different objects, settlements and even a city in single player mode, but I see that it is more suitable for network. Another of the positive aspects of the selected algorithm is scalability, you can save the results of calculations and, if necessary, use them to calculate the neighboring territory.



Of course, the generated map does not compare with what was done by a person, but the ability to create maps in automatic mode allows you to go a step further in creating the continuation and development of the ideas contained in the original game. You can also watch and participate in the development of the Caesar III remake on the project page . The source code of the map generator is here .

Bonus Screenshots from the remake

Source: https://habr.com/ru/post/230829/


All Articles