1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Did I Just Find The Source Code For Conquests???

Discussion in 'Civ3 - Creation & Customization' started by Ozymandias, Apr 18, 2020.

  1. Ozymandias

    Ozymandias I saw the Great Library burn.

    Joined:
    Nov 5, 2001
    Messages:
    9,476
    Gender:
    Male
    Location:
    The lone and level sands
    OK, One & All - Most of you know I'm ill, with (mercifully, for now) my main limitation being a lack of energy, while having savage insomnia at the same time. So, between 3 AM to 5 AM EST, I might be "found" wandering around the internet ... And sometimes d/l-ing items without bookmarking where they came from. That includes 2 .zips containing the following (and, yes, I do see that there's a "conquests.exe" in the 1st one) -

    Conquests.zip-1 of 2.jpg
    Conquests.zip-2 of 2.jpg

    Is this old news, or did I stumble across something helpful?

    -Oz
     
  2. Civinator

    Civinator Blue Lion Supporter

    Joined:
    May 5, 2005
    Messages:
    6,607
    Gender:
    Male
    Last edited: Apr 19, 2020
  3. Puppeteer

    Puppeteer Emperor

    Joined:
    Oct 4, 2003
    Messages:
    1,263
    Location:
    DFW, Texas USA
    I think @Civinator is right, you found the source for Conquests, just not Sid Meier's Civilization III Conquests. conquests_source.txt is just a readme on dependencies and how to compile, but there is code under Vision/ . Vision seems to be a 3D game engine.

    Seeing "Terrain.h", "World.h", and "Resource.h" almost made me double-take, but if you think about it, these words and "Conquests" are pretty generic and would apply to pretty much any map tile strategy game. Upon further looking at just the filenames I doubt this has any compatibility or interoperability with *our* c3c at all.

    Edit: Also, the dll file names are clearly things that civ3 wouldn't have used. Ogg is an open-source audio library, vorbis is an open-source video library, QT is a graphic/UI widget library, SDL is a graphics tech CivIII (which is DirectX) wouldn't use...and so forth and so on. I recognize pretty much all those dlls.
     
  4. Ozymandias

    Ozymandias I saw the Great Library burn.

    Joined:
    Nov 5, 2001
    Messages:
    9,476
    Gender:
    Male
    Location:
    The lone and level sands
    Yep, @Civinator is right: conquests.sourceforge.net. Nevertheless, the coding scripts for the AI are quite readable (and I am decades past the hands-on coding phase of my career.) I know there's very limited room to "inject" code into C3C - and, for what little I know, the various patches & editors might have already utilized it - but I'm curious to see if there are any interesting logic pathways, either for that, or on the off-hand that it triggers any notions of new ways to utilize the tools we already have at hand.
     
  5. Puppeteer

    Puppeteer Emperor

    Joined:
    Oct 4, 2003
    Messages:
    1,263
    Location:
    DFW, Texas USA
    As far as I know Antal1987 is the only one who actually hooked into the actual game exe with new code.

    I think messing with the c3c AI would require two very difficult (or worse) things:
    • Understand what the code does / how to change it
    • Understand what "memory" for the AI there is in the save file
    Or maybe those two things are hopelessly intertwined.

    I used to assume the AI had no memory and just happens to appear cohesive because the game doesn't change a lot from turn to turn, but now I think it clearly can follow some sort of plan or direction for quite a few turns. And in fact when I realized the "they refuse to speak to your envoy" counter appears to be a countdown timer that triggers again after they make peace, I think this is actually a cool-down timer to prevent the AI from breaking or making peace over and over again.

    But beyond that I have no clue where it's "this ship is headed for an attack on <civ>'s core" memory would be.

    I know I looked for the AI attitude, but there doesn't seem to be a furious/annoyed/cautious/etc. value; it seems that there is a huge diplomacy table that counts past attitude-influencing actions, and the "furious/annoyed/cautious/etc." must be a value derived from those and not stored directly in the data.

    So no telling where other AI strategic memory would be or what it would look like. Well, mostly; it's *probably* in the LEAD section.

    But now that I think of it...clearly sometimes the AI intends to attack but hasn't declared yet. Sometimes an experienced player can spot this by suspicious troop movements and an unnaturally friendly attitude for the situation. (Polite Zulu or Mongols, anyone?) And I've definitely recently seen a civ target a particular city for a "sneak" attack with multiple unstacked units several turns in advance. So that means I should look for unit IDs, city IDs, and leader/civ IDs showing up in the LEAD section (or anywhere else an "AI memory" might be). *If* I were to try to figure that in particular out, which I'm not sure is something I'd actually do.

    On the other hand, maybe I'm thinking too big. If we could just make the worker AI not stupid, that would have a huge impact on the game. I hadn't really given the worker AI much thought, but now that I am, it may have some form of memory, too. I don't recall all AI workers heading for the same tile, so they must remember their current target and avoid stacking if there is much to do, and that should be in the SAV somewhere, probably in a UNIT section? (rhetorical question)

    Edit: I should add that—in my mind—the SAV file data is just a serialized dump of the in-memory data, so knowing where it is in the SAV kind of leads you to where it is in memory and vice-versa. I could be wrong. I don't think the in-memory is in the same serialized structure and offset, but some translation should be possible I think.
     
    Last edited: Apr 19, 2020
  6. Ozymandias

    Ozymandias I saw the Great Library burn.

    Joined:
    Nov 5, 2001
    Messages:
    9,476
    Gender:
    Male
    Location:
    The lone and level sands
    Three things I've noticed about Workers: (1) They never clear Pollution (2) They never cut down trees (3) they never plant trees. Plainly, they do lay down roads and railroads pretty much everywhere. I've yet to have a chance to look at @Civinator's evidently brilliant work re: (among many other things) his "Worker Armies," and how they behave.
     
  7. Puppeteer

    Puppeteer Emperor

    Joined:
    Oct 4, 2003
    Messages:
    1,263
    Location:
    DFW, Texas USA
    Huh. I suppose you mean a fully-automated worker for a human-controlled civ, because I quite recently saw AI workers planting trees in tundra. But then they didn't really have anything else to do there and were separated from the core of their empire. And I think I saw AI workers clearing up volcano "pollution" recently, too. And, of course, there's an advanced unit command to specialize automating workers on clearing pollution. And another thing, clearly the AI-controlled civs chop trees, too; that can be seen from CAII or my CIA3 which shows which tiles have been forest-chopped.

    But I'm going to assume you're right for a fully-automated worker for a human-controlled civ, and that may tell us something...I think. I'm assuming there aren't two worker AIs, one for humans and one for AI players.

    So I'm deducing that there are a few worker worker directive plans, and either the human or AI can choose between a few of them. That would be an AI choosing which worker AI to employ. Interesting. Very interesting. That might give a hint as to why workers are so stupid: perhaps they don't understand the bigger picture *at all*. The leader AI may understand they need more road connectivity in general or have nothing useful to do besides plant trees and switch a worker's automation type. But that's just conjecture. (And it's not clear to me why/how the AI civ would do it for them and not for the player as I later conjecture that maybe differentiating between AI and human's automation is not much of a distinction.P

    So there must obviously be a value that shows which automation the worker is using or if it's manually controlled. Then I conjecture there is probably a tileID nearby and maybe an improvement flag to tell it "hey, you're heading here to do this, don't forget next turn". And...something in the leader section referencing workers? By unit ID? Not so sure, actually.

    And I may be overthinking the difference between human and AI players. The game *always* has an opinion on what you should build, how you should move, etc., so that almost must be just another the same AI that suggests things unless and until you let it take control via "automate" or turning on a governor.

    In any case, saving, changing a worker's automation assignment, saving again, and comparing the difference between the saves could be informative. But I'd have to be able to parse units which I haven't done successfully yet. (Not that I've really tried...they were always lower priority to me than tech and cities, and I only just recently was able to parse tech.) Once one figured out where that info is, it would be really interesting to see how/when the AI civs change automation, if that's how it works.
     
  8. Ozymandias

    Ozymandias I saw the Great Library burn.

    Joined:
    Nov 5, 2001
    Messages:
    9,476
    Gender:
    Male
    Location:
    The lone and level sands
    A few of us started explorations along these lines, years ago. I began with a simple question: "What unit will the "AI" build next? That one questions took up hundreds of tests and posts, begun by me, then continued, in far greater depth, mostly by tom2050. I've been deep-diving into this - and other - similar long ago threads before getting too deep into designing Terra Fantasia. The tentative title for that thread (1 -2 weeks time) will, I think, be, "C3C Combat Revisited; Unit Design Theory; And AI Unit Builds." Another thread will cover a couple of staring-us-in-the face, but somehow unnoticed, doozies (technical term.) Stay tuned.
     
  9. nick0515

    nick0515 Fantasy World Builder

    Joined:
    Jan 5, 2008
    Messages:
    2,509
    Gender:
    Male
    Location:
    New Zealand
    Interesting discussion! The dream of a slightly smarter AI lives on! :D
     
  10. WildWeazel

    WildWeazel -- Turns to Completion

    Joined:
    Jul 14, 2003
    Messages:
    6,875
    Location:
    %CIV3%\Conquests\Scenarios\
    Now you've got me thinking... with today's technology it would be possible to use machine learning to train your own AI to read BIQ/SAV data and play hotseat.
     
  11. Puppeteer

    Puppeteer Emperor

    Joined:
    Oct 4, 2003
    Messages:
    1,263
    Location:
    DFW, Texas USA
    It's a fun thought. I'm not sure it's impossible, but I doubt it's practical.

    Well...I mean in the common trope of giving a neural net a set of controls and a reward function and just letting it randomly figure things out. There are just too many contexts and controls. Each unit, each city, each government type, each terrain layout....

    But I think it might be plausible to make smaller AIs with specific task goals that can be measured, like what worker actions to take next to optimally improve a city's production. Well, basically any individual decision the civ3 AI makes might be improved with some neural net AI, but a human would still have to featurize the inputs, decide what controls the AI can twiddle, and set the reward parameters.

    The teaching would also be difficult. I guess you could have it learn against the civ3 AI. Otherwise you'd need every living civ3 player playing against the new AI or at the very least logging saves and actions for the AI to learn from. Then at some point you could have it play itself.
     
  12. WildWeazel

    WildWeazel -- Turns to Completion

    Joined:
    Jul 14, 2003
    Messages:
    6,875
    Location:
    %CIV3%\Conquests\Scenarios\
    Oh it's certainly impractical. The learning space for a 4X is enormous. But technically it could be done. It wouldn't necessarily have to be a trained neural net though, it could be a data-driven decision tree or something of the sort, hence the file reading as input. But unless Civ3 has some great accessibility features I'm not aware of, it would be really difficult to "teach" it to interact with the screen.
     
  13. nick0515

    nick0515 Fantasy World Builder

    Joined:
    Jan 5, 2008
    Messages:
    2,509
    Gender:
    Male
    Location:
    New Zealand
    Now that is a cool idea! I haven't the technical skills but would be fascinated if someone did use machine learning with Civ!
     
  14. Puppeteer

    Puppeteer Emperor

    Joined:
    Oct 4, 2003
    Messages:
    1,263
    Location:
    DFW, Texas USA
    Hmm...it might be more practical to code a new civ-like game with (initially) simpler rules. Like maybe you can only build settlers, one type of military unit, or a "victory building" / "spaceship part". And it's an always-war scenario. And maybe all tiles are equally productive.

    And maybe I'm being too pessimistic on the larger trainable AI idea. The AI doesn't have to understand everything; it just has to make a good "next move". Go (the ancient board game) AI's can't and don't understand long-term future states, but they manage to make a good next move.

    My intuition is that it would take several trainable AIs:

    • City production
    • Military unit
    • Settler
    • Maybe an overlord AI which could influence the other AIs...I'm thinking it would convolve the map and figure out where "hot spots" are, like enemies, improved/poor production, available territory to settle. Very fuzzy idea, and I have trouble imagining the inputs and outputs for this compared to the others.
     
  15. Ozymandias

    Ozymandias I saw the Great Library burn.

    Joined:
    Nov 5, 2001
    Messages:
    9,476
    Gender:
    Male
    Location:
    The lone and level sands
    Before I became ill & needed to "disappear" for a few years, a handful of us began banging around ideas re: forming a 501(c)3 (tax exempt corporation, in the US) and working on a New & Better Game.

    I never had the chance to put many ideas on paper, bu I was more focused on simple game rules which would nonetheless instigate much more sophisticated "emergent behavior."

    Example:
    1. The game starts with any AI Settler seeing 9 squares. Each square has a set of variable values - which change over time and circumstances - for terrain type, resources, etc.
      • A simple example of a dynamic change in value: On that very first turn, a Mountain tile without resources might have a value of "0," for the purposes of building a City. If, much later in the game, another Mountain tile without resources happens to border a hostile Civ, it might have a value of "5" - for deciding whether or not a unit should be placed there for defensive purposes.
    2. Returning to Turn 1, our Noble Warrior sets out, and discovers the value of each tile - except, here, the variables might be used, by a different yet equally simple algorithm, to chose which direction to move towards next.
    3. Further, again simple, algorithms readily drive - let's say - what to build, where to move, and what to improve, etc.
    4. Contact with its first other Civ might change behavior, in terms of, e.g.:
      • Sticking a unit on that - until that moment - otherwise useless mountain top.
      • Change which directions Settlers & Workers are sent, and how they are escorted.
    Jumping around a bit - A "Trait" like Seafaring might give higher impetus to building a coastal city.

    These are all scattershot examples of the "micro" of the 2 levels of algorithmic layers I envisioned. The "macro" - again, using simple values and variables - wound determine strategy, e.g., what types of units to build (example: actually building ships , even if the map has only one continent on it.)

    ... Oh, well, etc. :) I'm sure you get the gist.
     

Share This Page