[BTS] Development thread

Does this also mean you will consider Better AI complete, and stop working on it further?

HAAA... haha... ha. Dood, there's no, freaking, way he'll stop with this version. Unlike all other parts of a game, AI is an area where potential improvements are virtually limitless.

Also, if he didn't absolutely love working on this project, he'd have made a much-less-substantial 0.90 release long before now and then given the excuse of wanting to just wait for Civ5 at this point. The fact that that hasn't happened pretty much guarantees continued updates through at least Civ5's release date.

p.s. -- JDog, feel free to correct me if I'm wrong (though I rarely am :p).
 
Does this also mean you will consider Better AI complete, and stop working on it further?

No, the 1.0 designator means that it's (finally) got the most important changes I've been wanting to get in done well: combat logic and victory strategy. There are still a lot of other parts which could be improved that I've been thinking about ...

However, this might be the last major update because the next several months will be a little crazy for me, and then Civ5 will come out. So I might not have time for rewriting the tech selection system, we shall see, but I certainly intend to polish up the victory strategy AI and then play a few games myself!

From what I've read and seen, Civ5 should be pretty awesome ... I am looking forward to seeing how it works when it does arrive.

Minor detail:

I have Angkor Wat and set my military city to prioritize production (hammer button). It removes a free priest (mercantilism) and adds an engineer. There is absolutely no reason why it should behave like this when I have the Angkor Wat. Is it possible to fix? I know I can force a priest, but maybe it's an easy fix anyway?

Hmm, thanks. I'll see what I can figure out.
 
No, the 1.0 designator means that it's (finally) got the most important changes I've been wanting to get in done well: combat logic and victory strategy. There are still a lot of other parts which could be improved that I've been thinking about ...

Cool. :D

From what I've read and seen, Civ5 should be pretty awesome ...

