A Better AI.

I am pursuing starting a sub forum.

YAY! All hail Iustus!

seriously, good choice there. It will severely help. 89 pages takes a long time to read through. (90 Now :)) And with several discussions going on in one thread, it makes it hard to follow ANY discussion.

You have my Thanks

The M'Hael
 
Iustus,
Just some small ideas for unit actions. It's your decision whether you think they're worthwhile or not; you might consider them too minor to worry about.

-If a unit needs healing, and a friendly city is close, consider using the friendly city for healing instead of a home city, since the heal rate is the same in both. (I noticed in one of your recent posts, which detailed the order of preferred actions for attack units, that damaged units might move to a home city for healing.)

-Staging cities or tiles when possible should be chosen so they are not visible to other players - particularly hostile ones - whether through religions or unit line-of-sight. Or, if wanting to show military strength (real or feigned), consider deliberately making them visible in border cities. I guess this is only really important against human players. That is, I'm not sure how AI decisions are affected when unit stacks are in plain sight.

Cheers
 
I agree that now AI defense capabilities are nearing a very good level while their offense skills still have to be improved more.

A real gain in war is only taking cities and vassalizing rivals so AI's have to concentrate on these goals in their offensive wars.

I think an AI offensive stack should consist of 1/3 siege units and 2/3 high strenght combat units, a bit mixed in type not just mounted or melee etc.
With that setup i think they can capture cities (and raze them if it's impossible to hold them like in invasion war, to try vassalization).

Very important to constantly bring in reinforcement siege units because of their 'suicide' nature to keep the offensive rolling.

After capturing a city that seems could be held some city defense units should be moved in shortly like longbowmen.

Something that still surely needs improving is invasion.
To constantly reinforce the beachhead with new units.
That needs to set up many homeland cities to produce units, designate a harbour-city gathering point for them, and to make sea transport units constantly moving up and down between the gathering point (taking the units) and the beachhead (dropping them) and still provide adequate defense for the sea transports.
Not too easy to code i can imagine.

Also sometimes it just impossible to hold cities on a strong enemy continent so in this case the attacker AI might try to concentrate on razing them for vassalization.

I think too that AI pillaging is also necessary to make building (fast) attack type units for defensive purposes a necessity.

I hope overseas wars will come back they'll be fun after the AI will manage them to be dangerous.

And i hope ultimately we shall get an AI capable of defending itself but also to go on domination.

Thanks for the good work once again Blake and Iustus !
 
To Kettyo:

GREAT post.

You eloquently wrote what I've been thinking but have been unable to put into words.

Thank you for writing that :)
 
Would it be possible to alter the logic for building the UN?

I have had 2 games recently where I have been 1st in score (due to population and vassaled land area) but third in tech and power (by a long way). In this situation I tend to suck up to the more powerful people to make them like me.

In 2 games one of the 2 AI's beating me in tech has built the UN. My vassals vote for me, the other powerful AI votes for me (as I have been so nice to him) and I get elected. I then suggest voting for me as the diplomatic winner, and succeed.

In these 2 games I had no chance of winning up until then.

The AI that built the UN had no chance of being elected as the president as no one liked them, therefore they should not of bothered with the UN.

Could the AI logic be changed so that if they are unpopular they will not build the UN?
 
i was tried to recompile SDK with defined
FASTER_VISIBILITY_NON_SAVE_COMPATABLE

but compilation failed in CvPlot::changeAdjacentSigh
Code:
ifdef FASTER_VISIBILITY_NON_SAVE_COMPATABLE
	// get list of visible plots 
	CLinkList<CvPlot*> visiblePlotList; 
	[B]getVisiblePlotsList(visiblePlotList, eTeam, iRange);[/B]

	// change visibility
	for (CLLNode<CvPlot*>* pNode = visiblePlotList.head(); (pNode != NULL); pNode = visiblePlotList.next(pNode))
	{
		pNode->m_data->changeVisibilityCount(eTeam, ((bIncrement) ? 1 : -1), eSeeInvisible);
	}

	return;
#endif

getVisiblePlotsList identifier not found --- this function is not declared nor defined in SDK code
was previously defined in CvPlot.h in rev. 255, then removed in revision 269
 
Quite a lot of the unit stuff is going to be improved in the next build. The defender code changes a lot in several ways (how it's trained, how it's used, and more), one change is the AI now waits for real units before committing to a defense, "archer spam wars" should be quite unlikely.

