Version 0.50 Discussion Thread

jdog5000

Revolutionary
Joined
Nov 25, 2003
Messages
2,601
Location
California
You can always get the latest stable release from the download thread or sourceforge. Development versions and updated source code can also be checked out from sourceforge. There will also sometimes be development versions on CFC, see the development thread for more info.

There are a lot of smaller tweaks and changes spread out throughout the code in this version compared to prior, more focused releases. The one big block of changes are to how the AI chooses to vote on AP/UN proposals, particularly for ending a war. The AIs war tactics have also been tweaked, stacks without much bombard strength now prefer cities with low defenses and the AI will now minimize how many turns attack stacks and transports spend in enemy territory so they don't get counter attacked or give as much advance warning. Several reported bugs or odd behavior have been addressed, including issues with fired global event triggers not being set for new players, AI building boats in ice locked cities, AI not building workboats to get resources in small lakes, and unnecessary use of fighters for air patrolling when enemies don't have aircraft yet.

Better BTS AI v0.50 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
- Fixed bug in AI denial of switching civics when in Emancipation
- Fixed bug introduced in unofficial patch causing immunity to collateral damage
- Fixed bug with espionage mission to spread culture to an enemy city
- Fixed bug causing combat promotions to be counted twice for aircraft
- Fixed bug (introduced) in consideration of plot defense when selecting bases for offensive air units
- Fixed bug (introduced) causing crashes if there was an unowned fort on the map
- Fixed bug in unit AI type matching for retreating emptied transports
- Fixed bug in unit AI's determing if a transport had required space to hold them where they didn't consider other units intending to load
- Fix for naval blockades reaching across land, including across diagonal water tiles (fixed both actual range and graphically shown range)
- Fixed bug (introduced) caused by different fixes to the espionage mission to spread culture in this mod and the Unofficial Patch
- Fixed bug in use of unit type instead of UNITAI type when retreating assault transports after drop-off in certain circumstances
- Created CvPlayer::initInGame to fix several problems with using CvPlayer::init in CvGame::addPlayer, including global event triggers reseting for new player and city culture, revealed plots, plus other data not reseting when overwriting old player
- Fixed bug where AI would use total war boolean when checking whether to do limited war despite poor finances

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 targetting by terrain bonuses to consider how important bonus is to AI

