AIs and the Art of War

I could give you any of my savegames. I never use healers in my city until late Industrial if at all. And by then, some diseases are already obsolete. I mean, what's the point of fighting diseases? You have enough :) to counter all these :mad: from them and the :yuck: only makes your cities grow faster which in turn reduce the Education. Maybe my games would be way better with the use of healers, but I still beat the AI on deity easily by the end of the Medieval Era.

As you urge people to try faster gamespeeds: Try to not fight disease once and let me know how it works for you :goodjob:

:mwaha:Mwaha ha ha, time to get the Unhealthiness mod underway.

How about Malaria based on your disease level giving -:hammers: per population and that is when it is just present in the city an outbreak makes it much worse.

How about smallpox reducing your city population to the square root of its current population (size 40 becomes size 6 in one turn) on its first encounter. Later outbreaks you only loose 1-4 pop depending on your disease/unhealthiness levels and occur more often the worse your disease level.

Shaman/Druid combo wont help with these.
 
:mwaha:Mwaha ha ha, time to get the Unhealthiness mod underway.

How about Malaria based on your disease level giving -:hammers: per population and that is when it is just present in the city an outbreak makes it much worse.

How about smallpox reducing your city population to the square root of its current population (size 40 becomes size 6 in one turn) on its first encounter. Later outbreaks you only loose 1-4 pop depending on your disease/unhealthiness levels and occur more often the worse your disease level.

Shaman/Druid combo wont help with these.

:goodjob:
 
Yes, please do so :nuke:

For now, I changed the Smallpox and Plague events a bit so they now require the respective Disease in the city which gives you some control if they happen or not (I HATE these events -.-) :mischief:
 
Healers are a square peg being shoved into a star hole
Alright, when i first read it i was thinking about a Daycare fight getting out of hand :mischief::lol::p

Ontopic: I use on average like 10-20 Healers per city, starting somewhere Late Ancient but I Do have a Few proper defence unit's to defend both the healers and the City, and an Army of City guards mainly designed to be police isn't a bad wall of death either :p

City defence force: 10-20 Healers, 10-20 Police units, around 3 Designated City Defence unit's and a Dog and usually a mobile Defence Force of Heavy Maulers that has no use Defending but to just Massacre the attacking Enemy by attacking Them :D
 
Automat worker.
Il build a city just NEAR incense. I dont have this ressource yet. If I auto the worker, he will try to build a fort on the incense case instead of the right improvment....

