Better than BTS

Yakk

Cheftan
Joined
Mar 6, 2006
Messages
1,288
BTS AI kicks ass. I think we can make it better.

First, making the AI smarter.

We need a better power graph. As it stands, the power graph more closely reflects "total number of shields of units" more than "total power of units".

Second, there are AI tweaks that can make the game better, without making the AI better, if you get my drift.

Proposal: When the AI passes the following thresholds, it should make an offer to you:
1> I'm willing to call this war off if you will call this war off.
2> I'm willing to give up a city to call this war off.
3> I'm willing to capitulate and become a vassal state to call this war off.

Having to check each turn if your victim will capitulate is rather annoying, and if you fail to check each turn the AI is likely to surrender to some other AI.
 
BTS AI kicks ass. I think we can make it better.

First, making the AI smarter.

We need a better power graph. As it stands, the power graph more closely reflects "total number of shields of units" more than "total power of units".

Second, there are AI tweaks that can make the game better, without making the AI better, if you get my drift.

Proposal: When the AI passes the following thresholds, it should make an offer to you:
1> I'm willing to call this war off if you will call this war off.
2> I'm willing to give up a city to call this war off.
3> I'm willing to capitulate and become a vassal state to call this war off.

Having to check each turn if your victim will capitulate is rather annoying, and if you fail to check each turn the AI is likely to surrender to some other AI.

I'm definitely in favor of improving whatever can be improved. But can't the last problem you mentioned be fixed simply by a pop-up box or other indicator that the other civ is ready to surrender? (E.g., "Mansa Musa announces that he is willing to negotiate an end to the war." if the civ just wants a cease-fire in place, or "Catherine announces that she is willing to discuss surrender terms." if the civ is ready to capitulate.)
 
Sure, that is why it isn't really an AI improvement, but it is an improvement in the interface between the player and the AI.

I figure the AI offering surrender (starting negotiations) when it becomes willing to surrender to the player whose turn is active would work.
 
I just realized there's another bit of quirky behavior in the closeness code which we could remedy. Here are two situations, X and Y are cities and 0 is land and * is water:

Two cities on opposite sides of a large bay

00000Y
00****
0*****
00****
00000X

Like before but one city is on a separate island

*****Y
******
0*****
00****
00000X

In scenario 1, since the cities are in the same area (ie connected by land tiles) CvCityAI::AI_playerCloseness will do a second check of proximity using the path length between the cities (GC.getMap().calculatePathDistance(plot(), pLoopCity->plot())). The path is 10 tiles long, so they will not be considered close.

In scenario 2, because the cities are in different areas so the "as the crow flies" distance between them is divided by 2 and they will be considered quite close.

There are other related scenarios which also could be potentially improved. Right now a city will consider itself close to a city 10 tiles away on another island but not to a city 10 tiles away up the coast.

This kind of quirky behavior would really affect AI decisions when playing a Inland Sea map, on a map of the Mediterranean (ha, I actually spelled that right on the first try!), or on similar situations in other maps.

I haven't figured out exactly what I would propose in this regard but basically if both cities are coastal we could add some kind of check for the path length through water. Alternatively, if the cities are both coastal we could check if they're on the same body of water by comparing area ids for water plots around them and if they are then divide the stepDistance by 2 as in the different areas case.
 
Note, you can ask one of the Mods to split the posts from the unnoficial patch to here. I recently requested as such for a thread that went completely offtopic into a new mod/design idea.
 
I thought we'd remove the / 4 when adding closeness for everyone.

Comments I have are on testing this build:
OptionA, Option C and CvTeamAI :: startWarVal iClosenessValue != 0: iValue += iClosenessValue/1

I think this build is another improvement again with one possible exception. The upside is that on standard settings the regional war declarations do not crowd out other types of war declarations which is excellent, and it seems more dynamic, real and good with more warfare commensurate with the context.

On the downside, I think I have observed one "tactical" potential issue that is not serious but might be enough to trigger a stressed AI developer to get overly cautious especially if an AI dows on a human.

Neighbour 1 DOWS on Neighbour 2. The power graph says it's fine to do so and the overall defenses of 2 across all cities are warranting an attack. However 1 does not give complete heed to the defenses of the specific border city it is going to attack in some cases *I think*. This can result in a "small degree" to the attacker loosing a border war more often than it should *perhaps*. However it's difficult because there is more to a border attack than just capturing a city....