Declare war code also changes. At the moment it's pretty crazy especially on Aggressive AI. You wont be complaining about the AI's being too peaceful... the AI now performs disruptive early attacks so take care with those farmers gambits... this behavior isn't so much coded in, but a result of them being more fluid with their units.
The AI should also be far less likely to just sit on a winning army, it should use it.

Expansion and wonder building and unit building is better balanced out.

Some tweaks to the governor to do with extreme cases and food - like the governor will make a good honest effort to work 6f tiles and he'll recognize when it's definitely better to go with a 2f tile than a 1f1h tile... he'll also favor hammers more at the other end of the spectrum. This stuff seems to be working pretty good.

There should be a new build tomorrow.
 
i was tried to recompile SDK with defined
FASTER_VISIBILITY_NON_SAVE_COMPATABLE

but compilation failed in CvPlot::changeAdjacentSigh
Code:
ifdef FASTER_VISIBILITY_NON_SAVE_COMPATABLE
	// get list of visible plots 
	CLinkList<CvPlot*> visiblePlotList; 
	[B]getVisiblePlotsList(visiblePlotList, eTeam, iRange);[/B]

	// change visibility
	for (CLLNode<CvPlot*>* pNode = visiblePlotList.head(); (pNode != NULL); pNode = visiblePlotList.next(pNode))
	{
		pNode->m_data->changeVisibilityCount(eTeam, ((bIncrement) ? 1 : -1), eSeeInvisible);
	}

	return;
#endif

getVisiblePlotsList identifier not found --- this function is not declared nor defined in SDK code
was previously defined in CvPlot.h in rev. 255, then removed in revision 269

Sorry about that. I put that #define in to test how much of a speed increase there was when using my much faster algorithm for doing the calculations of which plots are visible. (It is not save file compatible to do it though). I still use that algorithm in cases where the actual visiblity count does not matter, like when I want to build a list of the plots you can see from somewhere, for the new explorer code. But I have to use the slower method when calcualting actual visibility, as for the fogbusting algorithm, and the actual visiblity calcs (although I did speed that up by only doing it once per unit on a plot with the same visibility range).

For right now, I am going to say that #define does not work. I could make it work, if someone wanted to do some extensive speed testing with it, but right now, it is not properly implemented. Being as there are many ways to speed it up, depending on how much you want to redo, I did not continue to pursue in that direction, at least until post 1.0 release. One of the things I want to do for CvPlotRegion is to convert it to run encoded regions, making them super fast.

All that said, you can make the #define work if you want by using the new function with similar parameters, and convert the iteration to use the new data structure:

Code:
	// get list of visible plots 
	CvPlotRegion visiblePlotRegion;
	addVisiblePlots(visiblePlotRegion, iRange, eTeam);

	// change visibility
	for (CvPlotRegionConstIterator it = visiblePlotRegion.begin(); it != visiblePlotRegion.end(); it++)
	{
		XYCoords xy(getXYCoords(it));
		CvPlot* pLoopPlot = GC.getMapINLINE().plotSorenINLINE(xy.iX, xy.iY);
		pLoopPlot->changeVisibilityCount(eTeam, ((bIncrement) ? 1 : -1), eSeeInvisible);
	}

	return;

Please note, I added that for my own curiousity, to see how much of a speed improvement it gave on AI turns. It is not as well tested as using the regular method. (It speed up the turn from 1 minute to 40 seconds, but that one just the one test, I did not repeat it, so for all I know, it could have just been a caching issue, totally unrelated to this change).

Note, if you are going to test with this, you probably want to either #undefine NEW_VISIBILITY_IMPLEMENTATION, or update it to do things the faster way by changing void addVisiblePlots(CvPlotDataRegion& visiblePlots, int iX, int iY, int iRange, int iObserverCount, TeamTypes eTeam) to work like void addVisiblePlots(CvPlotRegion& visiblePlots, int iX, int iY, int iRange, TeamTypes eTeam)
, which uses the faster algorithm. (You can just replace all the guts, and change the insert to also set the value to iObserverCount at each plot). In fact, you almost certainly are going to have to change addVisiblePlots(CvPlotDataRegion, ...) or the fogbusting code will make some silly mistakes.

If you do make this change, your save files will be storing different values in the visibility field, so they will not be compatible with a regular save. And you probably want to start a fresh game, or force a recalculation (it does a full recalc when your visibility over water goes up by one). If you like, you can just call that function when loading from a save, but make sure you call it after teams are loaded, I would suggest calling it from CvGame::setFinalInitialized, you can see the lines there commented out that you would need.

