consider this a devlog. progress, fails, lessons β all while building a strategy game in one C++ file. yes, really.
goal? learn C++ deeply. no frameworks. no engine. just raw STL and a grid-based fever dream.
introduction
i play a lot of map games. stare at borders. micromanage. get invaded. rinse. repeat.
but those games come with a 10-page tutorial and 4 DLCs. so i figured: make my own β no GUI, no paywalls. just C++ and vibes.
progress
ποΈ June 25, 2025
β current code
TL;DR: build a grid β randomly generate regions β name them β print them pretty in terminal.
[1] take user input for rows
and cols
β define map size
[2] call makeRegion(rows, cols)
β returns a grid + map of region names
[3] createGrid()
builds 2D base; regionNames
maps ids like
{1: "coastline"}
[4] usedNames
(a set) avoids duplicate region names
[5] cap region size with:maxSize = min(rows, cols) / 2;
[6] pick random values:
β randSize
: 1 to maxSize
β randRow
, randCol
: within bounds
[7] use namePool[]
for random, non-repeating region names
[8] loop (500 tries):
β check if area is free with checkFreeArea()
β if yes, fill it via fillRegion()
β assign name, bump regionId++
then we return the grid
and regionNames
map.
π¨οΈ printRegionInfo()
tracks bounding boxes for each region id:
β scans grid
β updates min/max row+col for each id
β prints: region id, name, top-left coords, and size
πΊοΈ printMap()
prints grid as a color-coded ASCII map:
β 0
β gray dots
β other ids β colored blocks via ANSI codes
β std::setw(3)
for spacing
it's a visual debug tool, but honestly kinda satisfying to look at
next: saving to .txt, maybe adding basic region editing
ποΈ July 2, 2025
β current code
TL;DR: save the map to txt file and also intialize map and add resources , to distribute later , to be saved in a file too
[1] btw i have started making gemini cli summarize the file changes in
documentation.md
[2]so now the map is saved at data/map.txt
in format of size then the grid then the region names
[3]now when the program is started and the map is found at said path we load the map using the loadMap
function , also made a struct named `cells` to easily store the data in the format i want that is row , column , regionId and name of the region
[4]then i defined a std::vector
with cell innit and well stored the data of the file into it , thus loading our map
[5]then the loadMap
function prints our map and all details , honestly wasn't needed but i wanted to create the effect of lot of things loading
[6]so now i defined primaryResources
and derivedUnit
to differentiate between like primary is present by default in regions , distributed using random (to be done ) and auto supplies a fixed amount every turn (TBD) and collecting these resources we can make things in the derivedUnits like outpost , tanks , aircrafts and other things. some derived units need other derived units to be made in the region. for ease i have taken the approach of `build it and you have it` instead of research then build and what not. also for now i have decided popuplation or say human resources doesn't really matter
[7] then after defining all those units and their dependencies i have finsihed this segment of todo things , next i have to define giveAndSaveResources
function which will give primary resources randomly to each region by ID