1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

LoR SDK ModMod - Dynamic Difficulty, Better AI and More!

Discussion in 'Civ4 - Legends of Revolution' started by Dave_uk, Mar 23, 2014.

  1. Dave_uk

    Dave_uk Chieftain

    Joined:
    Oct 6, 2009
    Messages:
    31
    Location:
    Oxford, UK
    Hi

    In this thread you'll find mods I've been making to LoR to make the changes I felt were needed, and have decided to release these changes to the community in case anyone else is interested.

    The main point of these changes was to make the game more interesting and challenging in the late game. Personally, I dislike the early game at the higher difficulties as it seems to unforgiving, but I get bored when winning too, so I created what I call dynamic difficulty which is the AI gradually getting more bonuses as you start to win. I have also tried to improve the AI as much as I am able, as ideally I would prefer to play a strong AI with no bonuses than a weak one with many bonuses.

    The current version is 0.94 released 06/10/2016. I've left version 0.92 released on 15/04/2014 up as well, as that's been used for years with few issues whereas the new version may have some.

    Here are the changes made since version 0.92:

    Spoiler :

    AI
    - Vassals more likely to research techs their master doesn't have
    - Imported some K-Mod espionage changes
    - CityAI changes
    - more likely to build units in hero epic/military acedemy city, even if it's a top culture city (building culture building is still a higher priority)
    - build more city attack units to finish off the last few cities in an area if AI owns most of it (vast majority of cities)
    - some conditions added to decision to build defense buildings, AI is less likely to build walls and bunkers in every city
    - changes to assualt AI
    - less likely to build ships/drydocks in a city if other cities already have drydocks, an attempt to have the AI specialise
    rather than build drydocks and then ships in every city when planning an assault (before drydocks are available, no effect)
    - Added additional chance to build assault units as a last resort after other checks, but before choosing any building or process, similar to if we have a land war (but still a chance not to build)
    - AI will increase it's estimate of enemy power if fighting a land war in their primary area and they are the weaker part of a team (enemy power is a team calculation but teammate might be on another landmass and be of little help)
    - AI will build more defensive units when going for culture or victory, and losing a land war (doesn't need to be losing by as much as normal)
    - improved governor AI for AI and humans with automated citizens
    - Build more AA
    - UnitAI
    - taught AI about flanking
    - value withdrawal promotions more for reserve AI units and weaker units
    - better evaluation of hills attack/defense promotions
    - better amphibious assaults, if plot isn't visible more realistic estimate of city defenders, should lead to more landing next to a city,
    fewer suicide attacks
    - Ships should stray further to bombard the enemy, if they don't fear a counter attack (slight cheat since we are summing enemy naval power in area)
    - Added code to work with teammates or improved what little code was already there to do this
    - Added code for smarter use of nukes
    - When choosing techs, more priority for biology (more value on the +1 food for farms, still requires AI to have significant amount of farms to begin with)
    - Added new function AI_GetWarDistrustVal - based on attitude from team previously declaring war on us or our friends. AI will be likely to launch a preemptive strike against such teams, and value peace with them less, when this value is high.
    - Smarter evaluation of who to go to war with - many improvements to AI_StartWarVal
    - less randomoness in the choice of when to go to war, more likely when there are good targets, revealing a new bonus we need but don't have can be a trigger for going to war to acquire it
    - When calculating AIs attitude towards a team, vassals matter much less. Previously each vassal counted as much as master team, now if the team has 1 vassal, vassal attitude counts as half, and if they have two or more vassals the attitude towards all vassals combined counts only as much as the master.
    - Takes into account annual trades when working out attitude value (e.g. bonuses sold cheaply)
    - many more modern warfare improvements
    - more likely to trade techs giving wonders if the wonder requires multiple techs the other team doesn't have and can't research
    - smarter diplomacy for open borders, declaring war on an enemy, peace vassaling
    - smarter worst enemy - ignores "initial impressions", focuses only on actual transgressions/trade etc.
    - many (mostly untested) changes to ruthless AI - sorry needed to get this version up to fix bug!

    Other
    Espionage discounts for trade routes are increased for passive missions
    - 20% is the standard
    - +5% off if target city has harbour or +1% off for each population size above 10, whichever is greater
    - +10% off if target city has mutual trade
    - maximum of 40% off, double the original discount
    Influence Driven War works differently when either side is barbarian, minor civ, or rebel
    For rebel, barb, minor civ - takes culture from all who have influence over tile not just battle loser
    When fighting rebel, barb, minor civ the culture taken is the average of the two (all remaining culture and that civs culture)
    Era based research speed modifiers scale with map size (effect is less pronounced the smaller the map)
    Air units do less damage when intercepting paratroopers, based on aircombat limit
    Nukes poison city water supply when they impact it
    Promoting a unit heals 1/3rd of damage, down from half
    Dynamic difficulty can now help human in a few circumstances:
    - AI costs can be increased up for wonder enabling techs if human isn't winning, up to a max of the human tech cost (i.e. no effect is human is winning ir difficulty is noble or less, designed to give player a peaceful way up the ladder by sometimes being able to win wonder races (or at least join the race!)
    Inflation is reduced for human and AI based on rank (-1% per rank, so more noticable in the early game, only when dynamic difficulty is on)
    increased global warming modifiers for larger cities (>10), coal power plants count double towards global warming (it's still quite rare though)
    support costs for later units increased (based on their cost to build, can be fractional, shown as extra support cost)
    interception stack code now only includes units in the same domain as the head interceptor
    war weariness does not decrease when troops are deployed - no decay when paying supply costs
    for teams of two, war weariness is decreased by 1/3rd
    Toned down big_civ_slow_tech, but allowed number of cities maintanence costs to rise when civ is very large (up to double)
    The limited religion code to found religions when starting in later eras didn't seem to work, replaced it with a new function so that if starting after the ancient era religions are founded at most one at a time after the game starts
    Two new optional features (see below)

    Perfect World Map Script
    Poles are colder and drier
    Rainfall changes
    - Added code to redistribute and smooth rainfall, to stop harsh bands appearing from geostrophic rain
    - Rain moves even further inland
    - Areas adjacent to peaks and downhill from tundra are wetter
    - overall effect is that land is more balanced while still looking more natural and less random than built in maps. Grassland and plains are mixed in while still allowing for some "great plains" (reduce PlainsPercent if this is too much for you). Deserts are less predicatbly in the center of continents, rain shadows from mountains and lattitude matters more
    Changed starting plot valuation to value rivers higher, and actively avoid deserts (without floodplain or oasis) and ice


    I've made a lot of changes to the AI in this version, so I'd be interested to hear if it's made it any more challenging. I still think it needs to be made more ruthless, but those changes would probably be best made by improving the "Ruthless AI" option so the standard AI can be left closer to the BTS experience. Other changes to note are that the BIG_CIV_SLOW_TECH has been toned down, but that number of cities maintenance can now rise up to double the amount specified in the handicap file for very large civs. Dynamic difficulty has also been tweaked, are there are two new optional settins (see below)

    Here are the changes made in version 0.92:

    Spoiler :

    Improved AI tech selection:
    - Will aim for techs to enable cities to use resources nearby
    - Will aim try harder to win the liberalism race if it knows there is competition
    - Will value alphabet based on how many civs it has met but can't already trade techs with
    - Will value techs providing the ability to build wealth and research more when not at war
    - Will value writing more under start as minors to negotiate, even when other civs it has met haven't (be more preemptive)
    AI will build more workers after having already built up an army, and will build more city hunting stacks when using when it's only met barbs and minor civs (useful for start as minors but previously blocked because the AI was not considered at war)
    Made dynamic difficulty kick in little earlier for difficulties above noble, except for unit cost discounts which now kick in less at the higher difficulties. Also limited human costs to equivalent of +3 difficulty levels to be consistent with AI bonuses
    I’ve re-written Dynamic Religion again. It's now closer to the original LoR code, but compared to the original the first 5 founded religions do spread faster. This code also tries to deal with advanced starts when starting in the classical era, ancient era religions should spread faster. If you start in the medieval era, you’d still be better turning dynamic religions off.


    I've also included my changes to the perfect world map script in this version, perfectworld2cd which is based on perfectworld2f. Compared to the original the overall map is slightly smaller, but with a lower sea level and more smaller continents and less chance of one or two big ones. I've also changed the rainfall and temperature code slightly to give the map a slightly more wet, tropical feel. Finally, I've added some code to mix in grassland and plains more, since it's difficult to grow a city when is surrounded completely by plains.
    Here are the changes made in version 0.91:

    Spoiler :

    Toned down big civ slow tech slightly
    Removed 2 undocumented features I had forgotten about and no longer like
    - ability to vote yourself to a diplomatic victory
    - a soft limit to the amount another teams espionage can let them defend against your passive espionage effects
    AI City Build Priority Changes
    - Civs will build a few more buildings instead of units when start as minors is enabled, or when their best unit isn't that good, rather than spamming low value units.
    - Changes from K-Mod to make AI compare the value of processes (wealth, research etc.) to the best available building to build rather than only running these processes as a last resort.
    Fixed bug reported by lfgr where the game sometimes crashes during AIAutoplay or when starting a scenario due to there being no human player for dynamic difficulty to work from.


    Here are the main features of this Mod:

    AI Improvements


    I've made many changes to the AI in LoR to improve it, most changes are taken from Karadoc's K-Mod, but I've made some of my own as well. This is not a full merge of K-Mod and LoR, I didn't have time to do everything so I've only merged the parts I deemed to be the most important.

    The AI should make better choices when going for technology based on it's situation, manage it's cities and workers better, and manage it's economy better in general. It will also be smarter when choosing civics (including code I have added to make it take more consideration of revolution effects). It should build more attack units when winning a war, and generally attack/defend and switch between attack and defense better.

    The AI will also build more AA units when it might need them, but not spam them for no reason, and is more likely to give it's AA units the intercept promotion.

    The AI will also become more ruthless when you are winning, even if ruthless AI is not turned on (many aspects of Ruthless AI make sense in all situations, not just when you want the AI to be ruthless)

    When it comes to diplomacy, the AI should be willing to trade technologies for cash more in the late game. They will also trade technologies more when they are behind in technology, to allow them to catch up quicker. The AI can now be bribed up to +5 relations (the "Fair and Forthright" bonus), but it will take more to get it to +4 or +5.

    I've made major changes to the acceptance criteria of alliances, if you play the game with permanent alliances turned on. You no longer need to have shared a war or defensive pact with an AI for a long time in order for them to accept an alliance. They will now usually accept if you meet the relationship criteria (usually friendly) and your empires are similar powers and sizes. For AI to AI alliances, they need a slightly lower relationship, +8 instead of +10. This is to make up for the fact AIs never bribe other AIs to be friendly. They will also no longer rely on a random number generator to decide when to make alliances, they will make them as soon as the criteria are met. All in all, these changes mean that the late game tends to end up with most civs forming alliances and becoming more powerful. If you decide to go it alone, or are unable to find an alliance partner, this can make the game more challenging and leader to larger "world war" type scenarios.

    Other changes


    Dales combat mod

    I've made various changes to the Dales Combat Mod elements to make them feel more balanced and less "cheaty". Unfortunately, I haven't had much success teaching the AI to use DCM features, so I've made them less powerful instead. This will of course only affect you if you use these elements anyway. Click show to see details...

    Spoiler :

    • You can only attack ships in ports or engage fighters in tiles you can actually see
    • When attacking a ship in port, the chances of it sinking are based on how much damage it has sustained, rather than a flat 50% chance
    • The fighter engage mission can only be carried out against enemy fighters that are running the intercept mission. It is now an air superiority feature, but you can't destroy a fleet of bombers in an enemy city, that is unbalanced, to destroy enemy bombers you will have to put your fighters on intercept and wait for them to come to you.
    • Ranged bombardment once again does damage to the head unit of a stack as well as doing collateral damage to additional units. The damage done is still of the collateral type, so the maximum damage that can be inflicted is based on the collateral damage limit of the attacking unit, and collateral damage imunities and protections still apply. To differentiate the damage done to the head unit, the bombard rate of the attacking unit is used as a multiplier, units with a bombard rate of more than 20 will do more damage to the head unit than to other units, units with a bombard rate of less than 20 will do less damage to the head unit.
    • Units can only ranged bombard if they have not moved that turn. This was mainly to make coastal assaults less powerful so that ships could not move in and damage units on the turn war was declared, but makes sense for ground units as well.
    • Active defense can now only happen once per turn, and is not guaranteed to happen but there's a chance based on the planes intercept chance. It can only target units in friendly and neutral plots (since it's active defense not active attack)


    Changes to LoR/Revolutions Features

    Changes to other features added in LoR, click show to see details...

    Spoiler :

    • When upgrading a unit to one of a different combat types, rather than simply doubling price, the prices varies based on relative combat values of the old and new unit. This works out slightly cheaper in most cases.
    • Toned down the effect of dynamic religions slightly, the first 5 religions spread more and the last 2 spread less. I found that with dynamic religions on, you would want to actively avoid founding early religions as they would be guaranteed to to spread automatically, whereas later religions spread all over the world super fast. Now it is more balanced
    • If a unit upgrades to another unit that requires a "non-core" building, the old unit is still build able in the city. Non core buildings are ones that would not be provided for free if you started the game in the future era. For example, cities with universities can now build paratroopers as well as special forces, rather than just special forces.
    • Minor civs receive extra tech diffusion (same as barbarians) for techs older than the current average era, to help them to be at least as advanced as barbarians.
    • If a unit is made obsolete but another unit it can be upgraded to can be built in a city, production is switched rather than lost.
    • Toned down sliding scale of Lead from Behind, made it so adjusted odds cannot be less than 10% of original odds, fixed bug where inflated odds had side effect of causing collateral damage units to always be chosen first as attackers.
    • Slightly more barbarian naval units can be spawned in the early game. BBAI restricted it until players had navies of their own, now a few barbarian naval units can be spawned but less than under default BTS
    • For the barbarian world option, barbarian cities can be founded on otherwise empty islands, and cities take longer before they can settle down to minor civs
    • For influence driven war, the owner of a city gets a 20% bonuses when gaining culture in the city tile. This gives defenders and advantage when killing attackers, but also makes it more useful to kill rebels/the original owner of a city near the city tile as it will increase your culture more and help keep the population in line.
    • The included GlobalDefinesAlt xml file includes some configuration changes I have made to influence driven war. I have set IDW_NO_CITY_DEFENDER_MULTIPLIER to 2.5, and IDW_CITY_TILE_MULTIPLIER to 0.15. This will increase combat influence on cities by 50% plus an extra 150% when the last city defender dies. (IDW defaults were 2.5 and 1.0, LoR defaults are 1.0 and 0.1). Emergency draft is now turned on, but only for cities size 20 or bigger, and drafted units are at 80% health. In this version, IDW_CITY_TILE_MULTIPLIER is not ignored when emergency draft is turned on like it is by default in influence driven war


    (Anti) Aircraft Changes

    AA is deadlier, put planes are deadlier to ships, click show to see details...

    Spoiler :

    • Added Afforess' AA Stack code, so the more anti aircraft units that are on a tile, the greater their chances are to intercept an air unit (in version 0.93 only units of the same domain i.e. land and land or sea and sea can stack)
    • AA units now do slightly more damage when intercepting units based on the relative strengths of the units. This is most noticeable when attacking with weaker units like the seaplane
    • AA units have a small chance to have more rounds of combat when intercepting air units (was 5, now up to 9). What this means is that there is a slightly higher chance for air units to be shot down rather than just damaged, and units with an intercept chance of less than 40% can now sometimes shoot down planes.
    • When air units attack ships, they can do 10% more damage than they could to land units. This means jet fighters and strike fighters can now sink ships. There is a small chance the ship will survive with just 1 hit point instead though.


    Other changes

    I've Added killmeplease's defender withdrawal mod - defenders with a withdrawal chance can withdraw to another plot or if in a stack, withdraw and let the next best defender continue the battle as a defender. This makes attacking more risky and interesting. I've made one change from the original, is that only one withdrawal can occur per battle, rather than up to 3 times.

    Other changes include barracks being cheaper in early game, and conquered cities more useful, click show to see details...

    Spoiler :

    • More buildings are kept when capturing cities in later eras. This is based on whether the building would be free if you started in the era you are currently in. For example, if you started a game in the medieval era, each city would gain a free granary. Now if you capture a city in the medieval era or later, granaries are guaranteed not to be destroyed. This makes captured cities more useful as you don't have to build so many buildings again
    • Cities can now control adjacent tiles even when they don't have the most culture in those tiles. Cities now always control adjacent coast tiles. And they will control adjacent land tiles unless another civilization has 3-4 times as much culture in them. This means cities acquired in the late game with little culture at least be able to work most of their adjacent plots.
    • The cost of barracks (any buildings that grants domain free experience to land units) scales based on the best available conscript unit, so it will be cheaper in the early game and more expensive in the late game.
    • Spies can be used for spying: when you keep a spy on a city tile, the cost of the investigate city passive espionage mission gets the same discount as spy missions. So if you keep a spy there for 5 turns the cost is halved and in many cases this is enough to allow you to investigate the city when you otherwise wouldn't be able to
    • Changed damage done by flanking to be related to the flanking "victims" strength, rather than the original defenders strength, so in most cases flanking does more damage
    • Require complete kills only requires all combat units and settlers to be killed, not all units (spies and workers aren't counted).
    • You can trade cities with your vassals, as long as they are not under occupation (the vassal may still refuse to accept the city).
    • You can liberate cities to players no cities, if they have at least 25% culture in them (only relevant with require complete kills on).


    Optional/configurable elements


    Dynamic Difficulty

    As you start to win, you will find your costs will increase and the AI will gain more discounts (usually up to an extra 15%, depending on type of bonus, the equivalent of going up 3 difficulty levels).

    Unlike the flexible difficulty mod, the AI bonuses and human handicaps will increase gradually 1% at a time, and the types of bonuses the AI gets vary depending on the situation. For example, of the human is powerful, the AI will get cheaper troops and lower troop upkeep costs. If the human is more advanced, the AI will get lower civic upkeep costs (so it can spend more on research) and cheaper projects (to build the internet or try to compete in the space race). Most other AI bonuses depend on the human score.

    The bonuses increase gradually, and you don't need to be winning overall for the AI to get a bonus, if you are above average power or near the top of the leader board expect the AI to get a small boost compared to your standard difficulty. The aim is to keep the game challenging the whole time, with an overall cap on the bonuses the AI can get so you can actually win eventually.

    This can be disabled by setting DYNAMIC_DIFFICULTY to zero in the included GlobalDefinesAlt XML file.

    Tech cost increases in the late game for the human player only

    Dynamic Difficulty does not affect the costs for human players to research, I couldn't find a satisfactory way for research costs to fluctuate. Instead, research costs will increase for the human but not the AI from the Renaissance era onwards, ending up costing 20% more for the human player by the end of the modern era. This is in addition to the extra tech costs for humans based on the difficulty you are playing.

    This can be configured in the included GlobalDefinesAlt XML file, by setting the LATE_GAME_HUMAN_TECH_COST_INCREASE property, including setting it to zero to turn this feature off. (if the game starts in the Renaissance era or later, this change will not take effect until the player enters the next era)

    More expensive units in the late game for all players

    When any player enters the renaissance era and for each era onwards, the cost of all units for all players will increase by 5% per era. This is not to increase the difficulty or give an advantage to any particular civ, it is merely a scaling change because I find excessively large unit stacks in the late game to be tedious. This also affects the costs to upgrade units. If the game does not start in the ancient era, units will start getting more expensive from 3 eras after the start era instead.

    This can be configured in the included GlobalDefinesAlt XML file, by setting the LATE_GAME_UNIT_COST_INCREASE property which is the per era costs increase for units, and can be set to zero to turn this feature off. Note, the cost increases are additive rather than multiplicative, so if you are on epic game speed unit costs will go from 150% to 155% compared to normal speed, rather than from 150 to 157. This is because I prefer round numbers :)

    Bigger civilizations research techs slower

    When a civilization reaches a certain size (the total percent of land it takes up is more than 100 divided by the default number of players for your map size), it will start to research techs slower. This effect increases as the civilization grows. This is meant to be like the number of cities maintenance but for research rather than gold. It should not have so great an effect that capturing extra cities is actually detrimental to your overall research since these cities will be adding research of their own that should be more than enough to counteract the effect, but it does mean that larger civs will now not be guaranteed to be the tech leaders, and decreases the runaway effect where civs quite quickly become too big and advanced to be stopped. Now big powerful civs may still have to trade techs, or bully smaller but more advanced civs, or use espionage to steal what they want.

    This can be disabled by setting BIG_CIV_SLOW_TECH to zero in the included GlobalDefinesAlt XML file.

    Progress Based Inflation

    Inflation now differs per civilization, and is partially (or completely, depending on how you configure it) based on how advanced the civilization is. Inflation will start to kick in around the medieval period, and max out at 100% towards the end of the modern period. Military techs, and "gold" techs (those that have gold flavors, like banking etc.) increase inflation more. Production and science techs do not increase inflation. This can help civilizations that are behind to catch up, but can also help in situations where the whole world is locked in war from the beginning, and you end up with high inflation despite no civilization having actually gotten that advanced.

    This can be configured by changing PROGRESS_BASED_INFLATION in the included GlobalDefinesAlt XML file, and comes in 3 flavors. Set it to zero to turn this feature off, and use the old inflation calculation based on the number of turns elapsed. Set it to 1 for inflation to mainly be based on the number of turns elapsed, but also partly on how advanced the civilization is. Set it to 2 for inflation to mainly be based on how advanced the civilization is, but also be affected by how many turns have elapsed. Set it to 3 for inflation to be entirely determined on how advanced the civilization is, with the number of turns elapsed being ignored.

    Sometimes quick combat

    I've changed quick combat so it will always be applied when a human controlled attacker is over twice the strength of the defender, i.e. battles you are almost certain to win aren't animated, but other are. This only applies of you have quick combat turned off to begin with, otherwise combat is always quick.

    This can be disabled by setting SOMETIMES_QUICK_COMBAT to zero in the included GlobalDefinesAlt XML file.

    Easy Trade Network

    With this option on, all of your cities and the cities of civs you have open borders with are connected to each other by default, providing:
    - You have researched roads and
    - you are not blocked by jungle (they only tile that still needs roads to be able to trade through)
    You must still build roads under resources for them to count as connected, but you do not actually have to connect them with anything

    This can be disabled by setting EASY_TRADE_NETWORK to zero in the included GlobalDefinesAlt XML file.

    Quick Start

    This option is intended to make the start of the game go more quickly, without going as far as starting in a later era. So far all it does if give two free techs at the start of the game, one which has one or both of your civs normal starting techs as a prerequisite, and one which has no prerequisite.

    This can be disabled by setting QUICK_START to zero in the included GlobalDefinesAlt XML file.

    So that's it, download and enjoy and let me know what you think! There are two attachments below, LoR ModMod v0.94.zip contains the compiled DLL and the XML configuration file you will need, and LoR ModMod Source.zip is the C++ source code for anyone who's interested.
     

    Attached Files:

    Last edited: Oct 7, 2016
  2. Dave_uk

    Dave_uk Chieftain

    Joined:
    Oct 6, 2009
    Messages:
    31
    Location:
    Oxford, UK
    I've exceeded the character limit in the first post, so I'll add a fuller description of new v0.94 features here.

    Fractional additional unit costs

    The base support cost of a unit is now based on it's cost to build, and is equal to the population that would be require to conscript it. The cost above 1 is considered as (and shown in the finance screen as) as the "extra unit cost". The extra cost can be a fraction and is reduced by up to 50% based on how strong the unit is compared to the strongest unit available, and 25% based on the number of units of that type that have been built in total, by anyone. Therefore strong, new units cost more to support than old obsolete ones. The overall cost is rounded down to a whole number. Units that already have an extra unit cost defined in the xml use that figure instead.

    City governors

    The AI and human automated governors have been made aware of revolutions and the risks of losing city plots to rivals civs through cultural pressure, and will value culture more in these circumstances, as well as a few other improvments.

    AI Attitude & Diplomacy

    The AI will care less about "initial impressions" (peaceweight and warmonger respect) when picking it's worst enemy. The worst enemy of an AI has more to do with what a civ has actually done to please or displease them after they've met, and is therefore likely to change throughout the game.

    When calculating AIs attitude towards a team, vassals matter much less. Previously each vassal counted as much as master team, now if the team has 1 vassal, vassal attitude counts as half, and if they have two or more vassals the attitude towards all vassals combined counts only as much as the master.

    The AI will be less likely to open borders with civs it has just met, in certain circumstances.

    The AI will be more likely to "peace vassal" with another civ when it is being beaten badly in a war.

    The AI will sign defensive pacts more urgently and at lower attitudes (pleased rather than friendly) if it feels it's about to be attacked.

    The AI is smarter about accepting a request to go to war with another civ. They will sometimes consider going to war with a second civ while already at war or planning a war with one. They will be more willing to join a war you are already fighting even if they don't normally like you enough. They will be more willing to go to war with a weaker civ, even one that they like. But they'll be less open to being asked to go to war with a stronger civ. Ruthless AI will only be willing to go to war with weaker civs

    AI Warring

    The AI will build more units when involved in overseas wars (but still less than when involved in land wars). It should be better at bombarding enemy cities with it's ships, and better at picking where to land amphibious assaults.

    The AI should be smarter about who to go to war with, be less constrained about always preferring direct neighbours while still prefer close targets, and consider to overall costs and benefits of going to war.

    The AI should be better at using nukes and air units, will spread it's AA units about more evenly, be better at supporting team-mates, better at modern warfare in general.

    The AI will more often going for the domination victory - which will now be more appealing to AIs on pangea type maps where they have the most power locally, since it's more plausible for them to achieve.

    I'm trying to make the AI less reliant on random numbers to decide when, how, and against who to go to war. The progress made towards this so far is that the AI will always consider more distant targets when it's friendly with it's neighbours, the default code meant that either it was OK to attack friends in which case neighbours were always considered a priority, or it wasn't, but this was completely random and no based on an analysis of the relative merits of either war. The AI will also be more likely to go to war when it knows many civs who are the right combination or weaker and not friendly. The AI will consider switching to a "dogpile war" against a stronger civ it wants to attack, rather than just giving up. I'm looking at adding triggers that make it likely for the AI to go to war, while still be constrained by attitude, personality (WarRand) and what they've currently got going on. One has been added so far, when a new valuable bonus is revealed that the AI doesn't have in their lands they'll consider attacking a civ that does have it.

    Share War Counter ("mutual military struggle") now decays overtime

    If you ever shared a war with another civ, the "mutual military struggle" modifier used to last for the rest of the game, causing them to be more friendly with you and consider themselves allied for the purposes of making permanent alliances. Now this counter will gradually decay if you aren't currently involved in a mutual military struggle. The counter reduces by 1 every turn that the civ is involved in another war that you aren't helping with, or if ruthless AI is turned on. Otherwise there's a random 1/25 chance each turn that the counter will reduce, similar to how the AI "forgets" other things that have happened and affect attitude.
     
    Last edited: Oct 7, 2016
  3. lfgr

    lfgr King

    Joined:
    Feb 6, 2010
    Messages:
    799
    This looks really cool.
     
  4. Spirictum

    Spirictum Immortal

    Joined:
    Oct 19, 2007
    Messages:
    3,105
    Location:
    Brazil
    Congratulations Dave, these changes seem very interesting to the game, and I hope it can make Deity less unforgiving as you said. I will test this as soon as one of the two games I'm playing end (actually I hope to test it in multiplayer single mode, as I don't play single player anymore, and not in multiplayer with friends).

    A quick look at what you've changed got me to agree with most things, and actually I don't disagree with any of them, there is only one which I must say a few words.

    The killmeplease's defender withdrawal mod.

    Actually it seems pretty reasonable to incorporate it, but in LoR (not sure in original BtS or others) we have 100% withdrawal chances units with ease. Any unit which can have Guerilla and Flanking may get to 100% if you put a GGen on it. So the only way for them to die was a massive attack from the enemy to destroy your Stack, because when attacking, they never die.

    Some may say this is a cheat and is gamebreaking, others may say it's not because it applies only to GGens. In fact, it is and it is not.

    It is because in the late game you may have any unit 100% from the generals you have been training since a long time, except some boats. Explorers, Musketmen and Attack Subs are the first 3 units that are able to become 100%. If you check the Unit Promotion page of Civilopedia you'll see that Assault Mechs, Mech Inf and Mobile Sam can all come from the Musketman, and Gunship, Modern Armor, Air Assault and Special Forces can all come from the Explorer. Including the Attack Sub, this leaves only the rest of the naval units, air units and the Siege family off. But some may say they will be a few, like 3 - 5 GGens in the late game. This depends on your ways of conducting a war and your knowledge of the revolution system. Revolutions in LoR may give Generals for free. Allied to that 100% GGens may attack every turn, and if you have a poor neighbor right outside your border, you may attack him every turn.

    And then you realize that Pathfinders make the best 100% initial GGens, as they don't need the flankings to become 100% (so just putting a GGen gives enough XP to become 100%: Guerilla 3 and Tactics) and they may get up to 3:move: and Blitz. And this means that if you have that neighbor to attack every turn, a snowball effect takes place. More GGens generate more GGens and so on. Allied to that you may still have an Imperialistic Trait, the Great Wall and/or the Brandenburg Gate (getting to a total max of +300% GGen production). In the game I'm playing now with a friend, I'm the Aztec, and oppressive Tokugawa took Tenochtitlan in the early game, leaving me with a single city in the continent, but with an enemy city right outside my borders since before christ. Now in the decade of 2030 of all my GGens I have 5 Tanks with more then 1000XP (they may only get Amphibious and one or two can get Vs. Armored Units still), one with almost 1000 XP, a non 100% withdrawal with less then 150XP (my only non 100% withdrawal Gen, I had other but it died a few turns ago), 3 Grenadiers and a Riflemen with ~100 XP and 3 Pathfinders with ~700, ~500 and ~300 XP each. This is only in the main army. In my big Island I have 4 Pathfinders with ~500, ~200, ~100 and ~50 XP and in my Core I have a single Pathfinder with ~50 XP. Soon I'm making another GGen. I don't remember exactly, but I'm sure I lost some Generals through the game, so imagine How many Generals I got (and I'm not Imperialistic, nor have the Great Wall or the Brandenburg). So in some ways it is gamebreaking.

    OTOH it is not, because the AI is unbalanced on Deity. The number of units the AI can have and still be the leader of research is absurd. Tokugawa in this same game is the tech leader since he discovered writing when he had just popped from a barb city with 40 Axemen. I'm not sure if the 40 popped from the Golden Age, but when he came he had 40 Axemen (at least 20 popped), before christ and reduced me to 2 cities (from 8). For a long time he had like 100 units on my ex-capital and was still conquering far off lands with other strong stacks, and he never lost the position of tech leader. When I was reduced to 2 cities, I decided it was the perfect time to change to Despotism (Spiritual, few cities, doomed anyway) and use my Spies to change him too. This was the relief of the World, Tokugawa lost all 3 religious shrines to other civs, the Celts, Koreans, Vietnamese, Arabs, Chinese and Aztec(me) popped from his empire, tearing his territory and taking more then half his cities, with the gift of many techs only he had and making trades with the rest of the world. Well it didn't last long, for this only accelerated his tech power and then he took everything back. Here in Spoils you may see a few numbers of how many units I've been killing, most of them (like 90%) are his. Imagine he lost at least this same number to other nations (mostly of older units) and he is still the tech leader by far (he is researching Satellites while the second best has just got Radio, which he has). 99% of the units I lost were killed by him.

    Spoiler :


    If I didn't have my uber GGens I would be long dead.

    So if these uber generals could withdraw on defense, we could be a lot less protective when using them to attack enemy lands, and if we remove the 100% withdrawal feature, Deity AI would win most games. It's not a bad improvement to the game, but it makes our lifes easier on Deity.

    I loved your idea of Inflation and I hope to test it soon, but I have this multiplayer single game I must finish, where I'm testing my mod to the Random Events, and until now it's doing fine, quests are more common and at least one former single player only event has worked properly on multiplayer game (the Tea event).

    My next mod in REs will be to reintroduce unique religious events (BtS has one for each of Buddhism, Judaism and Christianity but they are disabled by default) creating one for the other religions and to make civ-unique events too, as BtS have only for the Aztec (which needs one good option, because it only has bad options), American, Russian, French and Egyptian


    Almost forgot: Perm Alliances need to be studied and debated. I'm not sure yet, but It's not so hard to make a perm alliance with someone who loves you, and when this guy is at least big and strong, this is your ticket to win the game if other human players can't make perms with good AIs. Making it easier will make it a needed move to win the game. When you have a perm ally strong enough to survive, you may get all his income just by asking, and he will still be able to survive, because Deity AI has lots of bonuses. I didn't explore much this subject, because besides being not so hard, it's hard to make perms when you are weak for a good part of the game (someone strong will attack you and convince others to join him, destroying your good relations with friends) and when you're strong (because all other strong AIs will most probably try to slow you). It first got my mind when I was playing a game with the Iroquois, and my objective was to put as much culture as needed on my vassal cities to get them already Legendary and win by culture. I was doing great by my own, but things were getting hotter as my human "friend" was going for tanks, and the Aztec AI had Uranium and was going for satellites. My economy was good, I could make some gold and spend it at 100% to make Espionage, but I was behind in tech. Then suddenly one of the tech leaders asked for a perm, I accepted and then I asked for all his income gold. He gave me more then 1000 gold per turn, so I could be 100% winning hundreds of gold. This meaned I had top techs now, and enough gold to keep in 100% espionage to fulfill my objective, and then I won in the 1990s.
     

    Attached Files:

  5. Dave_uk

    Dave_uk Chieftain

    Joined:
    Oct 6, 2009
    Messages:
    31
    Location:
    Oxford, UK
    I usually play at prince level single player, so your games are probably quite different to mine. It will be interesting to see how these changes affect your game.

    I haven't tested in multi-player, but I don't think I've done anything that will break multi-player so it should work. In fact for dynamic difficulty I have taken multi-player into account, the AI will get bonuses depending on how well the top ranked human player is doing. To be honest, dynamic difficulty probably won't affect you much if you start off at deity level, your costs can't increase since they are capped at deity level, and the AI already gets such a bonus that they won't get additional bonuses until you are further ahead.

    Re: defender withdrawal, the unit can only withdraw once, either behind another unit if it is in a stack, or to a tile away from the attacker if there is a tile to move into and it is faster. Once it has withdrawn once, the AI could still come in with another unit and finish it off (if it's in a stack they'd have to kill the other units first, but they'd probably have to do that anyway since lead from behind probably would make them defend last). So hopefully it won't make things too easy.

    To elaborate on alliances, the AI will not make an alliance if they are over 20% more powerful than you, or if you are small enough to be their vassal (50% land and population), unless you have also shared a war of defensive pact for long enough as before. I could add other conditions if alliances are still to easy to form. My reasoning behind changing the alliance code was that often it would be very beneficial for the AI to join an alliance, and they have a potential partner who they are friends with, but they don't because of the shared war or defensive pact requirement.
     
  6. Spirictum

    Spirictum Immortal

    Joined:
    Oct 19, 2007
    Messages:
    3,105
    Location:
    Brazil
    Your answers were perfect.

    For the AI difficulty it seems perfect, it only affects them if the Human is better and it won't make deity more difficult.

    For the defensive withdrawal it's perfect too, only one withdrawal is a great new feature and it won't let the units invincible.

    For the Perm Allies I still have to see this happening more on Deity to make some conclusions. What I think is broken is the ability of requesting all their income gold for free. They shouldn't give this away so easily. It is gamebreaking of sorts, because you're getting a super bonus huge income for free from someone who can rearranje his empire to keep things under control, even if he gives you all his income. And now you have an income that reflects the bonuses of a Deity AI, in contrast to all your penalties for playing on Deity.
     
  7. lfgr

    lfgr King

    Joined:
    Feb 6, 2010
    Messages:
    799
    I don't have much playtesting feedback yet (got beaten up by the AI last 2 times), but a bug report: when using AIAutoplay and sometimes when starting a scenario (I believe if not choosing the first player), the game crashes.
    Your getHighestRankHumanPlayer/Team functions return crap if there is no human player (they return 51, which is probably the loop variable (!). You didn't specify a return value in case no human player is found. I'm surprised that compiles :)).
     
  8. Dave_uk

    Dave_uk Chieftain

    Joined:
    Oct 6, 2009
    Messages:
    31
    Location:
    Oxford, UK
    Hm I've never hit that when I've used AIAutoplay but you're right, I don't account for the situation when there is no Human player, so I'll fix that.

    I've also realized there are two changes to the SDK that I forgot to mention and I think I will actually remove in the next version:

    I've commented out the code that blocks you from voting yourself for diplomatic victory. But I've never actually been in the situation to check that it works, and I've decided that change is unnecessary so I'll probably put it back in the next version.

    I also added a soft limit to the amount of espionage points that can defend against passive espionage missions. For example, you don't currently always need double a civs espionage points to investigate their city, it also depends on their technology level, the rev index and culture level they have in that city. I've decided I don't really like how it works though as it's more complicated, and now that spies can be used to make investigate city cheaper it's not really needed. So I'll probably get rid of this too.

    I've also decided the effect of slower tech for larger civs technology can get a bit too big when the civ is very large e.g. near the domination limit, so I've toned it down a little.

    So I will release a new version soon, but hopefully the current version is OK still other than these known issues.

    One final thing I forgot to mention is that when trading resources, the AI now values resources more based on how the available buildings that can boost them. For example, they'll value seafood based on how many coastal cities they have once they can build a harbor, they'll value cereals more once they can build a granary, and they'll value livestock more when they can build a supermarket. There was actually code there to do a similar thing already, but it was based on the number of buildings actually built and I've based it on where the buildings can be built. This way it doesn't fluctuate too much. The reason I mention this is that since the AI doesn't value all resources the same they won't always trade then 1-1 with you anymore, but this is deliberate rather than a bug.
     
  9. Dave_uk

    Dave_uk Chieftain

    Joined:
    Oct 6, 2009
    Messages:
    31
    Location:
    Oxford, UK
    Ok a new version is up correcting these issues as promised.
     
  10. Dave_uk

    Dave_uk Chieftain

    Joined:
    Oct 6, 2009
    Messages:
    31
    Location:
    Oxford, UK
    I've uploaded a new version with a few more tweaks and a new map script. Any feedback on the mod so far?
     
  11. Spirictum

    Spirictum Immortal

    Joined:
    Oct 19, 2007
    Messages:
    3,105
    Location:
    Brazil
    Sorry man, older projects and college are taking all my attention. But I guess this Easter I may get the time I need.
     
  12. Dragonxander PR

    Dragonxander PR Emperor of the Drakons

    Joined:
    May 25, 2009
    Messages:
    545
    Location:
    Mayagüez, Puerto Rico
    Is this open for contribution with maps and scenarios? Lean and I have just returned to making those, the main of which will be based on a Giant Earth Map we're making ourselves!

    I'll give a try to the mod--I'm actually curious how it'd play out. The PerfectWorld script seems really, REALLY appealing! I'm rather unsatisfied with the previous versions that emphasize the huge continents.
     
  13. Conqueror Worm

    Conqueror Worm Warlord

    Joined:
    Jan 22, 2006
    Messages:
    256
    Great Mod!

    Just one thought/request. It would be really cool if there were a way for one to set the Dynamic Difficulty to max out at Deity instead of Emperor. You couldn't provide an alternative dll for that, I don't suppose.

    Anyway, great work, and thanks again Dave!
     
  14. Dave_uk

    Dave_uk Chieftain

    Joined:
    Oct 6, 2009
    Messages:
    31
    Location:
    Oxford, UK
    Yeah I'd be happy to have contributions, it would good for those of us making changes to stick together. Not sure how to organize it though, you could just attach stuff to this thread for now and I could add it to the main download.

    Yeah I'm quite happy with it. I mostly just changed some constant values at the top of the map script, they made it quite easy to tweak. Getting the type of map I wanted was the tricky part. I found the best way to get more continents was to generate a bigger map and then shrink it down more. Because of this it takes slightly longer to generate the map. But it hasn't been too bad on my machine, personally I don't mind waiting an extra minute or two for the map to generate given how long a civ game lasts overall. It's pretty variable so you do still sometimes get huge continents but usually you end up with several smaller continents with a few civs on each.

    The readme file is misleading and I need to change it, the limit should be approximately the same as going up 3 difficulties from your starting difficulty (I say approximately because it depends on the starting difficulty, the difference between immortal and deity is about the same in terms of bonuses the AI gets as between Noble and immortal). So it will only be limited to emperor difficulty if you start at noble. When I used to play on noble I found that difficult enough. I've play-tested it starting at Prince and Monarch instead and it seems about right for those difficulties too, so hopefully it should pretty well at all difficulty levels.
     
  15. Dragonxander PR

    Dragonxander PR Emperor of the Drakons

    Joined:
    May 25, 2009
    Messages:
    545
    Location:
    Mayagüez, Puerto Rico
    Just tried the script separately--it makes, at last, maps I want to try unchanged! I'll bring some samples of what I get soon, perhaps as soon as tonight. I'm yet to try the mian mod-mod, as I'm not quite ready to commit to it.
     
  16. stolenrays

    stolenrays Deity

    Joined:
    Aug 2, 2009
    Messages:
    2,061
    Have you coded AI for DCM? Only RBombardment and Fengagment have AI already written. Howeer, Fighter Engagement is not called upon. I haven't gotten around to writing the new AI, but it shouldn't be that difficult.
     
  17. Dave_uk

    Dave_uk Chieftain

    Joined:
    Oct 6, 2009
    Messages:
    31
    Location:
    Oxford, UK
    I've only made one minor AI change regarding DCM and that is that if a unit has nothing to do and isn't damaged, it will range bombard rather than skipping it's turn if there are nearby units it can target. I haven't done anything regarding fighter engagement.

    It would be cool if the AI could use DCM properly, it's probably not something I'm going to be looking at myself anytime soon though. I haven't made any changes to the DLL since I released the last version since I'm playing though a game at the moment, and my next priority would be to fix any bugs or issues found with the changes I have made so far.
     
  18. stolenrays

    stolenrays Deity

    Joined:
    Aug 2, 2009
    Messages:
    2,061
  19. nfw

    nfw King

    Joined:
    Aug 31, 2010
    Messages:
    733
    Is there a way to turn off individual features? For example I don't like how defender withdraw works (like the concept but not the execution), can I turn it off? Is it in the xml somewhere?

    I'm also getting a lot of tech trade offers where the AI offers me like 50 gold for chemistry, and I'm pretty sure they haven't partially researched those.

    Also the AA stacking mod is way overkill. Mao had a dozen AAs in one city and none of my 20 bombers got through.
     
  20. Dave_uk

    Dave_uk Chieftain

    Joined:
    Oct 6, 2009
    Messages:
    31
    Location:
    Oxford, UK
    I’ll consider making defender withdrawal optional via an XML setting in the next release. I understand it’s not to everyone's taste. You say you like the concept but not the execution, what do you mean by that? How else could it work?

    That's weird, I'm not sure what would cause that. I assume you mean they are asking you for the trade, rather than you asking them what they'd give you for the tech? Are you sure they haven’t been given free beakers for it via tech diffusion even if they haven't researched it themselves? I’ll fix it if I can reproduce it.

    That's doesn't sound possible. Each AA unit can only intercept once per turn, so they must have had at least 20 AA units to intercept your 20 bombers.

    Even if they did have 20 AA units, the stacking effect of the chance to intercept only counts units that haven't already intercepted, so the chance to intercept decreases the more bombers that have already been intercepted. Also, bombers have a 15% chance to evade interception regardless. To have all 20 bombers intercepted would be quite unlucky.

    In general though, if the AI has lots of AA units in a city then it's not usually a good idea to bomb it anymore. The point of the stacking code was to make AA units a worthwhile defense against this, so you will have to use other tactics. Try sending more ground forces and artillery instead, or bombarding from the sea if possible. The jet and stealth bombers can be more useful here since they have higher evasion chances. If you do decide to bomb a city with a lot of AA units, expect a high intercept rate, it's best to do all the bombing in one turn right before you attack to make it worthwhile.
     

Share This Page