There will be no warning that your save file is not compatible, visibility will just have all sorts of strange bugs if you use a save from the wrong version.

-Iustus
 
Quite a lot of the unit stuff is going to be improved in the next build. The defender code changes a lot in several ways (how it's trained, how it's used, and more), one change is the AI now waits for real units before committing to a defense, "archer spam wars" should be quite unlikely.

Declare war code also changes. At the moment it's pretty crazy especially on Aggressive AI. You wont be complaining about the AI's being too peaceful... the AI now performs disruptive early attacks so take care with those farmers gambits... this behavior isn't so much coded in, but a result of them being more fluid with their units.
The AI should also be far less likely to just sit on a winning army, it should use it.

Expansion and wonder building and unit building is better balanced out.

Some tweaks to the governor to do with extreme cases and food - like the governor will make a good honest effort to work 6f tiles and he'll recognize when it's definitely better to go with a 2f tile than a 1f1h tile... he'll also favor hammers more at the other end of the spectrum. This stuff seems to be working pretty good.

There should be a new build tomorrow.

I'm looking forward to the new build after reading this. :)

But I didn't quite understand what you meant by: "one change is the AI now waits for real units before committing to a defense, "archer spam wars" should be quite unlikely."

Does this mean that the AI only starts to build larger numbers of defenders after its opponents have axemen and swordsmen as before that time the opponent is less of at threat? Or does it mean that the AI dislikes archers as a defending unit? Archers are quite capable defenders allthough axemen are better against swordsmen. But axemen are also more expensive. What exactly do you mean by this remark?

I usually play with the aggressive AI setting because the AI in normal games is pretty passive. Do you recommend playing with the standard AI in this new build?
 
Does this mean that the AI only starts to build larger numbers of defenders after its opponents have axemen and swordsmen as before that time the opponent is less of at threat? Or does it mean that the AI dislikes archers as a defending unit? Archers are quite capable defenders allthough axemen are better against swordsmen. But axemen are also more expensive. What exactly do you mean by this remark?

I don't know what Blake meant, but I know what I think: One Archer, one Axeman and one Spearman are a better defense than the five or six Archers commonly seen with the 1-8 build. This is especially true if the right defender can pop out and knock off a pillager when the moment is right. Then, as soon as Construction is finished, add a Catapult or two to the mix and that's a pretty solid defense.
 
I don't know what Blake meant, but I know what I think: One Archer, one Axeman and one Spearman are a better defense than the five or six Archers commonly seen with the 1-8 build. This is especially true if the right defender can pop out and knock off a pillager when the moment is right. Then, as soon as Construction is finished, add a Catapult or two to the mix and that's a pretty solid defense.

Ok, I can agree with that. Maybe, he did mean that. Still, the AI also has to defend itself before those units are available. 1 single archer will hardly stop anything. But I don't think that Blake will let the AI defend itself poorly after all these changes, so I don't think I will have to fear a 1 archer defence.

I still hope that Blake could explain what he meant. :)
 
I really like what the BetterAI team has been doing and have transferred the SDK mods I am working on to a BetterAI platform, with each option I am using #ifdefed so I can do configurable builds.

As I understand Torteise/SVN, it should be possible to form a BRANCH of the BetterAI source code called EusebiusMods or something. But apparently I need to be granted some permissions on SourceForge to do this. Who do I need to speak to about this?

To clarify, I am not asking to have my code incorporated into this mod, I would simply like to store my SDK source code in your SourceForge project for anyone to use. As my code is 95% the same as yours, the storage needs should be insignificant.

[That said, I have tweaked the way the AI values civics, which might be of interest to this thread.]

Thanks,
Eusebius
 
I really like what the BetterAI team has been doing and have transferred the SDK mods I am working on to a BetterAI platform, with each option I am using #ifdefed so I can do configurable builds.

As I understand Torteise/SVN, it should be possible to form a BRANCH of the BetterAI source code called EusebiusMods or something. But apparently I need to be granted some permissions on SourceForge to do this. Who do I need to speak to about this?

To clarify, I am not asking to have my code incorporated into this mod, I would simply like to store my SDK source code in your SourceForge project for anyone to use. As my code is 95&#37; the same as yours, the storage needs should be insignificant.

While the needs of one mod might not be a big deal, there are quite a few people who would end up asking for this. In addition, it is not really needed, because of the way SVN works.

Please take a look at my documentation on merging sources using SVN (that is the link on sourceforge, you can also find it hunting this thread). If you set things up properly, you can make this a 99% automated process.

