[Dev] 0.1 "Babylon" Progress Thread

Hmm... there are a few undocumented bytes and shorts in the Apolyton TILE documentation, including two bytes immediately following the image/file bytes for the base terrain. It wouldn't be that surprising if it were there, the more surprising thing would be that it hadn't been figured out 15 years ago.
 
Well, it ain't there. I thought I had some candidates, but I have my nifty Lua analyzer going, and there is no correlation. I can clearly see the pattern with the base terrain graphics...there are just a handful of files and 81 tile indexes per file. No dice on the mountains in particular.

I guess I can rationalize that...it's important to have more variety with grass and ocean in particular because there are large swaths of it visible, and tile patterns would star to be obvious. With overlay terrain, not as much, although there are some damn large jungles. It's a busier image, though.
 
I took a peek at the decompiled code. The sprites for mountains, hills, and volcanos are determined by the tile drawing code (i.e. not stored) pseudorandomly based on the tile index, map seed, and of course the surrounding terrain. If we want to replicate the appearance exactly from the base game we'd have to replicate its PRNG, which wouldn't be too difficult since it's a simple LCG, but I don't think it's worth our time right now. Whether or not a mountain is snow-capped is stored in the tile object as a bit flag.
 
Ah, the seed is part of it. No wonder I could never figure it out back in 2010. I tried all sorts of ideas based on tile index/coordinates, and could tell surrounding terrain was part of it, but never thought the seed might be a factor. I knew it had to be replicatable, though, since it didn't change on game load.

I agree that it isn't worth our time to try to replicate it now. I'm going to implement the surrounding terrain so we don't have entire ranges appear as a bunch of freestanding mountains, and snow-capped, but not worry about an exact match. So far I haven't received any complaints about the lack of an exact forest/mountain match in my editor in the past decade, either, so "close enough" might really be close enough.
 
Remember the borders bump up over where the mountains and hills do, so ideally the "humps" location should be consistent between the borders and hills/mountains. Maybe each has the same relative tile index...that would be handy, but I don't know if it actually is that way.

And now I'm wondering how they track how not to draw humped borders on flat lands...there are some weird checks and calcs going on in Civ3.
 
I had not remembered that! And it appears I never implemented it in my editor, so there's not a reference implementation I can refer to. But looking at the file (Art/Terrain/Territory.pcx), it looks like there's simply an elevated version for each of the four potential directions, so in theory it may well be as simple as seeing if the neighboring tile is hilly or not - something that I've added utility methods for in my MountainsAndHills branch.
 
I went ahead and merged part 1 of mountains and hills, as seen in post #57. And have now started on a part two branch, which so far has hills and mountains connecting into ranges of hills/mountains. As part of that, I informed tiles who their neighbors are. This leads to some pretty readable code for figuring out which graphics to use, something that I didn't have when I first wrote my editor, and even today it's not as readable as the new C7 code.

Thanks to the new load-from-a-SAV feature, I've also been able to load a save that has volcanoes, and will be adding those, and likely snow-covered mountains. Maybe I'll even get ambitious and add forest/jungle mountains, although I may wait until forests and jungles are on the map before doing that.
 
Mountains and Hills Part Two is off to a good start. Volcanoes and snow-capped mountains are now supported.

Snow-capped mountains lead to some interesting thoughts about terrain types. For now, I've implemented it as a flag on a tile, like it is in Civ. But it got me thinking about how Civ has a lot of sub-types of terrain, which aren't really terrain types, but kind of are.

Snow-capped mountains.
Pine forests.
Bonus grassland.
Landmark terrain of various types.

If you ask how many types of terrain Civ III has, the traditional answer is 14 (or 12, without Conquests). But it's more complicated than that in reality.

I am thinking it may make sense to make the various sub types (or perhaps most of them?) first-class citizens, but am not sure about that now. It might only matter in our legacy/compatibility mode, if we wind up with a flexible/extendable terrain system. But I don't want to punt on these thoughts because we might someday have such a system - if nothing else, graphical questions around base terrain mean legacy/compatibility mode for terrains may be the default for some time.