War tactics AI
- Attack city stacks will now reduce the distance they travel in enemy territory so the enemy has less time to prepare or hit them with suicide siege
- Attack stacks with decent initial odds and big troop advantage will skip bombarding and just attack (so enemy can't restock)
- Attack stacks without much bombard power will now prefer to go after cities with low defense modifiers, effect reduced after AI can build bombers
- Attack stacks without much bombard power are a little bolder in attacking city before defenses are lowered to 0, though they will bombard a few turns to make sure bombers and ships can get some shots in
- Loaded transports coming in for an invasion will now usually move outside opponents territory and adjacent tiles to up surprise factor and reduce exposure to attacks before landing

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 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
- Rewrote CvCityAI::AI_isAirDefended so that it considers unit damage, movement, AI type and can also count land units
- Normal workboat build blocked if there's an enemy sea unit camping outside city
- Coastal cities will now build boats as if planning a sea invasion if there is no route to enemy cities
- Improved handling of building troops to fill transports, unified between coastal and non-coastal cities
- Non-coastal cities now help fill carriers, missile carriers
- The AI was blocked from building attack troops if it felt it was unable to build good ones, now if it is at war it can build them but with low probability so it can fight back a little early in the game
- AI will now emergency build fighter planes if its air defenses are shot down but it still has lots of bombers and missiles
- If not critical, AI will let cities with high production or free air experience usually build most planes
- Cities with military production bonuses now a bit more likely to build military units
- AI will now always build some assault transports if it has significant overseas colonies to help defend them
- AI will now build reserve sea units to defend its settler transports in later eras
- Reduced construction of escorts that are weaker than the transports they would be escorting (Caravels escorting Galleons primarily)

Worker AI
- Fix issue where AI would not build workboats to make use of resources in small lakes (was blocked because it felt lake was not relevant militarily)

Espionage AI
- When a spy has waited in a city but has no mission available, they are now more likely to move around and explore instead of sitting
- Revamped desired Espionage rate and priority weighting calculations, AI now always update weights, relations play a larger role
- Neutral priority weighting is now 10 instead of 0, differentiates between
- When AI starts preparing for war against another player they will heavily shift their espionage spending towards that player
- AI will attempt to gain passive mission levels against adversaries
- AI will now actually load spies onto the spy transport it builds

Gold AI
- AI now has a budget for troop upgrades each turn based on how much gold it wants to have, it won't spend more than this budget on non-critical units when at peace
- AI now prioritizes upgrading escort ships to same extent as transports

Diplomacy AI
- Removed blanket acceptance of all proposals by secretaries the AI is friends with, now just auto accept less strategic proposals like extra trade routes
- Being friends with secretary now influences civics and other strategic proposals
- AI now more likely to defy civic proposals which are bad for it, particularly on Aggressive AI
- Reworked AI voting on forced peace, added thresholds so winning/losing calculations are more meaningful (no longer losing a war in which no units have fought, unless being dogpiled)
- For forced peace proposals, added considerations for whether peace team is winning or losing big
- AIs which are third parties to the war in question may now vote to continue it for selfish reasons (share wars with peace team, are planning to attack peace team)
- AI will now only defy forced peace if it is doing quite well in the war,
increased use of personality so warmongers are much more likely to defy
- Vassals will now vote for forced war proposal under some circustances. Previously they were blocked from voting for a war they weren't already in since they can't declare war on their own. (Vassals of player to be attacked always vote no still)
- AI will now always vote for a forced war proposal against a player they are planning to attack anyway in addition to always voting yes if already at war
- For forced war vote, replaced blanket check on whether AI doesn't hate victim with roll based on AI's attitude-based peace probability

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
- Increased city danger threshold so enemy ships do not runaway so easily
- Damaged ships will stay in city unless city is highly threatened
- Galleons assigned escort roles before Frigates are available will now change their UnitAI type to assault transport instead of getting stuck in their role after better escorts come along
- Transport ships waiting in port will now only unload their cargo during a land war if an enemy city can be reached by land, the player is on the defensive locally, or a stack of enemy units shows up. Increases naval invasions of distant enemies on Pangea maps, sea assaults to complement land assaults.
- Assault flotillas now leave behind empty transports
- Assault ships now assume cities whose defenses the player can't see are properly defended (previously counted as a single defender). Should make invasions more likely to occur near blockades, attack ships, prior invasions.
- AI will now try to break blockades if it has many attack ships in port
- Transports will now pickup units stranded on small islands
- Transports looking for cargo to pickup now use PUF_isAvailableGroupHeadUnitAIType instead of just counting unit ai types, should stop assault transports from waiting forever for units attached to a settler to load or waiting forever on small islands for units already in their cargo to load
- EscortAI units will now also shadow settler_sea units when there is nothing else to do
- Added a pathlength consideration to AI_pickup so that mostly loaded flotillas don't sail around the world to pickup one more unit (previously they would have waited trying to load the units they already had on board until someone else came around)
- SettlerSea transports now only run pickup if they're not full (another change necessary since transports no longer try to pickup the units they're already holding)
- Modified CvUnitAI::AI_shadow to optionally ignore units in cities, far away
- Reserve sea units will now prioritize shadowing settler transports out at sea even if they're empty
- Attack sea units won't run around the world to shadow transports and carriers
- Slow escorts (Caravels mainly) will now protect large flotillas instead of doing nothing
- Escorts with nothing to do will now return to the primary area if it's not too far away so that primary area city production decisions take them into consideration
- If a settler transport if full of workers but has nowhere to take them, it will now dump the cargo if an available settler comes along

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
- Increased city danger threshold so enemy aircraft do not retreat so easily
- Attack planes in endangered cities will now more likely to airstrike attackers
- Improved code for defense planes in endangered cities so they stay to defend longer and either airstrike or patrol
- Improved efficiency of danger threshold check for ships and planes
- Improved code for moving planes to offensive or defensive bases to take city threat into account
- AI bombers will no longer consider basing in undefended forts even if the fort is unthreatened
- AI bombers will now consider moving to a city with two defenders (down from requiring 3), change made because of added threat logic and should allow AI to now use almost all of its cities as airbases
- Fixed bug introduced in Unofficial Patch 0.19 causing bombers to skip their turns whenever an interceptor was around
- Many improvements to better handle damaged planes in threatened cities
- Added two functions for defensive airstrikes to make both air defense and offense units more directly aid in defending cities from enemy stacks
- AI air defense units wake from airpatrol every turn, re-decide roles/need
- AI air defense units now consider how many other air defense units there are in the city and guarantee air defense
- Air defense units with Interceptor promotions now will be more likely to patrol when city is threatened
- Added new function for weighting bases for attack air units with new consideration for supporting offensive stacks and defending endangered cities, plus keeping planes safe from sneak attacks when at peace
- When at war forts are now more likely to be used as offensive bases, though cities are still preferred
- AI will again consider basing attack planes in teammate's territory (plot defense considerations effectively disabled this in many circumstances in earlier versions of mod)
- AI will now consider basing attack planes in vassal territory, though it will only use them if it owns no good base cities or forts itself
- Attack air units will now pull out of cities/forts if the defenders leave
- Airstrikes will no longer target enemies in adjacent territory when the territory is only adjacent to owned water tiles
- Fighters now always move before bombers, they're much better at taking on enemy fighters
- New function in CvPlot to count how many air units are running intercept missions already
- Added emphasis for both offensive and defensive units on the the players primary area
- If nearby enemies have no attack aircraft, fewer units are needed for air defense (freeing up fighters to make air strikes). Only applies to players the AI is actually at war with, so their sneak attack preparations remain the same.