You could set up your own SVN repository (on your own sourceforge project or just locally on your hard drive), and then include the betterai sources as a seperate branch, as what is refered to in SVN circles as a 'vendor drop'. This is exactly the same way that there is a 'firaxis' branch in the betterai SVN repository that we use as a vendor drop.

If one of your goals is to make the source easy for anyone to download, it is relatively easy to get your own sourceforge project, search around sourceforge and you should find the instructions for submitting a proposal. It takes a week or two for the process, so get started sooner rather than later.

Or, following the instructions I posted, just do a merge from the betterai sources to your sources every time you want to grab a drop.

Or do the same, but do a merge from your sources to a betterai checkout. (The second option in that documentation).

There are at least 3 ways you could set this up and make it almost completely automated. Which one makes the most sense depends on how often you make changes, how extensive they are, and just what you feel like doing. If you do not have many changes, and you make them infrequently, then the first option that I posted in the documentation is probably the best choice.

Hope that helps,

[That said, I have tweaked the way the AI values civics, which might be of interest to this thread.]

Once we get the subforum set up, it would be appropriate for you to make a post about what changes you have made, and why. We can discuss whether they make sense to be incorporated in betterai or not.

-Iustus
 
The AI that built the UN had no chance of being elected as the president as no one liked them, therefore they should not of bothered with the UN.

Well, there's still the Good Cause of spreading the Most Excellent civics, most notably Environmentalism. :lol:

Seriously, if the AI is to be allowed to build the UN then it should check at least what's good for it. Environmentalism generally gets a carload of votes. Would it be possible to set things so that leaders at least vote responsibly?

Let's stay on said Environmentalism, the bane of so many players. Doing a bit of an Asimov inpersonation, I'd say it should decide like this:
1 - check if Environmentalism is an anailable civic for itself; if yes, move to point three;
2 - check its economy and determine if it would be beneficial to it. If so, then vote Yes;
3 - consider how advantageous such a turn of events would be on the global scale, assignating modifiers to how much would it damage rivals and allies. The philosophy being roughly that if it's harmful to me and my flunkies, but catastrophic to my enemies, then vote Yes, otherwise, No;
4 - vote No on principle: if there's nothing to be gained in compensation for the loss of sovereignity, it would be foolish to go for it.

Well, at least it's a draft...

EDIT: and even before building the UN, an AI should at least check its chances of getting into office.
 
There should be a new build tomorrow.

Any luck chasing down bugs that could have been causing the multiplayer OOS? I plan on trying to start an MP game tomorrow night and would like to incorporate the newest Better AI if its solid for MP.

The late December builds seemed rock solid for MP play (at least for 2 players). We never tried with the 1/16 Asserts build but others reported problems with OOS.

Thanks!
 
I too would be very interested in hearing about if the Better AI team has had any luck tracking down OOS errors. We're planning on having a small lan party later this evening, and would love to use the mod.
 
Add another request for any info on the multiplayer status.

My brothers and I are in the middle of a Better AI game. We play a couple of hours at a time, and are due to meet again for another Lan session this Sunday. Following the OOS reports we decided to use an early December build (and we are finding the AI easier than I remember when I tried it single player :confused: )

I would be keen to replace that build with a later build so long as there was little chance of OOS errors.
 
Any luck chasing down bugs that could have been causing the multiplayer OOS? I plan on trying to start an MP game tomorrow night and would like to incorporate the newest Better AI if its solid for MP.

The late December builds seemed rock solid for MP play (at least for 2 players). We never tried with the 1/16 Asserts build but others reported problems with OOS.

Thanks!

I too would be very interested in hearing about if the Better AI team has had any luck tracking down OOS errors. We're planning on having a small lan party later this evening, and would love to use the mod.

Add another request for any info on the multiplayer status.

My brothers and I are in the middle of a Better AI game. We play a couple of hours at a time, and are due to meet again for another Lan session this Sunday. Following the OOS reports we decided to use an early December build (and we are finding the AI easier than I remember when I tried it single player :confused: )

I would be keen to replace that build with a later build so long as there was little chance of OOS errors.

The new build will include the changes from the 1/16 build. This will definitely fix some of the problems. Since so few people who play multiplayer actually tried the 1/16 build, it is hard to say whether all the problems are fixed or not. There was one report of a problem, but no details were given, and I do not know how indicitive of the problem it is.

We cannot track this problem down without the help of the people who are playing multiplayer games. The more detail you can give us, the better.

-Iustus
 
Top Bottom