telling the ai where to go?

Thanks Carboniferous for the info!
Didn't know that.

Jamie - according to this, other things might go wrong if you mess with areas.
You'll need to make sure other features (path finding etc.) work properly.

I also suggest modifying the function that recalculates so editing the map won't reset everything (I think I mentioned it somewhere).
 
how? I will probably need alot of help knowing this then...
 
:dunno:
Look at the code and find where areas are used.
I'm not even sure we can see all the places.

I must warn you that I won't have much time. I'll try to help you when I can, but it might not be much.
 
I tried the areas thing, so here's a word of warning: if you edit the areas manually, the AI will fail miserably. For Rhye it kind of works, because it's only done once IIRC and the border runs along natural borders... but if you separate an actual continent into several areas, the result will be very very bad.

Areas are land masses/continents/bodies of water and the AI treats them areas as such. If you divide a continent into 6 areas the AI will consider it to be 6 islands. It will not connect cities between areas (unless it happens accidentally), and more importantly, it will not properly move units between them, i.e. the only way for German AI to attack France would be naval invasion... (speaking from experience - I tried this approach in the Sword of Islam). There are other consequences like Germany vs. France being overseas but lack of unit movement is bad enough...

What you should do is use CvPlayerAI::AI_targetCityValue() which was mentioned earlier. Look at the code of Rhye's and Fall. It uses a 2d array for each civ to increase or decrease the value of every map tile. In my experience even if you use extreme values, the AI will still stray from the path and go for other cities, but it works very well as a general "AI guide for cities" and everyone who played RFC can confirm this.
 
interesting, can I have some sample code posted here please

(btw I downloaded sword of islam yesterday :D)
 
a sample code of what?

If you downloaded SoI, it comes with full source code. To see how to set up areas, look at CvMap::calculateAreas, mine/Rhye's code is marked there. You can see most of it is commented out, because I disabled the division of Eurasia into Near East, Persia and India for the reasons given in my previous post. The remaining code simply turns parts of Arabian peninsula into islands, because they're effectively separated from rest of the continent by impassable desert:

Code:
	CvArea* oman = addArea();
	int omanID = oman->getID();
	oman->init(omanID, false);

	for (iX = 0; iX < EARTH_X; iX++)
	{
		gDLL->callUpdater();
		for (iY = 0; iY < EARTH_Y; iY++)
		{
			if (regionMap[EARTH_Y -1 -iY][iX] == 30)
			{
				if (!plotSorenINLINE(iX, iY)->isWater())
					plotSorenINLINE(iX, iY)->setArea(omanID);
			}
		}
	}

EARTH_X and EARTH_Y are map size constants. regionMap you can check in CvRhyes.cpp, you don't have to use it, it's just my 2d array that divides the map into regions, and 30 is the code for Oman. Rhye just typed the coordinates manually. What the above does is that it creates a new area ID and then applies it to selected plots, turning them into a continent.

***

For how to deal with the AI values, just look at CvPlayerAI::AI_targetCityValue, in particular this part:

Code:
	//Rhye - start

	if (settlersMaps[getID()][EARTH_Y - 1 - pCity->plot()->getY_INLINE()][pCity->plot()->getX_INLINE()] <= 3)
		iValue = iValue/3 - 4;
	else if (settlersMaps[getID()][EARTH_Y - 1 - pCity->plot()->getY_INLINE()][pCity->plot()->getX_INLINE()] <= 20)
		iValue -= 3;
	else if (settlersMaps[getID()][EARTH_Y - 1 - pCity->plot()->getY_INLINE()][pCity->plot()->getX_INLINE()] >= 500) //500-700
		iValue = 2 + iValue*3;
	else if (settlersMaps[getID()][EARTH_Y - 1 - pCity->plot()->getY_INLINE()][pCity->plot()->getX_INLINE()] >= 300) //300-400
		iValue = 2 + iValue*2;
	else if (settlersMaps[getID()][EARTH_Y - 1 - pCity->plot()->getY_INLINE()][pCity->plot()->getX_INLINE()] >= 150) //150-200
		iValue += 3;
	else if (settlersMaps[getID()][EARTH_Y - 1 - pCity->plot()->getY_INLINE()][pCity->plot()->getX_INLINE()] >= 40) //40-60-90
		iValue += 1;

settlersMaps is a 3d array... or an array of 2d map arrays... also found in CvRhyes.cpp

settlersMap[id][x][y] = value of the plot (x,y) for player with this id. Mind you, this is for a scenario so IDs are always the same.

the code above makes sure that if the value of a plot is high, i.e. 400, the AI should value it highly, and when it's very low, i.e. 3, the AI should think it's useless.

RFC is rather complicated... I'm not sure what are you trying to achieve, but a similar thing can be done with much less work and Python only, although it's a bit artificial - you can make sure that the AI periodically declares wars on specific targets that have cities or plots defined as lists or coord sets.
 
thats great, I will take a look to see what I am able to find
 
Top Bottom