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

Version 1.00 discussion thread

Discussion in 'Civ4 - Better AI' started by jdog5000, May 17, 2010.

  1. Fuyu

    Fuyu Emperor

    Joined:
    Nov 5, 2009
    Messages:
    1,225
    Location:
    Austria
  2. Ninja2

    Ninja2 Great Engineer

    Joined:
    Nov 17, 2005
    Messages:
    1,142
    Location:
    Denmarkia
    Yes, but I never understood what they were - until now. :) Thanks for clarifying.
     
  3. Jet

    Jet No, no, please. Please.

    Joined:
    Mar 16, 2006
    Messages:
    2,364
    Haven't tried this mod in a long time. This version looks cool.

    In this version, can you permanently prevent an AI from pursuing cultural victory by capturing or razing his capital? You can do that in the unmodded game.
     
  4. sveint

    sveint Warlord

    Joined:
    Oct 9, 2006
    Messages:
    187
    AI refuses to take empty cities.
     
  5. Munch

    Munch Benevolent Despot

    Joined:
    May 25, 2006
    Messages:
    2,081
    I'm sure in the previous version settling on floodplains gave you three food, but in this version it reverts back to just two...

    EDIT: I found it, the 'original bts code' is commented out, and replaced with exactly the same thing (CvCity.cpp line 228)!

    Code:
    	if (lResult == 1)
    	{
    /************************************************************************************************/
    /* UNOFFICIAL_PATCH                       03/01/10                     Mongoose & jdog5000      */
    /*                                                                                              */
    /* Bugfix                                                                                       */
    /************************************************************************************************/
    /* original bts code
    		if (pPlot->getFeatureType() != NO_FEATURE)
    */
    		// From Mongoose SDK
    		// Don't remove floodplains from tiles when founding city
    		//if ((pPlot->getFeatureType() != NO_FEATURE) && (pPlot->getFeatureType() != (FeatureTypes)GC.getInfoTypeForString("FEATURE_FLOOD_PLAINS")))
    		
    		if (pPlot->getFeatureType() != NO_FEATURE)
    /************************************************************************************************/
    /* UNOFFICIAL_PATCH                        END                                                  */
    /************************************************************************************************/
    		{
    			pPlot->setFeatureType(NO_FEATURE);
    		}
    	}
     
  6. Fuyu

    Fuyu Emperor

    Joined:
    Nov 5, 2009
    Messages:
    1,225
    Location:
    Austria
    Instead of leaving floodplains when founding a city, floodplains are simply being re-added when a city on desert next to river is destroyed, see CvCity::kill() .
    This Unofficial Patch change was requested by EmperorFool because getting 3 food from city tile when settling on fp is altering the game rules and thus couldn't be part of BULL.
     
  7. Munch

    Munch Benevolent Despot

    Joined:
    May 25, 2006
    Messages:
    2,081
    I see, thanks for clarifying that :)
     
  8. NotSoGood

    NotSoGood Emperor

    Joined:
    Jan 25, 2009
    Messages:
    1,077
    Location:
    Finland
    This more like a question rather than a bug report.
    I'm using Better AI (1.00 IIRC) in my mod. I have done quite a few SDK changes but I don't think they affect this.
    In my test game I'm a super power and have two vassals. My question is why one of the AIs doesn't have any victory strategies? He's the weakest player in the game and vassal of Poland (not me). What is the reason for it, because even my vassals have victory strategies? Has he given up? :)
     

    Attached Files:

  9. Tholal

    Tholal Emperor

    Joined:
    May 19, 2009
    Messages:
    1,676
    I'm a bit confused at the getCultureVictoryStage() function. This section of code seems to be keeping the AI from ever hitting Culture 1 or 2 levels.

    Code:
            iValue = 0;
    	if (GC.getGameINLINE().isOption(GAMEOPTION_ALWAYS_PEACE))
    	{
        	iValue += 30;
    	}
    	
    	iValue += (GC.getGameINLINE().isOption(GAMEOPTION_AGGRESSIVE_AI) ? -20 : 0);
    	
    	if( iValue > 20 && getNumCities() >= GC.getGameINLINE().culturalVictoryNumCultureCities() )
    	{
    		iValue += 10*countHolyCities();
    	}
    
    	int iNonsense = AI_getStrategyRand() + 10;
    	iValue += (iNonsense % 100);
    
    	if (iValue < 100)
    	{
    		return 0;
    	}
    First off, it's only giving extra value to Holy cities when the game is set to Always Peace without Aggressive AI (this is the only option that results in iValue having a value greater than 20 at that point in the function)? This seems a bit extreme. Holy cities are always valuable culture centers.

    So for the first half of the code section, iValue will be 0 most of the time. I dont quite understand the next part where a random number is generated, but since only the remainder is being added to iValue, there is a 90% chance that the result will be less than 100, returning a 0. Also, this function doesn't ever seem to pull the Culture strategy weight from the Leaderhead info.

    Prior to the above code is this:

    Code:
    	if (GC.getGame().getStartEra() > 1)
        {
        	return 0;
        }
    If I understand correctly, this means that any Advanced start games will never see an AI using CULTURE 1 or 2 strategy levels as those are only assigned at the very end of the function.
     
  10. Tholal

    Tholal Emperor

    Joined:
    May 19, 2009
    Messages:
    1,676
    OK. My bad on the CultureVictory function. I must have messed with the code and forgot to change it back (or perhaps I had an old version). I do see that you're pulling the Leader's Culture Victory Weight to get an initial iValue. So ignore the first part of my post.

    However, I am still confused by the Advanced Start section.
     
  11. Munch

    Munch Benevolent Despot

    Joined:
    May 25, 2006
    Messages:
    2,081
    Loving the mod so far, great work.

    Was just looking through the additional options and have a question about defensive pact behaviour. Option "1 : Defensive pacts do not cancel when a player has war declared on them", isn't an offensive pact (that is option 2) but does the defensive pact remain in place if one party declares a war?
     
  12. Fuyu

    Fuyu Emperor

    Joined:
    Nov 5, 2009
    Messages:
    1,225
    Location:
    Austria
    No, with option 1 DPs should cancel if you declare war, and only hold if you are the defender.
     
  13. LunarMongoose

    LunarMongoose King

    Joined:
    Jan 29, 2006
    Messages:
    731
    Gender:
    Male
    Location:
    Boston, MA, USA
    With a moderate amount of testing so far, I can't reproduce this behavior.

    I also looked over the relevant code, and while I'm far from being able to conclusively say - just based on that - that there is no problem, I didn't find anything wrong. There are several different areas of code that did get updated or replaced in BBAI 1.0 that are involved in making city attacks however, so it's still possible this could happen under certain conditions.

    This is probably one where JDog would ask you to provide a save file, btw. ;)
     
  14. jdog5000

    jdog5000 Revolutionary

    Joined:
    Nov 25, 2003
    Messages:
    2,601
    Location:
    California
    Conquest and domination strategies cannot be adopted by vassals, so most likely the vassal would want to be running one of those if the game had gone better for it.

    Not running a victory strategy is not any kind of problem, as the first couple levels are only subtle tweaks to the AIs approach. And since they're already a vassal, their chances of winning aren't so hot ...

    One could argue that vassals should always switch to pursuing cultural or space victory (or diplomacy if they can build UN), as that's probably their only route to victory. However, I don't want to add any disincentive to accepting capitulation since it's not reversible should you later notice your vassal is getting close to cultural victory.

    Cultural victory is something the AI has to go for from the beginning of the game to really have a chance at. This logic was inherited from Blake's original cultural victory AI, and the idea is that if the game starts in the Medieval era then the AI hasn't had a chance to build ancient era wonders and go for religions which are pivotal for cultural victory.
     
  15. Maniac

    Maniac Apolyton Sage

    Joined:
    Nov 27, 2004
    Messages:
    5,588
    Location:
    Gent, Belgium
    I can confirm this behaviour since version 1.0. Unfortunately it's while playing Planetfall, so a save probably is of no use to you.

    If I move the sole defender out of a city threatened by five enemy units, the enemy moves towards another city instead. If I leave the defender where it is, the enemy attacks and conquers the city...

    I have a debug DLL, so I can have a look myself into the possible problem. Though of course some hints can always help speed things up: do you know what code should normally allow the AI to capture empty cities? The enemy stack is led by a UNITAI_ATTACK_CITY unit;
     
  16. jdog5000

    jdog5000 Revolutionary

    Joined:
    Nov 25, 2003
    Messages:
    2,601
    Location:
    California
    Thanks for the report Maniac. The code which should cause ATTACK_CITY units to attack cities is either the call to AI_stackAttackCity or AI_cityAttack. Both of these calls are inside of a large new piece of logic bracketed by if( pTargetCity != NULL )

    After taking a quick look, my guess is that the bug is actually in AI_pickTargetCity. In that function there's a line:

    Code:
    if( GET_PLAYER(getOwnerINLINE()).AI_cityTargetUnitsByPath(pLoopCity, getGroup(), iPathTurns) > 3 * pLoopCity->plot()->getNumVisibleEnemyDefenders(this) )
    
    Which could give problems if there are 0 visible enemy defenders ... so perhaps something like:

    Code:
    if( GET_PLAYER(getOwnerINLINE()).AI_cityTargetUnitsByPath(pLoopCity, getGroup(), iPathTurns) > std::max( 6, 3 * pLoopCity->plot()->getNumVisibleEnemyDefenders(this)) )
    
    You'd probably also need to comment out the code right above that about relative power also.

    Please let me know if that fixes things for you.
     
  17. Maniac

    Maniac Apolyton Sage

    Joined:
    Nov 27, 2004
    Messages:
    5,588
    Location:
    Gent, Belgium
    I've found that the problem is in fact in Lead from Behind code in CvUnit::canMoveInto.

    Code:
    if (bAttack)
    			{
    /************************************************************************************************/
    /* BETTER_BTS_AI_MOD                      06/14/10                                jdog5000      */
    /*                                                                                              */
    /* Efficiency                                                                                   */
    /************************************************************************************************/
    				// From Lead From Behind by UncutDragon
    				// original
    				//CvUnit* pDefender = pPlot->getBestDefender(NO_PLAYER, getOwnerINLINE(), this, true);
    				//if (NULL != pDefender)
    				//{
    				//	if (!canAttack(*pDefender))
    				//	{
    				//		return false;
    				//	}
    				//}
    				// modified
    				if( combatLimit() < 100 )
    				{
    					CvUnit* pDefender = pPlot->getBestDefender(NO_PLAYER, getOwnerINLINE(), this, true);
    					if (NULL != pDefender)
    					{
    						if (!canAttack(*pDefender))
    						{
    							return false;
    						}
    					}
    				}
    				else if (!pPlot->hasDefender(true, NO_PLAYER, getOwnerINLINE(), this, true))
    				{
    					return false;
    				}
    /************************************************************************************************/
    /* BETTER_BTS_AI_MOD                       END                                                  */
    /************************************************************************************************/
    			}
    The original code should be simply restored.
    As you can probably see right away now I've pointed to it,

    Code:
    else if (!pPlot->hasDefender(true, NO_PLAYER, getOwnerINLINE(), this, true))
    				{
    					return false;
    				}
    is not the same as

    Code:
    //CvUnit* pDefender = pPlot->getBestDefender(NO_PLAYER, getOwnerINLINE(), this, true);
    				//if (NULL != pDefender)
    				//{
    				//	if (!canAttack(*pDefender))
    				//	{
    				//		return false;
    				//	}
    				//}
    as it leaves out the "if (!canAttack(*pDefender))" check, changing the effect of code from preventing units that can't attack from attacking defended cities, to preventing attacking units from moving into empty cities.
     
  18. jdog5000

    jdog5000 Revolutionary

    Joined:
    Nov 25, 2003
    Messages:
    2,601
    Location:
    California
    Thanks very much for tracking this down Maniac!
     
  19. Djoums

    Djoums Chieftain

    Joined:
    Jun 10, 2010
    Messages:
    91
    Not sure if it comes from this but I find early rushes to be much harder now.
    Last attempt was on Qin, by the time I sent ~10 chariots and declare he already had 5 barrack promoted protective archers in his capitol (~1200BC I think), and that was before additional whipped defenders :( Replayed the same game without the rush/units buildup part and he had half of that defense at the same date.
    Does the AI detect your rush attempts and react to it by watching your power score grow ?
     
  20. Maniac

    Maniac Apolyton Sage

    Joined:
    Nov 27, 2004
    Messages:
    5,588
    Location:
    Gent, Belgium
    My pleasure. :)
     

Share This Page