So in summary:
startWarVal iCloseness != 0 at : iValue += iClosenessValue/4 (very conservative)
or
startWarVal iClosenessValue != 0 at : iValue += iClosenessValue/2 (still conservative or correct)
or
startWarVal iClosenessValue != 0 at: iValue += iClosenessValue/1 (possibly detrimental)

Here are some questions:
1) startWarVal iClosenessValue == 0: that /4 should be left alone in all cases yes?
2) what algorithm is the attacker using to judge the defense of his neighbouring opponent?


Cheers
 
These comments are an "aside" to the short term improvements *I think* that have already been made. I'm thinking the quality of war declarations not quantity at the moment:

1) Examine the inter-relationship between iValue += iClosenessValue / 1 in startWarVal and the closeness equation in cvcityAI. Reason why I say this is the possibility that the closeness equation redistributes city defenders away or towards border cities and thus has a bearing tactically on increased neighbour wars with closeness/1 in startWarVal. Am I deluded thinking this? Could this be a genuine "quality" aspect. The question to me is how option C (->getPopulation + getPopulation) effects this. The whole question of defense distribution is interesting.

2) Boost the default closeness range - If this improves the quality of border war declarations then it's interesting. I'm always lagging in thought time between Yakk and Jdog but to clarify for me -> default closeness has an effect on the cvcityai closeness array values because of the call to calculatePathDistance. Is this the bottom line of this idea? But the quality of border war declarations is actually totally dependent on the quality of the calculation in the function calculatePathDistance? So that if a city is 6 away from another city but it's path distance is 7, it's closeness should be rejected? I need clarification before I can pursue this angle.

Cheers.
 
I have contacted the admin of the BetterAI sourceforge project about getting access to that as a repository for our developments. If that doesn't pan out we can apply for a new project.

Yeah for the first time in a long time, I have packed away the magnificent "Revolutions" mod for a while because even at this early stage of the project, the game is much more *dynamic* even without adding a revolution. That said, the Revolution mod is probably going to benefit from improved localised warfare which is possibly a reason why you began this journey to begin with :D

After all is said and done, what we want is this yes?
To be totally beaten into submission by a super AI time and time again on totally equal terms as happens if you play an AI in chess.

Ooooh yeah :)
Cheers.
 
Yeah, it's going to be awesome. I got started with AI war decisions first for the StartAsMinors feature, in the next version of Revolution AIs will choose to keep some wars active when someone switches from minor to full. This is also now integrated with BarbarianCiv war decisions too ... makes for a very different (and more turbulent) first half of the game now as grudges from the minor civ period are held for a long time.
 
My goal for a BTS better AI project is simply this:

Python popup after a turn is complete with the AI declaration:
"You will loose to a domination victory in 121 turns. Would you like to resign now?" :)

Cheers.
 
Would you humour me for a moment and not to rain on my own cloud for a little while even if I am "delusional"? The most beautiful logical constructed turn based games I think humans have ever come up with are these:

1) The game "Go" without question

followed closely by:
2) Chess

followed closely by:
3) Civ + Revolutions

followed a fair way behind by:
4) Backgammon

followed so far behind it's not funny:
5) Poker, monopoly

Now forget 4 and 5 for a moment. The most capable turn based AI in the world without question is "Backgammon". After 15 years of exhaustive computing the game has been completely "solved" after the first move. Backgammon is a draw and the AI cannot be beaten. That is a fact.

The next best AI on the planet is chess. This AI is beating the very best minds in the world consistently without question even though the game is far from "solved". That AI can still be beaten occasionally especially now that the chess variant "Chess960" is gaining more and more support as being the "generalised" version of chess and which the AI cannot utilise it's database to win.

The next best AI is the Go AI. But this is still a huge order of magnitude behind the first two and remains one of the biggest challenges in computer science and will be for some time. Thankfully humans still have the upper hand on the "game of all games".

The next best AI is the civ AI. But that is *possibly* only as evolved as the Go engine. In reality, it is quite possible that a civ AI is possibly even more complex an artificial intelligence exercise than the Go AI is......

