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

Does the AI use Great Spies for anything other than Scotland Yard?

Discussion in 'Civ4 - General Discussions' started by Yxklyx, Nov 1, 2013.

  1. Yxklyx

    Yxklyx King

    Joined:
    May 7, 2008
    Messages:
    869
    This has been bothering me a bit. It seems that the AI never Infiltrates and never Settles Great Spies. Does anyone have any images to prove otherwise? If not, this is a big handicap for the AI players.
     
  2. TheMulattoMaker

    TheMulattoMaker Dictator of RF

    Joined:
    May 28, 2008
    Messages:
    1,483
    Location:
    Far-GO!
    I'm playing a rather cramped 18-civ (well, 17; Sury failed to fogbust) game. Ramesses popped a GSpy very early by building GWall and a couple other wonders before doing anything else. He used it for a Golden Age. With one city, population 5 at most, I'm sure he got a whole lot out of it. :rolleyes:

    Four more civs have popped GSpies since then. Without exception, they used them to build SY in the city that birthed the Spy, regardless of whether that city was any good for running EPs or not. :shake:
     
  3. Yxklyx

    Yxklyx King

    Joined:
    May 7, 2008
    Messages:
    869
    Yeah, I can believe I've seen them used for GAs before - but AFAIK they don't settle and they don't infiltrate. I'm surprised none of major modders here have noticed this - it's a major bug and gives an unfair advantage to the human player. Their infiltration ability should be removed at least (one line change in the xml) to even the playing field.
     
  4. Manco Capac

    Manco Capac Friday,13 June,I Collapse

    Joined:
    Mar 1, 2010
    Messages:
    8,051
    Basically, the GSPies are using the behavioral of GMerchants. Why? No idea. Lazy bum reason.

    Code:
    void CvUnitAI::AI_merchantMove()
    {
    	PROFILE_FUNC();
    
    	if (AI_construct())
    	{
    		return;
    	}
    
    	if (AI_discover(true, true))
    	{
    		return;
    	}
    
    	int iGoldenAgeValue = (GET_PLAYER(getOwnerINLINE()).AI_calculateGoldenAgeValue() / (GET_PLAYER(getOwnerINLINE()).unitsRequiredForGoldenAge()));
    	int iDiscoverValue = std::max(1, getDiscoverResearch(NO_TECH));
    
    	if (AI_trade(iGoldenAgeValue * 2))
    	{
    	    return;
    	}
    
    	if (((iGoldenAgeValue * 100) / iDiscoverValue) > 60)
    	{
            if (AI_goldenAge())
            {
                return;
            }
    
            if (AI_trade(iGoldenAgeValue))
            {
                return;
            }
    
            if (iDiscoverValue > iGoldenAgeValue)
            {
                if (AI_discover())
                {
                    return;
                }
                if (GET_PLAYER(getOwnerINLINE()).getUnitClassCount(getUnitClassType()) > 1)
                {
                    if (AI_join())
                    {
                        return;
                    }
                }
            }
    	}
    	else
    	{
    		if (AI_discover())
    		{
    			return;
    		}
    
    		if (AI_join())
    		{
    			return;
    		}
    	}
    
    	if ((GET_PLAYER(getOwnerINLINE()).AI_getPlotDanger(plot(), 2) > 0) ||
    		  (getGameTurnCreated() < (GC.getGameINLINE().getGameTurn() - 25)))
    	{
    		if (AI_discover())
    		{
    			return;
    		}
    	}
    
    	if (AI_retreatToCity())
    	{
    		return;
    	}
    
    	if (AI_safety())
    	{
    		return;
    	}
    
    	getGroup()->pushMission(MISSION_SKIP);
    	return;
    }
    Basically, doing the action right onto the spot they spawned, the unit rolls a serie of potential actions, depending if doable or not.

    1)Build the Great Building, that is the Scotland Yolo.
    2)Then, it immediately goes to the GAge evaluation.
    3) At last, it joins the city.

    So, in the end, there is no infiltration mission involved at all.
    I think Karadoc did make his own GSpy code bits.

    Sayonara~~~~
     
  5. Yxklyx

    Yxklyx King

    Joined:
    May 7, 2008
    Messages:
    869
    I looked at those functions - and you know, they're all practically the same for each Great unit. I can't see for instance from that function why the AI doesn't settle a Great Spy. I think there's other code involved. The Infiltration and Merchant Trade mission are related somehow - and you can't see that in this piece of code from what I can tell. If I give the Great Spy trade values in XML it will do a Trade Mission - I wonder if just switching the AI to UNITAI_SCIENITST will allow it to settle - that would at least make it more useful for the AI.
     
  6. whitelaughter

    whitelaughter Warlord

    Joined:
    Oct 21, 2008
    Messages:
    269
    Location:
    Canberra, Australia
    But GMerchants don't have a Great Building, so why is that coded?
    Any chance that both are using code for Great Scientist?
     
  7. Manco Capac

    Manco Capac Friday,13 June,I Collapse

    Joined:
    Mar 1, 2010
    Messages:
    8,051
    The XML file for units has shown me without doubt that GSpy is using the GMerchant behavior.
    The line about Special building is just skipped due to its absence.
     
  8. Seraiel

    Seraiel Deity

    Joined:
    Sep 6, 2011
    Messages:
    7,954
    Gender:
    Male
    But Merchants do Trademissions. Did I understand that part wrong? I somehow understood that Great Spies don't infiltrate because that part is completely missing and that the GPs work following the same script.
     
  9. plastiqe

    plastiqe Grinch

    Joined:
    Oct 5, 2004
    Messages:
    597
    Location:
    Canada, eh
    I'm pretty sure that is true, though hard to remember because... y'know.. the unit is invisible. Found this bit in the patch notes which is probably relevant:

     
  10. Ghpstage

    Ghpstage Deity

    Joined:
    Jan 15, 2009
    Messages:
    2,944
    Location:
    Bristol, England
    I suspect its got something to do with being so low down on the priority list, I don't recall ever seeing a settled AI GM either.


    The trade mission lines in the GMerchant code, do they cause a GM to move to a rivals city to trade, or are they only checked if the GM is already in a city it can trade with?
    If its the former it may explain a bit about AI GSpy stupidity as no check is made to find out if the unit can carry out a trade mission, which may cause it to wander about in rival cities, at least until a golden age becomes more valuable than a trade route, providing it doesn't land in one of its own cities without Scotland Yard.

    Dumb bugs like this wouldn't be unheard of, AI GEs do (did?) on occasion build wonders in other civs cities!
     

Share This Page