Procedural map generation in C++ — Part 2: A new hope with cellular automata and GPT4
This is the 7th devlog of Warmonger Dynasty, a 4X turn-based strategy game made in C++/SDL. If you want to read the previous entries, take a look at my reading list.
In my previous devlog, we talked about procedural map generation. We tried a combination of Voronoi diagrams, Perlin Noise, and Wave Function Collapse, but unfortunately got no good looking results.
For this part, I decided to try the GPT4 version of ChatGPT (which costs 20$/month), just to see what the fuss was about. Spoilers: it’s very useful if you know how to write your prompt efficiently.
Also, since the generation code was getting more and more complex, I had to write a debugging tool to see the data for each intermediate step. I used Python and Tkinter for this purpose, as well as matplotlib
, numpy
and Pillow
.
Prelude: Code organization
I want to be able to easily add or remove steps to the generation process, and rearrange them.
For this purpose, I created 2 structures, 1 class and 1 abstract class:
config
: this structure will hold the parameters of the generation algorithm, such as the seed, width/height of the map, …