Version 0.3 discussion thread

jdog5000

Revolutionary
Joined
Nov 25, 2003
Messages
2,601
Location
California
Download it here!

Most important changes from 0.21:

- Resource driven war: AI may now declare war to try to capture resources it doesn't have, added as a new factor to existing start war logic
- Fix of bonus, civic, religion trade bug found by DanF
- Additions and tweaks to city building priorities when preparing/running invasions, should cause the AI to more quickly fill transports for second waves


Better BTS AI v0.3 Changelog
_________
Spoiler :

Bugfix
- Fixed bug in player closeness calculations causing the AI to be blind to its actual proximity to other players
- Fixed bug with needed defenders where the AI would choose to defend a recently captured holy city less than a normal city
- Fixed bug causing player ID to be used in place of actual attitude when checking for denials in bonus, civic, and religion trading
- Fixed bug in paradrop code causing AI to avoid paradropping onto terrain bonuses under certain circumstances

War strategy AI
- Modified how closeness is used for determining who to attack, different settings for regular and Aggressive AI
- Created new function CvTeamAI::AI_calculateBonusWarValue so AI will consider declaring war for resources, weighted towards resources AI doesn't have and plots that are more easily captured
- Modified city attack targeting by terrain bonuses to consider how important bonus is to AI

City AI
- AI will now more likely fill empty transports when enagaged in transcontinental war, making reinforcements and second waves on invasions more likely
- When doing invasions, AI will now be more likely to have cities with free air experience fill vacancies on carriers
- When doing invasions, AI will now have cities with high production or free sea experience more often fill needs for aircraft carriers
- When doing invasions, if AI has at least 50% of its possible missile capacity it will no longer always build missiles

Naval AI
- Modified bombard behavior. Priority remains on supporting player's ground troops, if none then consider supporting other troops with common enemy and spreading out stacks to increase reach of blockade.
- Modified and expanded Solver's changes to retreat from city/fort AI to be more specialized for various unit AI types, only move if there's a real threat

Air AI
- Modified and expanded Solver's changes to retreat from city/fort AI to be more specialized for various unit AI types, only move if there's a real threat

Barbarian AI
- Barb ships will now often blockade cities for a few turns before moving on if they have no nearby targets
- Barb ships trapped by ice or around 1-tile islands are now removed so more can spawn

General AI
- Modified city closeness calculations to use population from both cities, not just pop of the other city
- Created functions for determining when cities share the same water area (lake, ocean)
- Partial implementation of a new A* solver for determining closeness, does not yet affect calculations

Debug
- Added AIAutoPlay mod
- Modified debug mode output to show relevant information for these developments
 
Resource driven war

I thought the AI already did this... what resources will it declare war over? IMHO should only be horses, iron, copper, coal, oil and uranium... maybe luxury clusters, but definitely not food.
 
It tried to do that (going to war over resources), but it ... sucked at it. ;-) There where some serious bugs in the code that jdog fixed -- and I think he added stuff that makes "nearby" resources actually worth more war-wise.
 
The code that appeared to drive the AI to war over resources did nothing without XML modding ... I was shocked when I figured that out. In CvTeamAI::AI_calculatePlotWarValue there was a section of code reading:

Code:
iValue += 40 * GC.getBonusInfo(eBonus).getAIObjective();

But the iAIObjective field in XML is 0 for all resources. I have no idea if that code was supposed to have been implemented somehow, but my guess is it was added for a mod that included some super important resource since +40 per resource is a very large bump.