So if it takes until 2027 to finally crack the BTS civ AI when they say the "AI singularity" is due, there is still a bit of time so go for it!!!

My approach will be to type randomly on the computer keyboard until then, and hope that something dawns on me. I hope you will use a more sophisticated approach.

Cheers.
 
Here are some questions:
1) startWarVal iClosenessValue == 0: that /4 should be left alone in all cases yes?
2) what algorithm is the attacker using to judge the defense of his neighbouring opponent?


Cheers

1) I'm going with the following for now:

Code:
	if (iClosenessValue == 0)
	{
		iValue /= (GC.getGameINLINE().isOption(GAMEOPTION_AGGRESSIVE_AI) ? 4 : 2);
	}

The rationale as Yakk and I were discussing before being that /= 4 is a pretty drastic reduction, especially considering that it has never been invoked in game until this week. Dividing by 4 for far away civs is sort of equivalent to worsening relations by two steps for nearby civs, ie Friendly -> Cautious or Cautious -> Furious... there are several other factors, but for just startWarVal that is basically true. On Aggressive the increased odds of having a cordial neighboring AI backstab you to gain territory may make sense, but for normal it seems like /= 2 would allow for more roleplaying.

2) Depends. For AI_doWar where the AI contemplates starting a war there are checks of the team's power versus the victim's getDefensivePower(), which is just the sum of power for teammates, vassals, and defensive pacts. There are different modifiers and considerations depending on whether the check is for total war, limited war, or a dogpile.

That's just for choosing whether to pick a fight, in terms of the tactical choices of which city to attack I believe there is no check for defensive power. CvPlayerAI::AI_targetCityValue does not consider the strength of defenders. There are also mechanisms in CvUnitAI for picking targets and deciding whether to launch an attack or wait for reinforcements so this may not be the whole story. In previous versions of civ you could play games with SoD by moving defenders around and having the stack chase a constantly shifting poorly defended city (or worker even), the AI doesn't cheat in this way any more but now is happy to march towards a well-defended city.
 
Would you humour me for a moment and not to rain on my own cloud for a little while even if I am "delusional"? The most beautiful logical constructed turn based games I think humans have ever come up with are these:

.
.
.

My approach will be to type randomly on the computer keyboard until then, and hope that something dawns on me. I hope you will use a more sophisticated approach.

Cheers.

:lol: Awesome. If only computers were fast enough so that the AI could simulate 50 turns to decide whether a particular action was good ... then humans would be screwed :scan:
 
I'm not a programmer, but I'm going to follow this project and wish you the best of luck. :thumbsup: Your ambitions will at least not be the limiting factor of this project. :)
 
Hej, nice work. As I just wrote in the bhruic-thread I would like to test some of your improvements in a new game. I can probably make the changes myself if I get a short instruction, otherwise I would love if you loaded up some of your files. :goodjob:
 
So, the value we get from this calculation -- is it relative? Is it absolute?

Is it linear-relative? (if you double all values, does the situation not change)
Affine-relative? (if you add 1000 to all values, does the situation not change)
Ordered-relative? (if you do any operation that doesn't change the order, the situation doesn't change)
Linear-absolute? (every doubling of the number has about the same effect)
Affine-absolute? (every increase of 100 in the number has about the same effect)
 
Hej, nice work. ... otherwise I would love if you loaded up some of your files. :goodjob:

Releases will happen for sure. "This" better-ai has already a very fortunate head start which means that there are already achievements......It's called finding the "closeness bug"! The other head start are that Yakk and Jdog will be working on it ;)

Cheers.
 
I'm not a programmer, but I'm going to follow this project and wish you the best of luck. :thumbsup: Your ambitions will at least not be the limiting factor of this project. :)

I remember the wonderful "discussion" you had with Bhruic regarding "worker behaviour" and the like and that plus AI-build schedules would have to be yet another prime avenue for improvement. Not a simple problem at all to say the least!

Like Yakk said, the BTS AI is already very cool. Help on a project like this is zeroing in on the tough task of visualising "clear" avenues of progress that can be made through the haze and the maze of the "ghost in the machine" of unintended consequences.

Cheers.
 
Top Bottom