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

Specific Bug Reports

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

  1. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    The AD code is more correct this time. I added more functionality in the modcomp then I have/had in AND. ;)
     
  2. Cybah

    Cybah Emperor

    Joined:
    Jun 22, 2007
    Messages:
    1,480
    It's strange that you don't update your own mod with your modcomp. :D
     
  3. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    Too many other features to add; it'd be 5 minutes I don't have, for functionality that isn't that earthshattering. ;)
     
  4. karadoc

    karadoc AI programmer

    Joined:
    Oct 3, 2005
    Messages:
    1,568
    Location:
    Australia
    In CvCityAI::AI_chooseProduction(), the following code is involved in deciding whether the AI should build a worker.
    Code:
    if (bDanger && (iExistingWorkers == 0) && (isCapital() || (iNeededWorkers > 0) || (iNeededSeaWorkers > iExistingSeaWorkers)))
    Maybe I just don't understand the strategy that the AI is using here, but I'm pretty sure that should be "!bDanger". I don't think the AI wants to build a worker as a response to being in danger.

    [edit]
    Or maybe I'm wrong about this... is the AI choosing to build a worker because it expects improvements to be pillaged? I guess I should just not post "bug reports" until I properly understand what's going on.
     
  5. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    Yeah, it should be a !bDanger.
     
  6. Fuyu

    Fuyu Emperor

    Joined:
    Nov 5, 2009
    Messages:
    1,225
    Location:
    Austria
    think the early warplans are just a byproduct of jdog's changes to CvTeamAI::AI_isLandTarget, and you can keep this from happening by adding a true to the argument list when using that function in doWar, that way you actually save cpu cycles.


    Code:
                                                    if ((iPass > 1) || AI_isLandTarget((TeamTypes)iI[B], true[/B]) || AI_isAnyCapitalAreaAlone() || GET_TEAM((TeamTypes)iI).AI_isAnyMemberDoVictoryStrategyLevel4())
                                                    {
                                                        if ((iPass > 0) || (AI_calculateAdjacentLandPlots((TeamTypes)iI) >= ((getTotalLand() * AI_maxWarMinAdjacentLandPercent()) / 100)) || GET_TEAM((TeamTypes)iI).AI_isAnyMemberDoVictoryStrategyLevel4())
                                                        {
                                                            iValue = AI_startWarVal((TeamTypes)iI);
    
                                                            if( iValue > 0 && gTeamLogLevel >= 2 )
                                                            {
                                                                logBBAI("      Team %d (%S) considering starting TOTAL warplan with team %d with value %d on pass %d with %d adjacent plots", getID(), GET_PLAYER(getLeaderID()).getCivilizationDescription(0), iI, iValue, iPass, AI_calculateAdjacentLandPlots((TeamTypes)iI) );
                                                            }
    
                                                            if (iValue > iBestValue)
                                                            {
                                                                iBestValue = iValue;
                                                                eBestTeam = ((TeamTypes)iI);
                                                            }
                                                        }
                                                    }
    Code:
                                            if (AI_isLandTarget((TeamTypes)iI[B], true[/B]) || (AI_isAnyCapitalAreaAlone() && GET_TEAM((TeamTypes)iI).AI_isAnyCapitalAreaAlone()))
                                            {
                                                if (GET_TEAM((TeamTypes)iI).getDefensivePower() < ((iOurPower * AI_limitedWarPowerRatio()) / 100))
                                                {
                                                    iValue = AI_startWarVal((TeamTypes)iI);
    
                                                    if( iValue > 0 && gTeamLogLevel >= 2 )
                                                    {
                                                        logBBAI("      Team %d (%S) considering starting LIMITED warplan with team %d with value %d", getID(), GET_PLAYER(getLeaderID()).getCivilizationDescription(0), iI, iValue );
                                                    }
    
                                                    if (iValue > iBestValue)
                                                    {
                                                        FAssert(!AI_shareWar((TeamTypes)iI));
                                                        iBestValue = iValue;
                                                        eBestTeam = ((TeamTypes)iI);
                                                    }
                                                }
                                            }
    I think dogpile warplans should still be possible, very early.
     
  7. Munch

    Munch Benevolent Despot

    Joined:
    May 25, 2006
    Messages:
    2,081
    Ok this is a stupid question. I tried to compile including this code, but apparently getAdditionalHealthByBuilding() and getAdditionalHappinessByBuilding() 'does not take 1 arguments'. The functions seem to require three arguments, the latter two of which are "int& iGood, int& iBad". I have no idea what to put for these arguments to make it compile. Please help!
     
  8. Fuyu

    Fuyu Emperor

    Joined:
    Nov 5, 2009
    Messages:
    1,225
    Location:
    Austria
    You're obviously using Better BTS AI, which does not include the updated BULL code required for this.
    iHappyAdjust += getAdditionalHappinessByBuilding(getProductionBuilding());
    can be replaced by
    int iGood = 0; int iBad = 0;
    iHappyAdjust += getAdditionalHappinessByBuilding(getProductionBuilding(), iGood, iBad);
     
  9. Munch

    Munch Benevolent Despot

    Joined:
    May 25, 2006
    Messages:
    2,081
    You're right, that works. Thanks.
     
  10. EmperorFool

    EmperorFool Deity

    Joined:
    Mar 2, 2007
    Messages:
    9,633
    Location:
    Mountain View, California
    You have no idea how happy it makes me that Better AI was able to make use of those functions from BULL. :D While they were very "simple" to write, it took a lot of time to track down all the sources from the XMLs, processBuilding(), etc. :eek:
     
  11. Yxklyx

    Yxklyx King

    Joined:
    May 7, 2008
    Messages:
    869
    I think I've found a bug with Better AI. I'm playing with v 1.01f, BUG 4.4 and my own mod which just adds new units/techs etc... In two consecutive games I discover a tech and am unable to trade it away, once with Theology and once with Education. When I press the F4 key it shows that the OTHER AIs "Can't Trade" even though they have the prereqs (I can check using Ctrl-Alt-L) - when I switch to the other AI it shows that my Civ "Can't Trade". It's like it's applying the Tech Monopoly AI code to the human player. I can supply a save game if needed.
     
  12. NotSoGood

    NotSoGood Emperor

    Joined:
    Jan 25, 2009
    Messages:
    1,077
    Location:
    Finland
    Check in the xml if the tech has <bTrade>0</bTrade>.
     
  13. Yxklyx

    Yxklyx King

    Joined:
    May 7, 2008
    Messages:
    869
    It's set to 1 as it should be and I can trade the tech later on. I'm thinking this has something to do with the tech diffusion code in Better AI. It seems to be applying some of the AI tech trade code to the human player. If I turn tech diffusion off and load the game would I be effectively backing out? Will try that later today.
     
  14. Yxklyx

    Yxklyx King

    Joined:
    May 7, 2008
    Messages:
    869
    Never mind - looks like I bulbed Education and the game doesn't allow you to trade a tech you bulb on the turn you bulb it.
     

Share This Page