Sprint 20 - Adam-Poppenheimer/Civ-Clone GitHub Wiki
Goals
- Resource distribution that balances civ homelands without oversaturating or undersaturating regions with bonus resources.
- The ability to enforce continent separation in the Continents map template.
- A Pangaea map generator, where all players are on a single large continent.
- An archipelago map generator, where players are scattered in a tangled mass of small and large islands.
- The notion of ocean regions, which include things like small and large islands and small archipelagos.
- Some sensible way of displaying farms.
- The ability to fortify.
- The ability to pillage.
Risks and Mitigation
- I've already expended a lot of thought on region balancing. While I've found a decent number of ways to increase a region's score, I've found very few tolerable ways of decreasing it. It's entirely possible that there aren't adequate solutions for balancing regions, which might make it very difficult to balance the map as a whole.
- There's a couple of things I can do to resolve this issue. One is to improve the way scoring works. Right now, I'm scoring based on the hypothetical maximum yield of a particular cell assuming all technologies have been researched. I might consider modifying score by considering the yield of a cell at different ages and then taking all of them into account. That'll decrease the value of rivers and fresh water, since fresh water is only useful after Civil Service has been researched. Balancing across an entire homeland might help resolve disparities, as well. If a homeland contains low-score and high-score regions, they might balance each-other out. I might also consider being more tolerant of imbalances. Increasing the range of per-cell scores a region/homeland can have might be the way to go, though that feels like something of a cop-out.
- The way in which I create continents is unpredictable enough that there's no clear solution for interjecting oceans, especially not if I want to ensure deep-water separation between regions of the map.
- I still think my original plan for creating ocean separation will at least help ensure the presence of two continents. I'm sure it'll be a lot more complicated than I'm thinking now. Another thing I can try is to create a sort of dividing line of open ocean across the entire map. That's a pretty heavy-handed way of guaranteeing continent separation, but it might work where a more nuanced solution fails.
- Map generation has not been tested on multiple map types yet. It's entirely possible that the solution I've come up with will be woefully inadequate for pangaea and archipelago maps.
- I'm not particularly worried about pangaea. The current configuration periodically produces pangaea continents and they look fine. I'll need to add some way of bringing civ starting locations closer to the center of the map to guarantee that continents connect to each-other, but that shouldn't be too difficult. And I bet I can make archipelagoes work by creating a PercentOfHomelandThatIsWater field and then also pulling in coastal cells during homeland creation. Or I could relax the adjacency requirements during homeland creation so that homelands are not contiguous blocks of land cells. I've got options that are fairly easy to try and don't disrupt the rest of map generation. Except possibly resource distribution. I might want to change resource weights so they're more aware of the cells in a particular region. That'll help resource distribution select ocean resources more often on archipelagoes and left often on pangaeas.
- It's not entirely clear to me what a balanced map ought to look like, nor how exactly balance plays into the experience of the game. And I can't exactly use rigorous playtesting to figure any of that out.
- I could look more deeply for design insight on Civ 5. A post-mortem or an analysis by some of the developers would be the best case scenario. More realistically I can take a look at Civ 5's map generation and see how it tries to balance regions. It might be that I'm overthinking things, or that I'm valuing certain things too highly. Maybe food and production aren't as valuable as I think they are. Maybe balance isn't as important to Civ 5 as I've been assuming. Maybe I'm overvaluing fresh water. Looking at generated maps might give me some insight, though I won't be holding my breath waiting for it.
- It's not clear to me how extensive island generation system should be. Right now islands don't look particularly good, but it's not clear to me that they're particularly important or that a 3-cell island will ever look particularly compelling.
- Islands are a very low-priority part of map generation. The standard continents map doesn't even produce small islands every time. There's not a lot of sense in worrying about it much until I've addressed every other issue.
Review
I began the sprint with a bunch of work on yield balancing. It turns out that my cell scoring and yield estimation code was filled with bugs that took some time to work out. I ended up properly accounting for vegetation clearing, reorganizing how cell yields are calculated, and adding the notion of technological ages to make the yield estimation more accurate. I also ended up putting YieldEstimator under unit tests, something I should've done a long time ago, I think.
After yield estimation, I spent some time working through balance strategies. I changed balancing from a per-region to a per-homeland affair, added strategic resources as valid rebalancing tools, and fixed some issues with resource selection during balancing that made things a lot better.
Next I tried to improve continent generation. I developed a simple but effective solution for ensuring continent separation in continental maps. I also added both a pangaea and an archipelago template. The Pangaea I managed by fiddling with the land percentages and adding center-seeking behavior when carving out homelands. Archipelagoes took more effort, but I managed to get a decent first approximation by allowing homeland growth to grab map sections not adjacent to the existing homeland. The current archipelago behavior generates some percentage of its land in a contiguous blob (forming large islands for each civ) and then scatters the rest more haphazardly to create smaller islands.
I resolved some smaller problems with luxury distribution that were preventing many types of resources from appearing.
I also started work on a farmland solution, since that's going to be an important component of the game's design. I ended up with a reasonable first approximation of farmland for flat terrain but couldn't figure out anything decent for hills. Exploring the farmlands issue has made me realize one of the limitations to my current map triangulation strategy and makes me rather want to change it.
Retrospective
What went well?
- I came up with pretty reasonable solutions for archipelagoes and pangaeas that didn't force some substantial and elaborate modification to my map generation logic.
- I vastly improved yield estimation and resource balancing, to the point where different homelands might actually be balanced against each-other.
- I didn't try to create overly-elaborate solutions for archipelagoes and pangaeas. Instead I opted for pragmatic solutions based only on the immediate requirements of the problem, which made creating those map types a lot easier.
What could be improved?
- I'm starting to run into the limitations of my current triangulation strategy. While there's no way I'm going to rebuild my terrain generation, I definitely should not use my current strategy in future projects.
- While I can't add useful unit tests for large chunks of my map generation logic, there are definitely some classes that ought to have them. I should endeavor to build out test fixtures for these classes.
- I need to come up with a completely new strategy for creating farmland. My current solution will never apply properly to hills. Ideally I would add some sort of terrain texture and use the Terrain shader I already have, though I have a hard time imagining how that'd work for terraced surfaces, or how I'd get it to create sharp boundaries.