1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  3. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  4. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  5. Dismiss Notice
  6. Forum account upgrades are available for ad-free browsing.
    Dismiss Notice

[MOD] More Naval AI

Discussion in 'More Naval AI Modmod' started by Tholal, Mar 18, 2010.

  1. Tholal

    Tholal Chieftain

    Joined:
    May 19, 2009
    Messages:
    1,629

    Attached Files:

  2. Seven05

    Seven05 Warmonger

    Joined:
    Dec 5, 2005
    Messages:
    1,969
    Gender:
    Male
    Location:
    USA
    There are some handy functions built into Civ4 for identifying areas, since areas in Civ4 are really continents you can use these to help the AI decide if, or how many, ships they'll need. I used this in my Civ4 mod to prevent the AI from building too many ships (obviosuly not a problem in FfH). I'll see if I can dig up the old python code from before I moved it to the DLL to give you some ideas. You can probably use similar code to refine how you determine which AI to assign to the units having them maintian a larger navy if they're split across multiple areas or switching to a more aggressive AI if they're at war with somebody on a different area.
     
  3. [to_xp]Gekko

    [to_xp]Gekko WM junkie

    Joined:
    Dec 16, 2005
    Messages:
    7,771
    Location:
    Seyda Neen, Vvardenfell
    awesome :D
     
  4. Tholal

    Tholal Chieftain

    Joined:
    May 19, 2009
    Messages:
    1,629
    I just realized that I didn't really talk about the net result of my changes. I'll edit my original post later, but for now here's a quick summary.

    • AI will build boats, settle islands and make sea assaults (decent job of settling; sea assaults are kind of hit or miss)
    • AI civs that begin with coastal empires will hit the water techs earlier
     
  5. snarko

    snarko DLLer

    Joined:
    Dec 9, 2003
    Messages:
    1,512
    Location:
    Sweden
    This is because FfH has a check, in the SDK, to stop AI units from moving if they can't move in any direction. This is to prevent a WoC issue. Don't think it would be an issue to exempt one tile islands from this rule (I did it before without noticing a problem) but it requires SDK modding :p

    As the settler is surrounded by water it can't move in any direction, therefor the AI is not allowed to use it in any way (including settling).
     
  6. Sephi

    Sephi Chieftain

    Joined:
    Jan 25, 2009
    Messages:
    2,908
    you can remove the whole code without problem (done in wildmana)
     
  7. Nor'easter

    Nor'easter Chieftain

    Joined:
    Feb 25, 2007
    Messages:
    1,243
    As someone who started a navy brainstorming thread about a month ago, I definitely agree with what you did with Cargo Space and streamlining the Upgrade Paths, should help make things easier for the AI.
     
  8. Tholal

    Tholal Chieftain

    Joined:
    May 19, 2009
    Messages:
    1,629
    That thread was definitely part of my inspiration.
     
  9. Tholal

    Tholal Chieftain

    Joined:
    May 19, 2009
    Messages:
    1,629
    Here are some screenshots to show the comparison between base Ffh2 and my mod.

    I used a setup that is a difficult map to play and one the AI really has trouble with. I chose a small archipelago map with high water, eight civs, ancient start, no Acheron. There was no human interference at all, and both playthroughs used the exact same start and map.



    First picture shows the starting layout.



    Here are the results for the base game. As you can see, the game was really very static aside from the appearance of Minister Koun, Hyborem and Basium. But despite building ships, none were ever assigned as settlers or assault ships, so everyone stayed on their own little island. Not a single inter-island settlement was ever built, and no enemy troops ever landed on foreign soil.



    Then here's the game with my mod installed. This round was much more dynamic. Not only did everyone settle at least one city off their starting island (though the Balseraphs soon got stuck in one of those situations were the settler lands in the wrong spot and then never moves again), but there were also a number of naval assaults over the centuries. Obviously, the Lsjolfar tore the Sheaim up, but the Elohim also took the two southernmost cities from the Hippus (hard to see due to the culture borders). The Sidar also acquired the easternmost Bannor settlement.



    And here we have a final comparison showing the status at turn 350 (which is near the end in a quick game) between the two versions (before is base Ffh2). The Sheaim have been conquered, and the Svartfalar responded to an ill-advised war declaration from the Bannor by destroying all their ships, mounting a trade embargo around their capitol and taking a border island city.
     
  10. ExMachina

    ExMachina Chieftain

    Joined:
    Jun 5, 2008
    Messages:
    203
    This looks very interesting. I've been playing on Pangaea maps lately, since the AI seems to have such problems with navies. This mod looks like a vast improvement so far.
     
  11. Valkrionn

    Valkrionn The Hamster King

    Joined:
    May 23, 2008
    Messages:
    14,450
    Location:
    Crestview FL
    Tholal, if you don't mind I'd like to look at what you've done and see what we can merge to RifE. :goodjob:
     
  12. [to_xp]Gekko

    [to_xp]Gekko WM junkie

    Joined:
    Dec 16, 2005
    Messages:
    7,771
    Location:
    Seyda Neen, Vvardenfell
    that test looks seriously awesome O.o
     
  13. Tholal

    Tholal Chieftain

    Joined:
    May 19, 2009
    Messages:
    1,629
    Yeah. No problem. What I've done so far is fairly crude. The main issue I discovered was that no naval units were ever being assigned assault or settler status, so simply getting those into the mix makes a huge difference.
     
  14. Sephi

    Sephi Chieftain

    Joined:
    Jan 25, 2009
    Messages:
    2,908
    yeah, Kael merged only the dll side of my basic naval AI, not the XML settings, that's why you saw no settle ships.
     
  15. Tholal

    Tholal Chieftain

    Joined:
    May 19, 2009
    Messages:
    1,629
    I have a new version that I'll post either tonight or tomorrow. Here's a quick preview of the changes:
    • Caught and fixed an issue that would result in newly founded cities trying to immediately build another settler
    • Did away with trying to use the AI_ESCORT_SEA script on naval units as they would never do anything useful
    • Added a check whenever war status changes to convert missionary and animal AI units to the AI_ATTACK script
    • Some naval units will now take an appropriate crew promotion when created
    • Added a check to convert the first Caravel created to a SETTLER_SEA AI to see if I could help the computer players make that first ocean crossing
     
  16. Tholal

    Tholal Chieftain

    Joined:
    May 19, 2009
    Messages:
    1,629
    Beta 1.1 released (see first post for more info). I'll be heading on vacation on Friday, so there won't be any new versions released for a couple of weeks.
     
  17. [to_xp]Gekko

    [to_xp]Gekko WM junkie

    Joined:
    Dec 16, 2005
    Messages:
    7,771
    Location:
    Seyda Neen, Vvardenfell
    thanx! :)
     
  18. Tholal

    Tholal Chieftain

    Joined:
    May 19, 2009
    Messages:
    1,629
    I was hoping to show further developments in the world, but the game went into one of those infinite hangups around turn 447. This image shows the map state at turn 5, 100, 200, 300, 400 and 440, respectively. This test was done with the latest version of Erebus Continents, low cohesion, high water, x-wrap -- everything else on default settings



    The Lanun had their sizable island all to themselves and they took full advantage, planting cities all around the coast and launching successful assaults of the Calabim and the Hippus, wiping both from the map.

    The Balseraphs chose a different path, using Loki to snag the 2nd Sheaim city and then waging a continuous, eternal war against the Elohim (restarting it as soon as possible after every cease-fire). They didn't build a single city all game, instead relying on their conquests, which were only mildly successful. But their aggression basically ensured that all of the civs on their island would never amount to a world power, though the Elohim did try to escape the insanity by moving some of their people to a tiny island in the northern hemisphere.

    The Khazad were mostly content with sitting on their two cities, though they did join the Lanun in attacking the Hippus, securing a city on that island and then branching off to another nearby. But then they summoned Basium, declared war on the Sheaim and the Doviello, subjugating both. The Grigori also jumped into the fray, taking the Sheaim's lone offshore colony and joining the Khazad in beating the evil civilization on their home turf.
     
  19. [to_xp]Gekko

    [to_xp]Gekko WM junkie

    Joined:
    Dec 16, 2005
    Messages:
    7,771
    Location:
    Seyda Neen, Vvardenfell
    amazing what you're doing man :D
     
  20. Shoobs

    Shoobs Chieftain

    Joined:
    Mar 31, 2010
    Messages:
    185
    Keep up the good work!
     
  21. Tholal

    Tholal Chieftain

    Joined:
    May 19, 2009
    Messages:
    1,629
    This mod is still in the works, though it's scope has been greatly expanded.

    After return from my vacation, I started by looking into why the AI wasn't valuing the Heron Throne, fixed that, and then saw lots of other places to tweak wonder buildings (such as giving extra weight to wonders when you have the resources to make them build faster; giving industrious leaders extra weight towards building wonders), which then also led to looking into lighthouses and shipyards, which then led to adding some build values for the Mercurians and the Infernals (to get them to focus more on troops and troop buildings instead of other buildings), then tweaking them some more to try and make them more aggressive...

    And then I took the big plunge in an attempt to focus back on the Naval AI, downloading the latest Better AI files and starting a merge while attempting to preserve the FFH-specific code. After spending all of last night on that, I estimate I'm about halfway through getting a successful DLL build, at which point I'll need to figure out what AI logic got hosed by the merge, and making some tweaks of my own while copying bug fixes and other useful stuff from Wild Mana (such as getting the AI to understand that Pyre Zombies have collateral value).

    Anyway, I just wanted to post an update. No idea when I might actually have a new version of the mod. Merging is a very labor intensive process :crazyeye:
     
  22. [to_xp]Gekko

    [to_xp]Gekko WM junkie

    Joined:
    Dec 16, 2005
    Messages:
    7,771
    Location:
    Seyda Neen, Vvardenfell
    sounds awesome! plus additional kudos for improving the mercurians and infernals ;)
     
  23. dusckr87

    dusckr87 Chieftain

    Joined:
    Feb 7, 2010
    Messages:
    595
    Even just using your beta version, it looks like the AI uses naval power better than before. Unfortunately, that's going to be the only version that I can use, because one of your files (CIV4unitinfos.xml) overwrites a file in another mod I use, and I have just got done merging the changes from the two mods into a new file, and don't look forward to doing it again.:p
     
  24. Tholal

    Tholal Chieftain

    Joined:
    May 19, 2009
    Messages:
    1,629
    It's awesome to hear that someone is actually using my code! Let me know if you run into any consistent issues with Naval production. I do know of one issue that will often result in the AI infinitely producing sea units if they have more than 10 coastal cities.

    If I can't get the DLL merge stuff in a better state over the next few days, I might look at releasing my latest Python changes which includes a fix for the previously mentioned issue as well as improved AI for building wonders (in particular, the Heron Throne and Pact of the Nilhorn) and lighthouses, nudges to make the AI value buildings more when it gets a bonus towards building them (via resources or leader traits), and several pokes with a sharp stick for both the Infernals and Mercurians.
     
  25. Tholal

    Tholal Chieftain

    Joined:
    May 19, 2009
    Messages:
    1,629
    Progress on this project is coming along better than I expected. I've now been able to make a couple of successful DLL builds, though there is still a lot of work to be done.

    Merged in the latest dev version of Better AI, though I had to replace quite a bit of code in doing so. Looks like I managed to keep most if not all of the FFH specific code intact except for where it was redundant with jdog's changes. Still haven't modified the FFH leaderheads to use his new AI victory system yet...

    ... because first, I wanted to try fixing the issue with AI switching religions too often. So I looked at Denev's mod, and ended up merging in his leaderhead and civ XML changes, as well as a majority of his unofficial bug fixes and code tweaks.

    Managed to get a build of that merge last night, and then had an interesting bug crop up where the Minister Koun event would fail, resulting in the civ that received the event being awarded their very own Hyborem unit! Figuring that out is my next task.

    Still to do:
    • Update leaderheads
    • Add in latest fixes from the bug thread and Wild Mana
    • Look into stealing some other AI improvements from Wild Mana
    • Figure out what else I broke with the merge and try to fix it

    Once those are done and I don't notice any major issues, I'll release a beta 2.0
     
  26. [to_xp]Gekko

    [to_xp]Gekko WM junkie

    Joined:
    Dec 16, 2005
    Messages:
    7,771
    Location:
    Seyda Neen, Vvardenfell
    sounds good. keep it coming ;)
     
  27. Tholal

    Tholal Chieftain

    Joined:
    May 19, 2009
    Messages:
    1,629
    Latest Update: Spent most of the weekend trying to get my merge of the latest Wild Mana build to work. I probably should have solidified things a bit before taking that step as it turned out to be a very difficult process (though I do want to give props to the Wild Mana team for clearly labeling all of their changes in the code!).

    I finally have a working build, though it seems to lock up fairly regularly. The good news is that the naval side of things seems to be working splendidly! Had a game last night where the Clan of Embers sent a fleet of Galleys halfway around the world to pick up their Sons of Inferno (I've since fixed that bug), and ferry them back to the homeland to aid in their war against the Bannor!
     
  28. Tholal

    Tholal Chieftain

    Joined:
    May 19, 2009
    Messages:
    1,629
    I happened to run across this code the other night and commented it out. I'm not really sure why it was there in the first place, though I'm a little concerned that it was in place for a certain scenario??

    Anyway, the AI can now settle on one-tile islands. Hoping to have a release up by this weekend.
     
  29. Tholal

    Tholal Chieftain

    Joined:
    May 19, 2009
    Messages:
    1,629
    Initial post updated. First build of the mega-merge released. Since I've greatly expanded the scope of this mod, I've de-ranked it back to beta 0.7. I would LOVE to hear any and all feedback!
     
  30. [to_xp]Gekko

    [to_xp]Gekko WM junkie

    Joined:
    Dec 16, 2005
    Messages:
    7,771
    Location:
    Seyda Neen, Vvardenfell
    wow this sounds awesome. I wish you joined the Wild Mana team :D
     

Share This Page