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

Report Questionable Behavior

Discussion in 'Civ4 - Better AI' started by Iustus, Jan 25, 2007.

  1. Roland Johansen

    Roland Johansen Deity

    Joined:
    Apr 29, 2003
    Messages:
    4,292
    Location:
    the Netherlands
    Sorry. As said before, I'm not a programmer, but I do like to think about improving the AI by employing decent approximations.

    I'd likely prefer an average over a minimum or a maximum. iiNumDefenders / iNumCities is an underestimate as the AI will distribute the units in a better way over the cities, in a way that it gets more happiness advantages. AI_neededDefenders is an overestimate as the AI will often not own the units to get that preferred number of defenders. An average seems to be a decent approximation of the actual happiness advantage.

    I'm not a programmer so I didn't try to decipher all of the code. But if this causes the AI under hereditary rule to continuously create more units to fight unhappiness then that might not be such a good idea. The cost of building and maintaining a unit plus the food required to create another citizen in a city (which could have been hammers or commerce) is often larger than the advantage of the temporary extra citizen during the period that the AI is using the hereditary rule civic. At some point the investment in temporary units for temporary happiness and the cost of creating temporary citizens is just not worth it. After the hereditary rule civic has been replaced by another civic, the extra defenders are superfluous and costly and the extra citizens can't be kept happy.
    I typically don't use more than 3-4 units per city during hereditary rule and will often use even less units.
    It's nice to get some happiness bonus from the defenders in your cities, but it's typically not a good tactic to start creating units in great numbers to create happiness.
     
  2. LunarMongoose

    LunarMongoose King

    Joined:
    Jan 29, 2006
    Messages:
    731
    Gender:
    Male
    Location:
    Boston, MA, USA
    You're assuming they will switch off Hereditary at some point in the future, but they might not if it's more useful to them than anything else. I did think about the issues with disengaging from it after using it, but that will happen with any level of usage of it, so at that point it's like, why bother ever using it in the first place.

    Unfortunately Fuyu found what is a significant problem with my implementation if he's right, which I'm assuming he is, and I will need to change it when I can, which is why I wish JDog were around. But if you are evaluating the value of the civic based on military units instead of just using a low flat value, then you are also obligated to try to make use of military units when you are actually running the civic. You're either using it seriously, or you're not, and if you are then yeah switching off of it later is gonna be painful. But that shouldn't stop the AIs from having the option.

    Afforess' point was that not all existing defense units will actually be IN cities: some will be defending resource tiles, some will be moving to reinforce other cities as needed, etc. I therefore was/am banking on this effect roughly cancelling out the extra benefit of AIs intelligently deploying happiness troops where they are most needed instead of just an average number everywhere. So yeah, I stand by "iNumDefenders / iNumCities", and as I argued earlier, believe AI_neededDefenders() would be a potentially huge overshoot depending on the situation.
     
  3. Roland Johansen

    Roland Johansen Deity

    Joined:
    Apr 29, 2003
    Messages:
    4,292
    Location:
    the Netherlands
    I use hereditary rule every game, but the average number of units in my cities under this civic never ever exceeds 3 and even in great cities I will not place more than 4 or 5 units. It's just too costly to invest more in units and unit upkeep especially since those units are not being used for war and will eventually be disbanded (or I'd need to invest huge sums of money to upgrade them all for war). You can't use them for war as long as you're using hereditary rule as you need them for the happiness effect.

    If you stay in hereditary rule for the entire game, then the investment in peacekeeping units could be worth it. I must say that I never do that. Once I find other ways of happiness, then I'll go for the more economically beneficial civics like Universal Suffrage, Representation or Police State (in heavy wars). There could of course be situations where the AI would benefit from staying in hereditary rule when it for instance has access to very few happiness resources.

    Can you describe how much your code would entice the AI (in hereditary rule) to build units instead of happiness increasing buildings?
     
  4. LunarMongoose

    LunarMongoose King

    Joined:
    Jan 29, 2006
    Messages:
    731
    Gender:
    Male
    Location:
    Boston, MA, USA
    The code I wrote tells AIs to add one additional unit beyond the number determined to be needed for defense, to cities that are currently at their happiness limits if Hereditary is in effect (and to do nothing differently otherwise). And in writing that sentence I already see one problem with it heh, but in any case I need to look at Fuyu's issue with it before I say too much b/c I may have done it completely wrong anyway heh.

    But what I was TRYING to do, and hopefully WILL do correctly in a few days when I'm done taking a Civ break lol, is make it add one unit to each city currently at its happiness limit, regardless of building plans, and the same code would also allow it to remove the extra units if happiness buildings later finished there. But it wouldn't directly interact with the building planning/queuing code.
     
  5. Thomas SG

    Thomas SG CCV-designer

    Joined:
    Aug 10, 2007
    Messages:
    1,164
    Location:
    Germany
    I'm running my mod with BBAI 1.01f and I've got some questions.

    a) I've got the impression that the AI won't settle over sea. And so I finally decided to make a test.
    I've created near the home country of my civ an isle. While very short on ressouces in the home country there was nearly everything on the small isle. I've placed fresh water, some trees, some hills, gold, wheat, cows, stone, horses, copper and iron on the isle. And I gave a galleon, all needed techs and a settler. All plots and ressources were revealed. And the distance to the capital was very small. About 6 plots.

    And so I expected the AI would create now a new city on that isle. So I started the automated AI. But nothing happend. The settler stayed in the coatal city with the galleon. A workboat moved around the isle. And my civ had only 3 cities on that medium map. Other nations decleared war to my civ. And although my civ suffered from a lack of ressources like horse, copper and iron the settler never moved to those known ressources. :sad:

    b) Are you sure that AI subs and missile cruisers load missiles and nukes? I've never seen it. So I had a fast look over the code. How and where is the AI teached to do so? I saw old code commented out but nothing equal somewhere else. And why was this code commented out?

    form void CvUnitAI::AI_missileCarrierSeaMove()
    PHP:
    //    if (AI_pickup(UNITAI_ICBM))
    //    {
    //        return;
    //    }
    //    
    //    if (AI_pickup(UNITAI_MISSILE_AIR))
    //    {
    //        return;
    //    }
    Thanks.
     
  6. Fuyu

    Fuyu Emperor

    Joined:
    Nov 5, 2009
    Messages:
    1,225
    Location:
    Austria
    Is the galleon running UNITAI_SETTLER_SEA ? If not, does your civ have a coastal city plus the required techs to build another transport (galley at least) to run UNITAI_SETTLER_SEA?
    If yes then we have a problem only jdog can solve, probably -_-
     
  7. Thomas SG

    Thomas SG CCV-designer

    Joined:
    Aug 10, 2007
    Messages:
    1,164
    Location:
    Germany
    Yes. And my civ could build galleys but no galleons. The galleon came with WB.

    I've made a new test some minutes ago. And I've got two results:

    a) If you have no coastal city the AI will not settle over sea! Settlers will only be loaded in coastal cities. And that is problem. In my test a few minutes ago I placed my civ at the beginning of the game on a very small isle. And I gave it a scout and a warrior on a near continent. And also a galley. The AI placed the first city exactly in the middle of the isle. Fresh water was available there. But there was no coast. And the AI knew from start up that it is on that mini isle because all plots where revealed and placed the city away from the coast. :sad: And although it had a galley and produced a settler in the city the AI could never leave that isle. :cry:

    But in the moment the city had a coast (created by WB) the galley moved there and loaded the settler. The settler was brought now to the continent and founded a city. :)

    By the way I've made a little change before this test.

    PHP:
    /************************************************************************************************/
    /* BETTER_BTS_AI_MOD                      01/16/09                                jdog5000      */
    /*                                                                                              */
    /* Gold AI                                                                                      */
    /************************************************************************************************/
        // No new settling of colonies when AI is in financial trouble
        
    if( plot()->isCity() && (plot()->getOwnerINLINE() == getOwnerINLINE()) )
        {
            if( 
    GET_PLAYER(getOwnerINLINE()).AI_isFinancialTrouble() )
            {
                
    // Thomas SG
                //iOtherBestFoundValue = 0;
                
    iOtherBestFoundValue /= 4;
            }
        }
    /************************************************************************************************/
    /* BETTER_BTS_AI_MOD                       END                                                  */
    /************************************************************************************************/
    But while this situation was a construction think about a civ that has lost it's costal cities in war but still has transport ships and settlers and needs to flee from it's home country. The AI must be teached to load settlers from coast. What about scenarios?

    b) There must be a mistake from the advanced cargo in my mod. :sad: With the little change from above the AI settles when the advanced cargo is disabled. But not if it is enabled. But this is no task for you...
     
  8. Fuyu

    Fuyu Emperor

    Joined:
    Nov 5, 2009
    Messages:
    1,225
    Location:
    Austria
    As long as the mapscript/scenario maker place settlers on the coast when expedient, this shouldn't be that much of a problem. After the first city, the AI city placement code will make sure there are enough coastal cities, so building settlers and ferrying them off should rarely be a problem.
    Also there is no such thing as a "need to flee". If a player needs to flee, he is as good as dead anyway, no purpose in prolonging the suffering.
     
  9. LunarMongoose

    LunarMongoose King

    Joined:
    Jan 29, 2006
    Messages:
    731
    Gender:
    Male
    Location:
    Boston, MA, USA
    Sure there is: Require Complete Kills option on and trying to annoy the other players! :p
     
  10. Thomas SG

    Thomas SG CCV-designer

    Joined:
    Aug 10, 2007
    Messages:
    1,164
    Location:
    Germany
    Fine. :)


    That depends on the map and mod stuff. Imagine a map with an old and a new world. You may be nearly dead in the old world but if you are able to go to the new world with a settler you may still have a good chance. And in CCV this is especially an option for the vikings as their longboat (galley) can travel across the ocean very early. (And so also for all players that could conquer one.) ;)

    But thanks for your help. :goodjob: I'm satisfied with the results in CCV now. The little change from above solved one part of my problem. And Advanced Cargo is now also working as intended. Also fighters and missiles are now always loaded as expected. So most of the unfortunate behaviour was caused by mistakes in my code.

    Good work. Thanks. :)
     
  11. Zeppelin4

    Zeppelin4 Warlord

    Joined:
    Mar 30, 2007
    Messages:
    230
    Does anyone know why when I start a game now my city maintenance starts at plus 9 or more? This started after I loaded the latest mod though it does it without the mod loaded. Even though my maintenance says plus 9 or more I never make any gold. :confused:

    Note: I don't use any other mods.
     
  12. PieceOfMind

    PieceOfMind Drill IV Defender Retired Moderator

    Joined:
    Jan 15, 2006
    Messages:
    9,319
    Location:
    Australia
    First, what steps did you take to install the mod?

    Second, how certain can you be that nothing in the install folder of the game has been modified? When I am in doubt, I just re-install the game entirely.
     
  13. Zeppelin4

    Zeppelin4 Warlord

    Joined:
    Mar 30, 2007
    Messages:
    230
    The only mod I use is this mod. I just install it to the mods folder like I have done since the start. I will reinstall the game though and see how that goes.
     
  14. Sidney Magal

    Sidney Magal Latin Lover

    Joined:
    Oct 3, 2009
    Messages:
    201
    Location:
    Brazil
    I got a weird DOW from Suryavarman when playing the Earth 34 civs with the Better BUG AI mod. He declared war on me and didn't send anything, had no units near my borders or close so I got curious. I went back to the last autosave before the DOW and tried to see what forces they had with the Worldbuilder. The Khmer had an army of 4 warriors and 1 worker. Why did he do it? I don't think he was bribed because AFAIK, no one has alphabet.
    Spoiler :




    Did he make that decision because I only had one warrior in the city in his borders? We all know that in the early game in that map the Khmer suck and have no way of keeping up against China so wth?

    I attached the autosave before the DOW and the save of turn he declared.
     

    Attached Files:

  15. Sidney Magal

    Sidney Magal Latin Lover

    Joined:
    Oct 3, 2009
    Messages:
    201
    Location:
    Brazil
    Is this forum dead or was my question stupid?
     
  16. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    Forums dead. It's not you.
     
  17. Fuyu

    Fuyu Emperor

    Joined:
    Nov 5, 2009
    Messages:
    1,225
    Location:
    Austria
    The only one who could answer that question is jdog, and he's not available right now. I've seen strange DOW decisions too but didn't have the time yet to find out where this is handled.
     
  18. Cybah

    Cybah Emperor

    Joined:
    Jun 22, 2007
    Messages:
    1,480
    What does DOW stand for?
     
  19. NotSoGood

    NotSoGood Emperor

    Joined:
    Jan 25, 2009
    Messages:
    1,077
    Location:
    Finland
    I think it means "declaration of war" or something like that.
     
  20. rspeer

    rspeer Spearman

    Joined:
    Apr 5, 2006
    Messages:
    101
    Here's something that seems like an AI glitch. I'm playing BBAI through the LoR mod, so hopefully that doesn't change things too much.

    Things are not going well for my rival, Greece. I'm amassing a stack of units to attack his capital.

    On the turn after this save, he moves a big stack of units from the city into the open, with no defense bonuses, where I can massacre them. Why?
     

    Attached Files:

Share This Page