This is a result of the introduction of Super Forts.:( The AI considers the defensive and cultural yield of the fort to be greater than the resource + other yields that the improvement will give. It was something that was missed.
 
I just started a game and put AI Autoplay on - the AI is butchering subdued animals rather than building the Myths and herds! Sounds like the improvements for non-player AI have not made it into auto play :(
 
Would I be right in thinking there is no AI code for transporting captives by sea? An AI has a military captive on an ice tile surrounded by my culture. He is within his own culture, but the AI has allowed one 'escort' stack (several units) to freeze to death, without rescuing them or the captive. We had open borders, but he didn't even move them to my city to heal. He has placed a renewed escort for the captive - one unit - which is now down to half strength. He has galleons galore, his nearest city is three tiles away, and as I said, his culture extends to the tile where the captive is marooned.
 
I don't know what possesses the AIs to place all their HNs out in the open like a shooting gallery. Mine always end their turn in a city or fort, and many of them are my most promoted units. Even my Dragon Ships (mostly) stay alive - they even have occasional level-ups. The AIs' ones allow you to pick them off with your choice of unit as soon as built.
 
I'm copying this over here for Alberts and I to look into in our codes. Understanding some of Koshling's structure here better for Nukes is not all I'm hoping to divine in this post - there's indications of ways other problems we also have may be resolved here (like the ai not building NEARLY enough siege weaponry.) But a lot of these were deeply valuable points so I wanted to be able to find them again a little easier and share them as food for thought.
Ok, several thoughts here. I think the AI has two separate problems that make it bad at building nukes:

1.) The AI does not properly value buildings that unlock nukes.

Spoiler :

Code:
if ( bUnitIsEnabler )
{
	PROFILE("CalculateAllBuildingValues.IsUnitPrereq");

	if (kUnit.getDefaultUnitAIType() != NO_UNITAI && kOwner.AI_totalAreaUnitAIs(area(), ((UnitAITypes)(kUnit.getDefaultUnitAIType()))) == 0)
	{
		iValue += iNumCitiesInArea;
	}
	//This forces the AI to build neccessary buildings for units. 
	
	UnitAITypes eUnitAI = (UnitAITypes)(kUnit.getDefaultUnitAIType());
	
	iTempValue = 0;
	
	switch (eUnitAI)
	{
		case UNITAI_UNKNOWN:
		break;
		case UNITAI_ANIMAL:
			iTempValue += kUnit.getCombat() / 5;
			break;
		case UNITAI_SETTLE:
		case UNITAI_SETTLER_SEA:
			iTempValue += 25;
			break;
		case UNITAI_WORKER:
		case UNITAI_WORKER_SEA:
			iTempValue += std::max(0, AI_getWorkersNeeded()) * 10;
			break;
		case UNITAI_ATTACK:
		case UNITAI_ATTACK_CITY:
		case UNITAI_COLLATERAL:
		case UNITAI_PILLAGE:
		case UNITAI_RESERVE:
		case UNITAI_COUNTER:
		case UNITAI_CITY_DEFENSE:
		case UNITAI_CITY_COUNTER:
		case UNITAI_CITY_SPECIAL:
		case UNITAI_ATTACK_SEA:
		case UNITAI_RESERVE_SEA:
		case UNITAI_ESCORT_SEA:
		case UNITAI_ASSAULT_SEA:
		case UNITAI_CARRIER_SEA:
		case UNITAI_MISSILE_CARRIER_SEA:
		case UNITAI_PIRATE_SEA:
		case UNITAI_ATTACK_AIR:
		case UNITAI_DEFENSE_AIR:
		case UNITAI_CARRIER_AIR:
		case UNITAI_MISSILE_AIR:
		case UNITAI_PARADROP:
		case UNITAI_ATTACK_CITY_LEMMING:
[COLOR="Red"]			iTempValue += std::max(6, (kUnit.getCombat() * kUnit.getCombat())) / 6;[/COLOR]
			break;
		case UNITAI_EXPLORE:
		case UNITAI_MISSIONARY:
		case UNITAI_PROPHET:
		case UNITAI_ARTIST:
		case UNITAI_SCIENTIST:
		case UNITAI_GENERAL:
		case UNITAI_MERCHANT:
		case UNITAI_ENGINEER:
		case UNITAI_SPY:
		case UNITAI_SPY_SEA:
		case UNITAI_MISSIONARY_SEA:
		case UNITAI_EXPLORE_SEA:
			iTempValue += 10;
			break;
		case UNITAI_ICBM:
[COLOR="red"]			iTempValue += kUnit.getNukeRange() * 50;[/COLOR]
			break;
	}
	if (bWarPlan)
		iTempValue *= 2;

	if (iTempValue > 0)
	{
		//	Just because we can build new units here doesn't add much if we can already
		//	build them a ton of other places
		iTempValue = (iTempValue*3)/(3+std::min(10,kOwner.countNumBuildings(eBuilding)));
	}

	iValue += bUnitIsBonusEnabled ? iTempValue : iTempValue/5;
}


Important bits are in red. This code is for the AI, in valuing BUILDINGS. Not units. Late game, unit strengths are very high. So a building that unlocks a combat unit is given a high weight. But A nuke with a small range is given nearly no weight. 50 combat x 50 combat = 2500. 8 Range nuke is 400. I can tell you which unit the AI should prefer. (Hint: The nuke). I think the nuke range value should be squared, just like the combat. Leave the * 50 for good measure.

Ok that should help the AI build stuff to unlock nukes. For the units themselves, they still have issues.

2.) AI does not properly value Nuke units