Unit AI
- AI will skip bombarding and go straight to attacking cities when it has good initial attack odds and a big strength advantage
- Stranded units with nothing to do will wait once someone is coming to get them instead of mindlessly patrolling
- Stranded settlers will now wait if someone is coming to get them instead of just scrapping after 20 turns
- Attack unit stacks will now break up when assigned to defend workers so that some of the units can do other things (protect other workers, get in transports)
- Units set to UNITAI_ATTACK will now get in transports instead of aimlessly patrolling when player is preparing invasion force
- If attack_city units cannot reach an enemy city while in land war, they will try airlifts and then load into boats
- Tweaked circumstances where attack units load into transports to encourage filling up boats
- Fixed discrepancy where attack units could group with settlers and then get in boats but were highly unlikely to get in boats with waiting settlers
- Speed up to AI_group so it loops over selection groups instead of units
- Attack units now do a bit better of defending cities in the new world if the AI hasn't sent/built enough city defense units yet
- Removed blanket block for loading transports when in land war, now handled by specific unit ai logic
- Tweaked loading of Counter units (Axemen, etc) onto boats to integrate with other changes
- Removed redundant logic from counter ai routine
- If an attack city stack is not big enough to go out on its own, but has enough units coming to join it, it will wait instead of traveling a long way to join another forming stack


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
- Barb ship spawn rate throttled so they don't swamp the seas before players build navies
- Improved barb ship blockade decisions so they stick around for a while but will then should actually move to another area
- Barb ships less suicidal, more oppurtunistic
- Reduced range in which barb ships detect unprotected resources by 25%
- Barbarians now will build defenders in captured cities first, not buildings

Pirate AI
- Privateers now prefer moving outside of other teams territory and enter at the last moment for a quick strike
- Fixed issue with AI Privateers being unable to group, also won't run around the whole world just to group

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)
- Removed the unused partial implementation of a new A* solver for closeness
- A bonus which enables the civ's unique unit is now valued more
- Added function to calculate plot strength of teammates and (if desired) vassals
- AI will now be more likely to sacrifice green units when assaulting a well-defended city
- AI will now be reluctant to sacrifice units with medic promotions when assaulting a well-defended city
- Created function PUF_isAvailableGroupHeadUnitAIType for counting number of unit ai's on a plot which might actually load onto a transport (aren't in another group, aren't already cargo)
- Created two path finding flags to weight paths towards avoiding enemy territory, useful for minimizing exposure of attack stacks, loaded transports, or privateers to enemy attack
- Created function to approximate how long it will take for a stack to bombard city defenses to 0

Combat Mechanics
- Modification for air v air combat to make veteran units more valuable, especially when wounded. Air v air combat is now more much more similar to land combat. This change can be disabled/enabled using BBAI_AIR_COMBAT in GlobalDefinesAlt.xml

XML changes
- Increased WAR_SUCCESS_CITY_CAPTURING from 10 to 25, AI now feels more like it's winning/losing based on city gain/loss

Customization
- Added GlobalDefinesAlt.xml to mod files to allow some customization of what new features are running

