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

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.
 
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:
 
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:

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.
 
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~~~~
 
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.
 
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.
 
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.
 
I think Karadoc did make his own GSpy code bits.
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:

  • Tightened the conditions on espionage usage when using the 'espionage economy' strategy, so that the AI will be a bit less likely to waste all its espionage blowing up factories when it is meant to be stealing techs.
 
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.
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!
 
Top Bottom