(As far as I can tell, USE_UNIT_TENDERING is off. Is this correct? I checked the makefile: http://svn.code.sf.net/p/anewdawn/code/Trunk/Sources/CBMakefile )

Basically in the code where cities choose to build units, cities only have two real chances to even select building nukes. The first chance is about half-way, in terms of code. Workers, city defense, etc, are all way above this. So if the AI needs more workers, or hasn't got enough defenders, well that sucks for the AI then, because they won't build nukes. IMO, there should be an earlier additional check. Basically something like this:

Code:
if city is tier 1 production city (in the top 3 hammer producing cities in the nation)
     if city is not in immediate danger from enemy units and has > 3 defenders
          if we are at war, or are planning war, or another player already has a nuke
               try and build a nuke

Obviously not real code, but you get the idea. I'd stick it in CvCityAI, before this bit:

Code:
if( !bInhibitUnits && !(bDefenseWar && iWarSuccessRatio < -50) )
	{
		if ((iAreaBestFoundValue > iMinFoundValue) || (iWaterAreaBestFoundValue > iMinFoundValue))
		{
			// BBAI TODO: Needs logic to check for early settler builds, settler builds in small cities, whether settler sea exists for water area sites?
			if (pWaterArea != NULL)
			{

That code is for early settlers, and frankly, if nukes are available, settlers don't matter that much anymore. So extra nuke logic before settlers. Early game AI will just skip it since UNITAI_ICBM will return no units available.
 
@Thunderbrd

The AI promotion evaluation in CvPlayerAI::AI_promotionValue has some issues.
Some tags add to iValue without checking if the evaluated promotion even has a value in that tag.
Example:
Code:
	iTemp = kPromotion.isOneUp();
	if ((eUnitAI == UNITAI_RESERVE) ||
		  (eUnitAI == UNITAI_COUNTER) ||
			(eUnitAI == UNITAI_CITY_DEFENSE) ||
			(eUnitAI == UNITAI_CITY_COUNTER) ||
			(eUnitAI == UNITAI_CITY_SPECIAL) ||
			(eUnitAI == UNITAI_ATTACK))
	{
		iValue += 20;
	}
	else
	{
		iValue += 5;
	}

should at least be like this
Code:
	if (kPromotion.isOneUp())
	{
		if ((eUnitAI == UNITAI_RESERVE) ||
				  (eUnitAI == UNITAI_COUNTER) ||
					(eUnitAI == UNITAI_CITY_DEFENSE) ||
					(eUnitAI == UNITAI_CITY_COUNTER) ||
					(eUnitAI == UNITAI_CITY_SPECIAL) ||
					(eUnitAI == UNITAI_ATTACK))
			{
				iValue += 20;
			}
			else
			{
				iValue += 5;
			}
	}
 
@Thunderbrd

The AI promotion evaluation in CvPlayerAI::AI_promotionValue has some issues.
Some tags add to iValue without checking if the evaluated promotion even has a value in that tag.
Example:
Code:
	iTemp = kPromotion.isOneUp();
	if ((eUnitAI == UNITAI_RESERVE) ||
		  (eUnitAI == UNITAI_COUNTER) ||
			(eUnitAI == UNITAI_CITY_DEFENSE) ||
			(eUnitAI == UNITAI_CITY_COUNTER) ||
			(eUnitAI == UNITAI_CITY_SPECIAL) ||
			(eUnitAI == UNITAI_ATTACK))
	{
		iValue += 20;
	}
	else
	{
		iValue += 5;
	}

should at least be like this
Code:
	if (kPromotion.isOneUp())
	{
		if ((eUnitAI == UNITAI_RESERVE) ||
				  (eUnitAI == UNITAI_COUNTER) ||
					(eUnitAI == UNITAI_CITY_DEFENSE) ||
					(eUnitAI == UNITAI_CITY_COUNTER) ||
					(eUnitAI == UNITAI_CITY_SPECIAL) ||
					(eUnitAI == UNITAI_ATTACK))
			{
				iValue += 20;
			}
			else
			{
				iValue += 5;
			}
	}
Good point... I'll look through those and try to spot and fix them if you haven't already.
 
I'm in the middle of a fresh playthrough, and the AIs continue to be a bunch of sad sacks who have no idea how to wage war. I'd decided to give Ruthless AI a try, to see if it would give them a bit more get up and go.

We're in Late Classical at this point.

The Ottomans and the Native Americans have been at war since they first met, 600 turns ago. So far their hostilities have amounted to the Ottomans twice knocking down a freshly placed Native American City.

Beyond that, they just stand and glare at eachother. They don't even beat up eachothers units outside the cities. Even though the Native Americans have but one city, and the Ottomans have 11. They seem to have no idea how to go about taking an established city, and so decide that it is hopeless to try. I continue to be suspicious that this has to do with excessive amounts of City Defense, and changes made to early siege engines.

Even so, the Ottomans have arsonists. I can see them right there. They just don't seem to know what to do with them.

It's an odd thing that the Native Americans have only one city. They had beautiful open land to their west for millennia, but they fixated on a point to their north. They built there twice, each time getting knocked down by the Ottomans (who are to their east). When my borders grew and made that spot no longer sensible, they simply stopped trying to settle at all, even though they had excellent land available. Are they getting stuck on one settling location, and not able to change their minds?

The rest of the world is doing no better. Occasionally somebody declares war, but no cities actually change hands. They don't even seem up to the job of dealing with barbarian cities. With a few exceptions, they are doing a very poor job of expansion.
 
I'm copying this over here for Alberts and I to look into in our codes. Understanding some of Koshling's structure here better for Nukes is not all I'm hoping to divine in this post - there's indications of ways other problems we also have may be resolved here (like the ai not building NEARLY enough siege weaponry.) But a lot of these were deeply valuable points so I wanted to be able to find them again a little easier and share them as food for thought.

Unit tendering certainly should be on, unless that area has been radically changed since I was working on it!
 
Unit tendering certainly should be on, unless that area has been radically changed since I was working on it!

No, it's still very much active. I've come to understand that structure much better recently and I did manage to get the AI to finally value siege weapons a lot more appropriately I think from the games I've seen so far.

That's one win but there's many more still to go.

As for the nuke stuff I was merely passing along what Afforess had done and wondering if we might want to implement some of that as well as I'm not really sure how well it really interacts with the current unit tendering.
 
I've just taken two medieval/renaissance cities with my industrial army, and it seems they don't build defensive units anymore. They had 400+% fortifications, but once I got that down, it was all over: 1 organ gun, 1 crusader, and a half-dozen law enforcement and health units.

While I was besieging, they were building... geology labs!!!

While I did have tech superiority, they could have had a stack of CG3 something-or-others, and I might have at least lost some riflemen, rather than about two siege rams.

I really hope this isn't the AI's response to the new siege warfare system...
 
The Ottomans and the Native Americans have been at war since they first met, 600 turns ago. So far their hostilities have amounted to the Ottomans twice knocking down a freshly placed Native American City.

Beyond that, they just stand and glare at eachother. They don't even beat up eachothers units outside the cities. Even though the Native Americans have but one city, and the Ottomans have 11. They seem to have no idea how to go about taking an established city, and so decide that it is hopeless to try. I continue to be suspicious that this has to do with excessive amounts of City Defense, and changes made to early siege engines.

Even so, the Ottomans have arsonists. I can see them right there. They just don't seem to know what to do with them.

A while back, I had a large barb stack come for one of my cities, but the shortest path meant coming via a desert tile next to the city (with terrain damage on). After a turn on that tile, it seems they were deciding they were no longer strong enough to attack. They never attacked. They just went back and forth between the desert tile and the one beyond it. For centuries! Of course eventually I built a tech-superior force to [go the long way round and] clean them up.

This was early game. Later on you get the same effect from city defence buildings (ie. traps etc.)

Having decided they are no longer strong enough for the assault, it would be nice if they could learn to either: go away/make peace; or: calculate how many reinforcements are needed, and build them. But I think maybe as soon as they heal up, they've forgotten what happened and think they're strong enough again...
 
Top Bottom