Anyway, I left that part alone and added my own function just for resources. Instead of hard-coded AIObjective values it makes use of CvPlayerAI::AI_bonusVal which assigns values between 2 (happy/health bonus AI already has) and around 200 (for oil when AI doesn't have). The weights for strategic resources from this function are much higher than for luxuries or food and change depending on what the AI is unable to build because of lack of access. As Yakk indicated, the bonus are also weighted 2-3 times higher if they are near the AI's territory (ie, more easily captured).

Just to clarify, the AI won't really declare war over resources but instead when it is considering starting a war it will now be more likely to start a war with someone who has resources it doesn't. I haven't added a new situation where the AI decides to declare war, just tweaked the existing decision to weight towards the chance of capturing valuable resources.

Loosely speaking, here are some example values that would get added:

(normal / adjacent to territory)
Luxury/health AI has already : +0 / +0
Luxury/health AI doesn't have : +1 / +4

Iron AI has : +1 / +2
Iron AI doesn't have : +3 / +11

Oil AI has : +4 / +10
Oil AI doesn't have : +30 / +90

The sum is added to the other effects in AI_startWarVal, you can see the various values that go into this in debug mode by holding Ctrl over a civ's capital. The 3 values in the parentheses are:
1. "PlotWarValue" - number of adjacent tiles owned by other team x 4
2. This new terrain bonus value
3. Capital proximity
 
Once again sorry for the airhead question.

But how do you know if Better AI is running?

I have replaced the files so it is permantley running?

Thanks
 
Did you install it into Custom Assets?

The easiest thing would probably to see if AI autoplay is working.
 
Did you install it into Custom Assets?

The easiest thing would probably to see if AI autoplay is working.

No like I said I replaced the files in the assets file like the readme said if you want the better AI running all the time.

Where is the AI Autoplay?
 
Check out the instructions here for turning on AIAutoPlay and the in game debug mode.

I'll add some little string to the mouseover info for something for the next version.


So is what your saying here, if I follow those instruction and the autoplay command works then BetterAi is running? If the command doesnt do anything then it is not running?

Thanks
 
thanks for your work towards improving the AI

i'm almost at the end of a game started with the better_bts_ai_0_21 dll , then switched the dll to better_bts_ai_0_3 about 20 turns ago.

huge panagea map, noble, 11 civs at start.

what i've noticed is that the AI goes to war with civs near itself, no more wars with civs far away. its nice to see the AI behaving more rationally.this was expected. what was a surprise is that through 5 wars against other civs that had airships or bombers, the airships/bombers were never used against me. the AI does seem to use its fighters for attacks, at least after its turn i'd see messages that my fighters had shot down enemy fighters(the messages that come up at the start of my turn). but never a message about enemy airships/bombers doing anything to me. the last war was with the ai_0_3 dll in. i purposely left single units next to ai cities that had bombers to see if the ai would bomb them, but no. with bts3.13 with bhruics dll, the ai used airships and bombers often.

just thought i'd let you know about bombers seemingly not being used now. perhaps it has something to do with the retreat code for bombers that was added by solver, i think, thats included in the better ai dll. perhaps the ai is so busy protecting its air assets that it doesn't use them, cause its moving them all the time? maybe the retreat threshold needs to be adjusted so the ai will take a chance.

if i set up simple experiment in wb the bombers bomb my units, but in a late game environment with lots of cities and large armies something doesn't seem right with airships and bombers now.

just thought you'd want the feedback. maybe its just me, that i screwed something up somehow:) thanks again for your work on this

------------------------------------------------------------
addon

just for the heck of it i put the default bts 3.17 dll back in and played another turn of the same game mentioned above(i'm still at war). with the default dll in the ai opponent used its bombers against me the next turn
 
what was a surprise is that through 5 wars against other civs that had airships or bombers, the airships/bombers were never used against me. the AI does seem to use its fighters for attacks, at least after its turn i'd see messages that my fighters had shot down enemy fighters(the messages that come up at the start of my turn). but never a message about enemy airships/bombers doing anything to me.

I second this. I realized the same behavior.

Matze
 
made some screen shots of messages during ai part of turn and start of my turn using various DLLs. used a save from late in game(modern era)just before hitting the end turn button to compare the dll's effect on bomber usage. put each dll in, then hit end turn and waited for messages. then changed dll and used the same turn save for each. the mod is my personal, based on the marnz mod.

solver 19
Spoiler :


only aircraft mentioned at start of turn




bbai 30
Spoiler :


only aircraft mentioned at start of turn





default 3.17 dll
Spoiler :


during ai move



one of a few about bombers at start of my turn






so it seems to me from this very rough comparison that during late game something in the retreat code in solver19 is interfering with the ai using bombers
 
found i still had a copy of better bts ai 20 so i did one more dll comparison. bbai 20 includes solvers 17 which does not have the airship/bomber retreat code in it i believe. used the same save game as the comparisons in my post above

bbai 20
Spoiler :


message during ai part of turn



one of a few messages mentioning bombers at start of my turn






this one let the late game bombers work. at least for me.

do only a few of us play to the late game where the ai civs have bombers, or is what i noticed just bad luck because of something on my end ?
 
Can you just swap dll files like that and expect everything to work?
 
Thanks for bringing the bomber issue up, I believe it has to do with retreating as you suggest. Particularly in Solver's implementation, the bombers will retreat if there is any enemy unit within two squares of the city ... his rationale in response to my thoughts on this is here.

It's a tricky situation deciding whether the planes should retreat or not ... right now the threshold of nearby enemy power to your city's defensive power is 1/4 for bombers or 1/3 for fighters. This seems to be too low ... I was planning on making it more like 1/2 or higher but Solver talked me out of it. I'll go back make the levels higher so planes are much less skittish.
 
Can you just swap dll files like that and expect everything to work?

Yes, everything will work fine. The AI won't re-determine missions for units that are in the middle of an extended mission but all new decisions will be made properly with the new logic.
 
as long as there aren't python and xml files that have to be changed/added to go along with the dll that you are moving in and out i believe its ok. i believe the game just looks at a different set of instructions(the ones in the dll) when bts loads. if the game doesn't like changes, it won't let a save load. i switched each of bhurics many dll's in the middle of games i was playing with no bad results. naturally the game is off when i changed dlls.

what i did to try and see if i was nuts that i didn't see the ai using its bombers showed a consistant result. at least for me, the aircraft retreat thing is a problem. both the default3.17 dll and the better ai_20 dll don't have the retreat thing, and when i loaded bts, then loaded the same save, both times the bombers the ai had, but wasn't using, were used.

i'm just wondering if other people that played games till the ai had bombers have noticed the bombers not actually being used by the ai. or if in other folks games, the ai used its bombers against the human player. unlike what i noticed. maybe what i noticed is a problem on my end. it seems MatzeHH noticed the same thing, and there was a post in the ai21 thread saying the same thing about bombers.

its strange cause with a simple world builder test, the dlls that apparently weren't working in a game environment, worked ok.

its no big deal, i just wanted the guys who were nice enough to make these dll's aware of what i noticed. for now i guess ill play with the better ai 30 dll till i see the ai has airships, then put the better ai 20 in
 
Thanks for bringing the bomber issue up, I believe it has to do with retreating as you suggest. Particularly in Solver's implementation, the bombers will retreat if there is any enemy unit within two squares of the city ... his rationale in response to my thoughts on this is here.

It's a tricky situation deciding whether the planes should retreat or not ... right now the threshold of nearby enemy power to your city's defensive power is 1/4 for bombers or 1/3 for fighters. This seems to be too low ... I was planning on making it more like 1/2 or higher but Solver talked me out of it. I'll go back make the levels higher so planes are much less skittish.

personally i don't think just because units are within 2 squares of a city that the bombers should retreat. even if enemy units are only one square away. don't think proximity should even be a consideration. imho the threshold should perhaps be inversed ie enemy power to your city's defensive power is 4/1 or maybe 3/1. doubt the bombers would ever be used under the conditions jdog described if the ai is being attacked, that is in a defensive war. thats when the ai really needs to use bombers, to cause attrition of the attacker's forces, be it human or another ai civ

the explaination you gave about why the bombers retreat explains why it seemed to me they weren't being used in my game. i was attacking the ai's and had the advantage in numbers.
 
I found the actual bomber bug, it was introduced by Solver but not with the retreat code. He added special handling that was intended to have damaged planes continue to pound an opponent without stopping to heal if there were no interceptors around. Unfortunately his new code applied to all planes running the attack AI, not just injured ones causing all bombers and airships to skip their turn if there is a single enemy interceptor anywhere in their range ... fix will be up soon.
 
Top Bottom