Yeah I certainly agree. The combat system will be different (but IMO better) though, which means probably few of your combat code will translate to Civ5. :( I was kinda hoping Firaxis had recruited you to write some combat AI for Civ5.
 
Probably a times zero or rounding error, where it values non-production too low to actually show up as being of any value at all?
 
I have Angkor Wat and set my military city to prioritize production (hammer button). It removes a free priest (mercantilism) and adds an engineer. There is absolutely no reason why it should behave like this when I have the Angkor Wat. Is it possible to fix? I know I can force a priest, but maybe it's an easy fix anyway?
Hmm, thanks. I'll see what I can figure out.
I believe it has been reported frequently that these prioritize buttons don't work as well as many people wished they would but there's a really simple solution to it: don't use them. Same goes for worker automation.
The problem here is, as Yakk suggests, that anything that isn't production simply doesn't count (at all, or at least not much). That's the result of pushing that button.

From what I've read and seen, Civ5 should be pretty awesome ...
I'll believe that when I see it, no sooner. And it's rather doubtful we'll have as much freedom to mod (the AI) as we have in Civ4 right now.


Code:
	<Define>
		[COLOR="Green"]<!-- Better BTS AI: Changes behavior of defensive pacts (Def: 0) :
			0 : Default BTS
			[B]1 : Defensive pacts do not cancel when a player has war declared on them[/B]
			2 : Turns defensive pacts into alliances, so they are now also offensive pacts.  Plus pacts
				do not cancel when war is declared.  Does not change name/description in game.
		 -->[/COLOR]
		<DefineName>BBAI_DEFENSIVE_PACT_BEHAVIOR</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
Did you actually test 1? I did yesterday, and it seems to behave like 0. Which was not exactly unexpected since you didn't completely rewrite whole chunks of the DoW function, which might be necessary.

X has DP with Y, A declares war on X: A's DoW on X removes any DPs A might have (A = aggressor), and triggers all DPs X has: Y declares war on A because of DP - Y's DoW (Y = aggressor) removes any DPs Y has (which would be the DP with X). In the end, A loses all DPs, and all of X's DP partners lose all DPs, which includes, but is not necessarily limited to, all DPs of X. (If Y had a DP with Z then Y would lose that too even if Z had no connection to X or A.)
I think your change in the code only removed the part where X would actively cancel DPs, which looks redundant to me since all of X's DP partners declare war and thus cancel any DPs on their own.

At least I think that's how it works :crazyeye:
 
Minor detail:

I have Angkor Wat and set my military city to prioritize production (hammer button). It removes a free priest (mercantilism) and adds an engineer. There is absolutely no reason why it should behave like this when I have the Angkor Wat. Is it possible to fix? I know I can force a priest, but maybe it's an easy fix anyway?

Have you tried to press both the production and commerce emphasize button as well? Sometimes combination is the key and here the logic might be that assigning an Engineer might lead to GE later - which can help to speed up a wonders. The co-emphasize on Commerce perhaps makes the governor value the addiotional commerce from the priest more.
 
Have you tried to press both the production and commerce emphasize button as well? Sometimes combination is the key and here the logic might be that assigning an Engineer might lead to GE later - which can help to speed up a wonders. The co-emphasize on Commerce perhaps makes the governor value the addiotional commerce from the priest more.

I don't think there is any such logic.

I would avoid emphasizing commerce in a production city.
 
Try it. I believe I once read something about a very similar problem where the only way to make the city work the right tiles was to have all prioritize buttons pressed. Maybe that works here too :p
 
I would rather just force the priest if the buttons can't work properly.
 
Minor detail:

I have Angkor Wat and set my military city to prioritize production (hammer button). It removes a free priest (mercantilism) and adds an engineer. There is absolutely no reason why it should behave like this when I have the Angkor Wat. Is it possible to fix? I know I can force a priest, but maybe it's an easy fix anyway?

The production value of a settled Great Priest with Angkor Wat is exactly the same as the production value of a settled Great Engineer (3). So in this example, you're telling the AI to focus on production, and in that matter, both options are of equal value. You can't expect the AI to read your mind and know that you would prefer a Priest instead of an Engineer. But the solution is simple enough, assign the Specialists yourself.
 
Did you actually test 1? I did yesterday, and it seems to behave like 0. Which was not exactly unexpected since you didn't completely rewrite whole chunks of the DoW function, which might be necessary.

X has DP with Y, A declares war on X: A's DoW on X removes any DPs A might have (A = aggressor), and triggers all DPs X has: Y declares war on A because of DP - Y's DoW (Y = aggressor) removes any DPs Y has (which would be the DP with X). In the end, A loses all DPs, and all of X's DP partners lose all DPs, which includes, but is not necessarily limited to, all DPs of X. (If Y had a DP with Z then Y would lose that too even if Z had no connection to X or A.)
I think your change in the code only removed the part where X would actively cancel DPs, which looks redundant to me since all of X's DP partners declare war and thus cancel any DPs on their own.

At least I think that's how it works :crazyeye:

Ah, good catch! I hadn't yet tested that setting, it was on the list before release. I think it'll be easy to get that setting working logically.
 
The production value of a settled Great Priest with Angkor Wat is exactly the same as the production value of a settled Great Engineer (3). So in this example, you're telling the AI to focus on production, and in that matter, both options are of equal value. You can't expect the AI to read your mind and know that you would prefer a Priest instead of an Engineer. But the solution is simple enough, assign the Specialists yourself.

I think even a computer doesn't need to be a mind reader to understand that an Angkor Wat Priest is better than an Engineer. It's called programming.
 
I think even a computer doesn't need to be a mind reader to understand that an Angkor Wat Priest is better than an Engineer. It's called programming.

Then I guess you don't understand simple math. Because 3 is not > than 3.

You say MAXIMIZE PRODUCTION. Production is hammers. A priest with Angkor Wat is 3 hammers. An Engineer with Angkor Wat is 3 hammers. They are EXACTLY EQUAL! There side benefits (gold and research respectively), have absolutely nothing at all to do with production. Pretty simple and basic. You're expecting the AI to understand that you prefer limes to lemons when telling it to make apples. That's a pretty hefty expectation from a human, much less a computer. I prefer lemons myself, but I guess you already know that, right?
 
Wow, all the great people on this forum...

So you don't expect the computer to pick a workshop by a river instead of the one not next to one? (it does, by the way, must be a mind reader)
Lets see who doesn't understand simple maths:
Hmm, 2 hammers and 1 gold or 2 hammers and NOTHING. Hmm, I think I'll have nothing.
 
The AI does count the little extras, just with much lower value than the production.

I have tried to recreate this in game but have not been able to, the value placed on the priest is always a bit higher. If you have a save or a screenshot of the city screen or something maybe I can track it down.
 
Attached a savegame (using Better BUG AI - dunno if that matters).

Washington, Philadelphia and Addis Ababa will remove a free priest and add an engineer if prioritize production is on.
 

Attachments

  • Eirikin AD-1755.CivBeyondSwordSave
    615.8 KB · Views: 118
Alright, I figured it out ... as kind of expected, the issue was basically caused by rounding with integer math. The value the AI places on the one commerce from the priest is pretty small to begin with, and when it gets multiplied and divided a few times it can disappear.

This has been fixed and will appear in BBAI 1.00 and then in UP 1.51 when I get around to that.

Thanks for your persistence Caboose.
 
Jdog, I have a code submission for you.

The Long Version:

I noticed the AI were poor (read: terrible) at choosing buildings that gave free promotions. When I checked out the code, I found this comment on it:

Code:
iValue += ((iHasMetCount > 0) ? 100 : 40); // XXX some sort of promotion value???

Not exactly a good sign.

The problem was that promotion values were evaluated on a unit-by-unit basis, which is fine for units, but terrible for everything else. I short-circuited CvUnitAI::AI_promotionValue(...) to a new function in CvPlayerAI, which mimics the UnitAI exactly, except that it does not require (but will accept) a CvUnit object to return a value.

With this, I created a valuation function in CvCityAI so that it properly evaluates promotions based on their effect, and how many units they can effect. I'm hoping this can be added to Better AI, mostly for selfish reasons, so that my future update merges are easier. ;)

The Short Version:

I created a new City promotion AI for you to use. ;)

Feel free to make any adjustments that you see fit.

Code:
View attachment CvGameCoreDLL.zip
 
AI ships breaking blockades?
With high enough odds, Attack_Sea ships will attack anyway but if the odds are lower, this special place is called. I am doutful if that part is really working as it should.
I think AI_attackSeaMove() is called for every unit seperately and AI_anyAttack() would then only cause one unit to move.
Now if the unit immediately moves after a mission is pushed, a situation like this could happen:
1 ship is blockading a city, the city has just enough ships parking inside with UNITAI_ATTACK_SEA, so when the first unit does its AI_attackSeaMove(), it will try to break the blockade. However, now that this ship is outside of the city, there are no longer enough UNITAI_ATTACK_SEA ships left inside, so when the next ship does its AI_attackSeaMove(), it will decide to stay, leaving the ship that already attacked all alone -_-
 
Top Bottom