Debug
- Added SDK and adapted python code from AIAutoPlay mod to faciliate testing
- Modified debug mode output to show relevant information for these developments
- Added string to lower right flag help text showing Better BTS AI version number currently running
- Added SDK and adapted python code from ChangePlayer mod to facilitate testing
- Added new Python module Tester for testing purposes
- Updated ChangePlayer SDK pieces to fully redraw units
- Brought over war decision debug output from Warlords version of Better AI, updated for BTS logic

Better BTS AI also includes Dresden & Solver's unofficial 3.17 patch version 0.21.


One of the next pushes will be have the AI reinforce or ferry troops once it has a beachhead in invasion scenarios, something which it doesn't do explicitly right now.
 
AI not building workboats to get resources in small lakes

Another bug related with workboats is that Barbarian AI never builds them. It's not a big issue, though.

In fact, I don't know if Barbarian AI ever builds naval units. I've seen barbarian galleys only, and they seem to be "spawned" rather than built. It would be nice to see barbarian privateers, but I suppose its absence is by game design.
 
unnecessary use of fighters for air patrolling when enemies don't have aircraft yet
Oh, that WOULD be sneaky!! If AI civs at Peace had fighters that weren't put on display doing their intercept dance, the player wouldn't have their presence stuck in their face.

More important might be for the AI to put more priority on getting flight in the 1st place, especially if they have oil. Aircraft can be SUCH a force multiplier!
 
What about declaring war more often? Currently, in my game, an AI player got 2x more strength than every other player and is not declaring war to anyone.

edit: sorry only 2x more than everyone else, but 3x more than most of the others. ;)
 
There are a lot of factors involved in whether and when the AI decides to declare war, including their relationships with other players and the state of their finances. In 0.50 you can now get some extra info about who they would consider declaring war on and with what odds by holding down ALT and mousing over different players in the scoreboard (have to have ALT down before putting the mouse on the player whose decisions you want to check out). You have to have the chipotle cheat code entered in CivilizationIV.ini to see this.

One thing I've run into and been thinking about is the issue of role-playing versus playing to win ... a human player with a huge power advantage over the rest of the world will pursue conquest/domination, but the AI never ignores its relations with other players and thus some leaders are unlikely to ever go that route even if they have a big military advantage.

On Aggressive AI this isn't much of a problem though ... the AI is much less tied to relationships and will push an advantage when it has one.
 
Is the land bug that results in Incas on Earth18 refusing to send settlers to the rest of South America fixed?
 
Just throwing an idea out there. jdog, have you looked at anything about the way AIs head for spaceship victories? If it's true that AIs often build expensive SS parts in 1:hammers: cities then an improvement in the strategy there could go a long way. Disregard this post if the issue has already been addressed! :)
 
Here's something odd. I'm in the process of rolling a SoD through Hammurabi's territory, razed a city just to the SW of my SoD.

On the next turn (or two), Hammurabi has sent out a settler with only 2 guards in an attempt to re-settle that hill.

One would think that with a massive SoD inside his borders, he's at war, he would either not send out a settler or at least protect the settler better.

This is 0.50F. When I clicked next turn, the settler did turn around and run away to Nippur to the NW. However, the two riflemen stayed in position to be slaughtered.
 

Attachments

  • Mehmed XI AD-1937-July Hammurabi Trying to Settle a City.zip
    1,012.2 KB · Views: 47
On my first LAN multiplayer game with better ai I experienced a strange occurrence while attacking a city. With my entire stack clicked I scrolled over the city and it displayed the unit with the highest chance of (attack + retreat combined). These odds seemed fair to me so I clicked to have the stack attack. When I did, rather than my horse archer, the axeman ran in and was miserably slaughtered. The axeman had slightly higher victory chance than the horse archer but was by no means the best choice overall.

I'm new to this mod and wanted to know if this was a known issue.
 
On my first LAN multiplayer game with better ai I experienced a strange occurrence while attacking a city. With my entire stack clicked I scrolled over the city and it displayed the unit with the highest chance of (attack + retreat combined). These odds seemed fair to me so I clicked to have the stack attack. When I did, rather than my horse archer, the axeman ran in and was miserably slaughtered. The axeman had slightly higher victory chance than the horse archer but was by no means the best choice overall.

I'm new to this mod and wanted to know if this was a known issue.

I think that has nothing to do with better AI... Just the mechanics for how stack attack works. I've got no real idea how stack attack works because I never use it but maybe it throws in units in some order which are not the same order that you agreed with. For example, it might send in the most highly promoted units first, or the units most suited normally to city attacking (axemen and swordsmen) first.
 