Most important paragraph: Treating them as first-class terrain types could make our code more logically consistent (just look at the base/overlay terrain type for info, don't have special cases around the various sub-types). This could be especially true for Landmark, where yield, movement cost, and defense bonuses can differ, and accounting for that with only the original 14 top-level types would complexify our code.

From a modding standpoint (even within a legacy framework), it also would open up some doors to allow custom data for snow-capped mountains and pine forests. Wouldn't it be cool if you could build roads on regular mountains, but not the snow-capped Alps? Or set the movement cost to 9 so it's really expensive to build on them, due to the harsh climate? I've already been knocking down Landmark doors in my editor, and this seems like the logical next step.

------

It also made me think, should we keep the base/overlay terrain concept? I'm more in favor of it than the sub-terrain-type system though, since it does give some legitimately useful information such as which terrain type you'll get when you clear a forest. I think it would be more complex to get rid of it, as then you'd have a proliferation of combinations at the top level (forest on plain, forest on tundra, forest on grassland, etc.).

------

Another thought that's too early for its time, but I'll write it anyway. There's been some talk of extending my editor to create C7 scenarios. That's about 20,000 leagues in the future, and there would be a lot of logistical questions (teaching it to speak C7 formats as a second language, for example), but breaking out snow-capped mountains and pine forests is a good example of an area where it would be fairly easy to extend it to treat them as separate types, and allow modding their attributes. We wouldn't even have to teach the editor how to speak C7 - it could save the results as an BIQ with additional terrains, which Civ 3 could not utilize, but C7 could.

(For now I'm thinking that if we get to the point that C7 modding is viable, having native tools likely makes the most sense. An extended Civ III editor likely only makes sense as an intermediary stepping stone, for when we can get some benefit fairly quickly, but native C7 tooling is still a ways out in the future. That view could change completely as we learn more and evolve C7, however)

-------

Finally, there are a few graphical variants that could be considered sub-types, albeit not as prominently as the ones I mentioned above. Jungle and forest mountains and hills. The game treats them the same as "regular" ones, but that wouldn't have to be the only option. An additive format, like the SMAC (?) one discussed recently, may well treat them differently.

I'm less inclined to do that for now, due to the lesser prominence of those in the Civ III mindshare, but it's worth considering.

There also are non-existing variants that could be their own types in theory. Why are Hills always grassy, even on the tundra or in the desert? I think we can safely chuck these on the "features to look at if we get a playable game" wagon, but they are interesting IMO, and the more I think about them the more I see the appeal in an alternate system based on elevation, temperature, and vegetation.
 
Last edited:
As far as whether or not the variants are first-class citizens, my first answer is no. Because in the game engine there is no difference between a snowy mountain and non-snowy mountain, rules-wise. And then you'd have to mark wheeled units to be unable to go in mountains and snow mountains, for example.

From a modding standpoint (even within a legacy framework), it also would open up some doors to allow custom data for snow-capped mountains and pine forests. Wouldn't it be cool if you could build roads on regular mountains, but not the snow-capped Alps? Or set the movement cost to 9 so it's really expensive to build on them, due to the harsh climate? I've already been knocking down Landmark doors in my editor, and this seems like the logical next step.

Ok, now you're talking about first-class terrain in my mind. If the rules can be different, then yeah that's a different terrain type.

That said, I can also imagine a variable terrain type. Mountains, but their output (and display) varies with temperature. Clearly some temperature is calculated at least during map generation to place tundra and decide whether mountains are snow capped and if there are pine trees. I didn't see anything in the save data that looks like temperature, wind, or rain/moisture maps, so I'm guessing it's all modeled in map generation and the only vestige is the terrain type.

Anyway, I expect we'll want to model at least humidity and temperature, and why not keep that data in the map (or calculate it on the fly like SMAC does if you raise or lower terrain), and then the terrain can behave and/or appear differently based on temperature or humidity? I think that can me moddable, that a FoP output and/or display appearance is a function of temp or humidity.

It also made me think, should we keep the base/overlay terrain concept?

Absolutely not. My thought is a configurable number of layers, and Flintlock's ILooseLayer seems to be a very good base for this. I think the modder should be able to add one or more sky layers for cloud cities and other sky objects, and maybe even they block enemy aircraft from passing through but ground units can go under...all moddable.

Now for the Civ3 compatible mode...well that's interesting. The display is two-layer, but the effective logical terrain isn't. And I just realized that ILooseLayer is display-only. Well, I won't try to architect it all right now, but that's where my mind is: multiple logical layers possible. And now I'm ... well now I'm lost in thought and it's al getting jumbled up in my head, because my multi-logical layer idea and the layering of Civ3 media are actually kind of different topics I'm mixing up. No never mind that for now.

But yeah, I would love to see possible layers like underwater, surface, air, and maybe orbit possible to mod in, and units and cities and whatnot might exist in only one of those or more than one...something like that.

There also are non-existing variants that could be their own types in theory. Why are Hills always grassy, even on the tundra or in the desert?

Yeah, Civ4 had plains hills and desert hills if I recall correctly. Again, I think that could be handled by a single first-class terrain type that varies based on environmental factors or as separate terrain types.
 
Interesting, I hadn't thought about how things like wheeled units not being allowed in jungles/mountains may be complicated by adding e.g. snowy mountains as a top level citizen.

What about the landmark terrains, where the rules (in terms of yields, though not flags) already are different?

Does your vote of no base/overlay apply to the legacy/Civ3 mode, or just the desired end stat? I am realizing there are multiple endpoints we could be discussing - legacy/Civ3, legacy/Civ3 with some more modding (e.g. pine forest customizeability), and whatever we wind up at in the end. We'd probably have to figure out an architecture for that end state to move the legacy/Civ3 mode away from it.

What is a FoP output? I am not remembering what that acronym means currently.

My thinking last night wound up at it being desirable to have overlays for hills/mountains as well (a hill with forest, for example), and probably some sort of temperature scale available more widely, e.g. snowy hills, arid hills. But that is still beyond the basic Civ3, so it's probably thinking too far ahead.
 
I know almost nothing about landmark terrain. I didn't know it could have different values. FoP is factor of production, so tile yield: food, shields, commerce.

I would like for "legacy/Civ3 mode" to be more of a standalone mod to C7 than, say, a different engine. That may not be possible or practical, but when I start coding I try to keep my pie-in-the-sky ideas in mind and try not to block them as opposed to just making it like Civ3 first. But that's me, not how everyone else should do it.

I can see the "thinking too far ahead" issue, but I also think in terms of "Civ3 graphics overlay is not a core feature of the engine, so the file ID and tile index should be an extension and not core to the engine," which is why I put that in a sub-object ExtraInfo in the Tile instead of alongside terrainType, xCoordinate, and yCoordinate. For right now ExtraInfo is one class definition, but in the Json serializer we could call that an object type and then define a type descriminator so we can load different class definitions based on whatever pluggable we have there. I haven't thought far enough ahead to figure out how we might define classes in a mod, but now that I think of it, it almost has to be dictionaries/associative arrays.

Anyway, I don't think that diversion broke the existing code or halts progress, but it does allow for the idea that ExtraInfo is pluggable and not core to the game engine.
 
More interesting! I had not yet noticed the ExtraInfo class. A few ideas are circulating in my head simultaneously, so I'll try to keep them in separate paragraphs as I write.

One is that we appear to have been taking different approaches in terms of future-proofing. I've been generally making it like Civ3 unless there's a way I see that doing so will box us in. In part that is because it's what I know, in part it's because I suspect that will be a difficult enough task, and in part it's because I don't know what else exactly we would be working towards. We all have pie-in-the-sky ideas (and come up with more ones as we go), so I don't know which ones we'll wind up using eventually.

Another is that the "legacy/Civ3 mode" reminds me of the Windows NT architecture, and how it had several different modes it could present itself as. One was the Windows mode, which is what we all know. Another was a Unix mode, which provided POSIX compatibility and allowed Microsoft to sell NT into markets that required POSIX compatibility. A third was the OS/2 mode, which allowed Windows NT (through 2000) to natively run some OS/2 applications. I believe the same underlying concept us used in the new Windows Subsystem for Linux (WSL). But what it means is that the Windows API is not really the native API of Windows NT. There's a lower-level NT API, which the Windows, Unix, OS/2, and likely WSL layers all use, and which isn't publicly exposed to programmers outside of Microsoft (though some have figured out how to use it). But what made me think of it is the concept of having layers of what's considered core to the engine. File ID and tile index are core to Civ3, but they may not be core to all ways in which C7 presents itself to the user.

It's probably apparent by now that I'm often the rein-in-the-ambition, will-be-happy-if-we-can-match-Civ3 person on the dev team. So I'm a bit torn. If we try to make everything flexible, I'd argue we would be, to use a term a manager of mine once used, gold-plating the project - basically, over-engineering it so it could support possible future extensions that we don't really have any way of knowing whether they will ever exist. Some later peers would use the term YAGNI (You Ain't Gonna Need It) for the same basic concept. IMO, the challenge is knowing what it worth planning ahead for and what isn't, and I tend to lean on the side of past attempts along this line haven't met their ambition, and thus exercising caution.

But sometimes it is worth architecting a little bit ahead. I remember one time with a real estate project where we asked, do we need to support mixed retail/apartment complexes, and the business partners said no, we're never going to do that. So we didn't built support for that into our database architecture, and of course six months later they wanted mixed apartment/retail complexes. It would have saved us a lot of time and effort to make the database a little more flexible up front. There was another, smaller example on that project where our business partner told us to do something that seemed quite counter-intuitive, but insisted he was sure that's how it should be done. I spend a few extra minutes and made it so that if he reversed his decision, we could reverse the behavior to what we thought was intuitive with one line, with comment above it saying, "if business changes their mind about x, reverse this conditional". Sure enough, nine months later, our business partner asked, "why'd we ever do this like we did?", and our analyst showed him that he'd requested it that way, and I changed it to the new way he wanted it almost instantly with a one-line change. Of course, this was all after the analyst and I had been there quite awhile and knew the business domain and our business partners well enough to be able to read fairly accurately what was likely to change and what was not.

This may be an area where some input from @WildWeazel may be helpful in determining the appropriate level of planning ahead for potential extensions, both in the terrain case and more generally.
 
Thinking about it some more, I realize that a lot of what my peers and I were doing at the software consulting company I worked for was figuring out what the appropriate level of design/architecture/flexibility was for each project. Being good at writing code was also important, of course, but finding that balance was one of the things that set that consulting company apart from the typical company that has software. It's probably more common, historically at least, to under-architect, and wind up with a spaghetti code mess. But I've also seen overly abstracted corporate code where it was technically extremely flexible, but it took new developers forever to wrap their heads around it because it was so abstract; my team re-wrote one such project to be less abstract due to that problem.

The trick is being able to figure out where that balance lies. And experience in the domain helps a lot. I was reading an interview with Soren the other day, where he said,

Soren Johnson said:
I always knew that Civ 3 was... well, it was a cool and crazy project which blew up half way through. It was a cool game which was great to work on – and my first major project, basically – but we could make a huge list of all these things we'd want to do better if we could do it a second time around.

Similarly, in the Windows NT example above, Dave Cutler (the main architect) has designed operating systems before at VAX, so he had experience with what did and didn't work so well.

We're probably not going to hit the sweet spot, unless someone has far more experience designing and architecting games than they've let on. Failing that, we'll best apply our knowledge from other parts of software development, but likely under-design some areas and over-design others. At least we ought to get better as we go, and if we're fortunate, we might even be close enough to refactor in changes rather than have to start over.

If we're not that fortunate, well, that's why it's called the Prototype.
 
There's the motivational angle, too. My drive is not to make a Civ3 with a 257x257 map, 33 civs, 513 cities, (max resources)+1, etc.. I just enjoy tinkering with stuff and learning tech. For me Civ3 or whatever is just the environment in which I do it. Which is why I've been posting stuff in C&C for years with code in Python, Go, JavaScript, C#, and some others without really ever having a complete thing someone else wants to use.

Actually duplicating Civ3 sounds downright boring and pointless to me. Making a thing that can act very much like Civ3 but do a lot more sounds a lot more interesting. So yeah, I'm mentally architecting the thing and how Civ3 can be emulated by it.

Again, I'm not saying mine is the way. This would never be a finished project if it were just me working on it, and I'm not going to insist things or any particular thing go "my way", and it's fine if they don't. And don't let my crazy ideas slow or stop anyone from coding.

So if I go on about pie-in-the-sky stuff it's just enthusiasm, not arguing or persuasion.
 
Inspiration and Enthusiasm are what makes Creation happen and "Brain Storming" with others doing the same thing, all towards a mutual Goal, is indeed exciting :thumbsup:

The different strengths of individuals in a Group are synergistic and Great Things are discovered, learned and come from those differences.

I think this Group is much like playing a Civ Game in that there is a desire for "Just One More Turn" :clap:
 
Yeah... thinking about the motivational angle, my motivation has been that it's been fun (Vuldacon, you're right that there's a "Just One More Turn Feature" angle to it), but I'm also a goal-motivated person. And so far the goal in my mind has been summarized by WildWeazel's "We're going to create our own Civ3" in the reveal. Better in various ways, of course, but better how is kind of nebulous in my mind, so I've been motivated more by the Civ3 part of it.

I'm also traditionally a "build a complete [or at least usable, if never really complete] thing" type of person, and am that odd developer who is perfectly happy to stick with whatever unsexy technology I know if I know how to build something that will solve the problem I'm trying to solve in it. You could even say I don't really enjoy learning tech, unless it lets me solve new problems or solve them in a significantly better way. Which is something that's taken a while to come to terms with in a career field that is always talking about learning new tech. I don't really enjoy it for the sake of it, although a lot of other people in the field do.

Which can indeed be complimentary. We may not be coding in Godot, or even writing C7 at all, were it not for Puppeteer's earlier explorations and experiments in Godot that showed things like animations and tile maps were possible, for example.

My main concern is that we might wind up with a fragmented architecture where we have two to four ideas of how to do things, and implement them in two to four ways. I suppose it goes back to Oz's concern that we might get ahead of the design truck if we just jump in and start the coding engines.

I wonder if we might learn some about good/bad decisions in implementing a more customizeable system by studying Civ4, and what it exposes via XML, Python, and C++ (DLLs)? I never dove into Civ4 modding as much as Civ3 (and that's probably true for the majority of the C&C regulars), but it must have been an intentional decision to design it that way. And maybe it would make sense for us to have a similar system where both Lua scripts and .NET DLLs could be swapped in depending on what level of changes are desired.

All in all I'm left thinking it might be a good thing this discussion came up before the train rolls too far into the Civ3-like station. I don't have a good idea of which mechanics should be in the "core" and which should be in the "civ3" (early thoughts are quite a bit might wind up in the "civ3", although we also might want a lot of them longer-term). But it has me thinking about more flexible options than I had been before.
 
More specifically on the "Babylon" world map task:

I've added support for mountains, volcanos, and hills with jungles/forests. I realized this is getting a little bit ahead of things, as we don't have any jungles or forests yet, so the new variants of mountains/volcanos/hills cannot yet appear.

So I think I'm going to merge in the Mountains/Volcanos Part II branch, and switch focus a bit to forests and jungles. Eventually there will be a part III for mountains/hills, with landmark terrain, or maybe that will be covered as part of a landmark branch in general. But at this point landmark feels like it should be in the future, once more base terrains are present.

This also may be the point at which I refactor our TerrainType support so that we're importing the terrains from the SAV rather than hard-coding them.

Edit: Just checked the project board, and I see Puppeteer has Enabled Modded Terrain in progress. I'll leave that part as is for now and focus on forests. Or maybe studying Civ4, or some other part of the world map. Or maybe config file/preferences so we can have the main menu music on by default for our release builds but turn it off locally.
 
Last edited:
Just checked the project board, and I see Puppeteer has Enabled Modded Terrain in progress.

Oh hell I forgot about that. That is *only* with respect to reading alternate Civ3 graphics, e.g. if you create a winter terrain game it loads from civ3ptw\extras\winter terrain . I'm hunting for the right paths in sav and bic, and for some reason I'm getting it wrong.

It involves nothing with the actual map code, just ensuring relModPath gets passed on, and that the media mod path is pulled from the Civ3 sav/bic properly. I'll see if I can merge my not-quite-working-as-I-want-yet-but-not-actually-broken changes later today.
 
Ok, that's merged and the task is complete. It's not more broken than it was before, but neither is it doing what I want yet. The remaining work to fix it is either identifying where the real path is in the save and/or getting the search order correct. (Or something to do with how C# is handling relative paths; e.g. /path/to/civ3/Conquests/../civ3PTW/Extras , but as far as I can tell that bit works as expected. It's just that I haven't yet figured out why e.g. "Brian's Watercolor" is in "Warpstorm Watercolor Terrain" (or some similar odd juxtaposition) folder and how we're supposed to know that from the info provided.)

Apparently I hadn't coded in 4 days which surprises me a little, but obviously I'm derailed at the moment.

TL;DR: Any remaining work isn't in the C7 map code.
 
I am not a Programmer and it might well be Good to look at CIV IV, However, I believe that would end up a dubious endeavor because Civ IV is, among other things, bent on Different Graphics that have altered the Programing.

My "vote" is to stick with understanding how to implement what is needed to not only duplicate CIV III/Conquests but be able to add/change what is wanted.

There will be "Stumbling Blocks" along the way but don't lose sight of the Goals. By that I mean look into anything you think will help with understanding and the approach to programing but keep in mind the Bottom Lines of what is wanted.

We do not want CIV IV but IF there is any Programing there that would help, by all means use it...
This is all still in its infancy and I think I understand the issues on an individual basis for you programmers concerning what and how to go about performing the tasks needed.

Relax, Look into any and all things for yourselves, take your time to be certain and experiment to find the way.

It will be Great... just don't "go off on the deep end" before seriously ready from knowing what the Best way is and what will work best.

There are some differences between you programmers and that is Good... perhaps each of you could look into what you think and after doing so, compare Notes and discuss it all... at least that would help consolidate and help you guys be in agreement.

It is all Good and I am happy to see you are all working toward the Goals..

This seems much like the beginning where individuals were not sure what to do and were looking into what they could do from their perspective. Very Understandable.

I think it important at this juncture that each of you programmers look into what you think and know, then compare notes and results so each of you can "be on the same page" and work together better.

That takes time and well worth it so relax and go on and do as you think is best.

I seriously do appreciate your efforts... it will all pay off in the end and you are all, Great :goodjob:
 
Back
Top Bottom