Hmm ... yeah, I can confirm this symptom. Have not heard it before, thanks for posting!

It seems that when you send a group in to attack which has a unit with good retreat odds, the game may show you the statistics for that unit but then it will actually send another unit which doesn't have retreat odds. I'll see what I can figure out ...
 
Alright, so the switch of which units actually attacks is nothing new with Better BTS AI ... here's what happens:

When you mouseover and the game shows you what the attack odds are, it shows you the details for the "best attacker" which is the unit most likely to survive the battle. For a tough defender, this will usually be a unit with a withdrawal chance.

When you actually order the group to attack, the game again determines that the same unit is the "best attacker" but then sees that the odds of survival for that unit are < 68%. In this case it does a new computation for the best unit to send into battle, the "best sacrifice" unit. Instead of odds of survival, this calculation includes a balance of expectation of damage done, the hammer cost of the unit, experience level, withdrawal, and other factors. This is the same code the AI uses when sending a group to attack.

It's not a bug, but a somewhat hidden feature designed to protect the top units in the stack if facing really long odds.

There are a few options on how to proceed:

1. Do nothing, leave as is.

2. Add extra information to the combat help info for a group, showing first the "Best Attacker" as it does currently but when the combat odds are low also show the same set of stats for the "Best Sacrifice". It would look something like:

Best Attack: Horse Archer
Odds: ___%
Withdrawal: %
All the info on modifiers

Best Sacrifice: Axeman
Odds: ___%
All the info on modifiers

I would hesitate to replace the current best attacker info with the sacrifice info, the best attacker info is still pretty useful.

Thoughts?
 
Unless you really want to jdog, I don't think it's really necessary. If interface enhancements are now in the scope of Better AI then I could mention a number of other ones, including borderline bugs like this one.

If you did make the change, you'd need to make it obvious which attacker would be used (for people who don't know about the 68% value), to avoid confusing people even more than it would now.
 
Been playing a few huge/marathon games (tectonics, 60% water, warlord). Something that I'm noticing is that the AI is very bad at "panic" defense. Such as responding to a SoD suddenly marching towards a city. The SoD might have dozens of units, while the city that it's near only has a handful of units.

The AI doesn't seem to grasp the concept that unless this attack is blunted or stopped, it's game-over for that AI. Some of the things that I'm surprised to see the AI not doing:

- Pull defenders out of neighboring cities to shore up the defenses of the most threatened city. Assuming that cities have some sort of "how threatened am I" value, I could envision iterating through the cities and having them send to more threatened cities within N tiles. Using a bit of randomness to evenly distribute these units based on the threat levels of the destination cities. We wouldn't want to see all the defenders only go to the most threatened city.

- Use our own stack of doom to counter the invading force.

- Pop a golden age (not needed for spiritual leaders), switch to a drafting or whipping civic and attempt to reinforce threatened cities with the best defenders. If the power differential is 2x or greater.

- If the threat is bad enough, switch to either a drafting or whipping civic (even if we can't do it via a GA) and attempt to raise a large number of defenders. By bad enough, I would say that a power differential of 4x or greater. One or two turns of anarchy followed by massive defense spending.

- Ask friends to declare on the invader. (This might already happen as part of the diplomacy AI.)

This came up when I invaded Charlemagne earlier. He had a dozen cities all with 4-6 units in them. But as my SoD approached his first city, he never shifted units or called up reserves to attempt to counter it. As a human, I would have pulled about 1/2 of the units out of more distant cities and flowed them from city to city towards the invasion forces.

Another time, units dug unto a fort on a nearby hill didn't shift into the local city that was threatened by my SoD.
 
That's very true, the AI does not often shift around its defenders to counter an incoming stack ... the AI does allocate itself "floating defenders" who I would imagine are supposed to do this, but I have never seen a strong defensive shift of forces. As it's set up now, an AI on the defensive is unlikely to shift half of its 4-6 defenders per city around, it almost certainly feels that each city needs 4-6 and so they won't shift. When on the defensive, the number of floating defenders the AI thinks it needs shoots up and it will think it needs 4-6 D in each city, going up to 20+ for those cities with stacks outside. So, the AI does recognize the situation now, but its ability to react quickly enough to make a difference is the weak link. If you park a large stack outside an AI city for 20 turns, eventually they'll get the needed defense ... I'll see what I can do, won't be in the next release (0.60) though as that's basically "gone gold."
 
Top Bottom