UncutDragon
Chieftain
For BtS v 3.19 - download it here
At the core, this mod is about trying to keep valuable units safe (or at least safer ...). The standard algorithm would pick units to attack or defend based on their relative strengths. This would lead to more valuable units being picked even when it's a 'suicide mission'. It also meant that Great General's got used as healer's since otherwise they could easily be killed when moving around (even if part of a large stack).
This mod tries to make the unit choice a little more intelligent, factoring in the 'value' of the unit. Value in this context is roughly equivalent to 'rare' - units that you wouldn't generally have a lot of, so would really hate to lose.
Changes in this mod:
-Best Defender code is modified to use the actual combat odds to determine the best defender. It also evaluates the value of a unit and uses that to 'adjust' the odds to come up with a defender ranking (making them more likely to defend if they have an excellent chance of winning - less likely otherwise). The amount of the adjustment depends on the value of the unit.
-Likewise, the Best Attacker code uses combat odds and adjusts based on value.
-Some speed improvements to combat in general, and combat odds in particular. Most notably, use of a cache to store partial combat odds to reduce the computations needed. Even with the use of combat odds, stack combat (1 large stack attacking another large stack) now takes roughly half the time.
The criteria for what makes one unit 'more valuable' than another is based on: are they led by a great general? how much experience do they have? are they a unit that's limited in the number that can be produced? do they have the ability to heal? (This last one is a bit different from the others in that you can easily create a lot of healers ... but generally you'd rather leave that to a few units, seeing as only one healer/stack will actually do anything).
Source code is included under CvGameCoreDLL - just search for UncutDragon to find my changes.
You can adjust the behaviour somewhat with the Config settings in the included xml file:
Updated to v1.1 - changes:
- Fixed a bug that was causing a python exception in the best attacker code when there was no defender (only appeared if you had python exceptions enabled)
- Changed the experience valuation to use tiers (instead of 25% more than the other unit)
- Changed the odds adjustment to use the value (instead of only adjusting when more valuable) and use difference from 99% (instead of 85%)
Updated to v1.2 - changes:
- Changed value adjustment to (odds-990)*(value*numerator/denominator)^2 - numerator/denominator are config settings with a default of 1/3
- Changed best defender code to ignore value adjustment when attacker has a limit to the damage it can deal (e.g: siege engines)
- Changed best attacker code to factor in chance of withdrawing
(Basically the last two changes are to base the value adjustment on chance of living through the battle instead of chance of winning)
At the core, this mod is about trying to keep valuable units safe (or at least safer ...). The standard algorithm would pick units to attack or defend based on their relative strengths. This would lead to more valuable units being picked even when it's a 'suicide mission'. It also meant that Great General's got used as healer's since otherwise they could easily be killed when moving around (even if part of a large stack).
This mod tries to make the unit choice a little more intelligent, factoring in the 'value' of the unit. Value in this context is roughly equivalent to 'rare' - units that you wouldn't generally have a lot of, so would really hate to lose.
Changes in this mod:
-Best Defender code is modified to use the actual combat odds to determine the best defender. It also evaluates the value of a unit and uses that to 'adjust' the odds to come up with a defender ranking (making them more likely to defend if they have an excellent chance of winning - less likely otherwise). The amount of the adjustment depends on the value of the unit.
-Likewise, the Best Attacker code uses combat odds and adjusts based on value.
-Some speed improvements to combat in general, and combat odds in particular. Most notably, use of a cache to store partial combat odds to reduce the computations needed. Even with the use of combat odds, stack combat (1 large stack attacking another large stack) now takes roughly half the time.
The criteria for what makes one unit 'more valuable' than another is based on: are they led by a great general? how much experience do they have? are they a unit that's limited in the number that can be produced? do they have the ability to heal? (This last one is a bit different from the others in that you can easily create a lot of healers ... but generally you'd rather leave that to a few units, seeing as only one healer/stack will actually do anything).
Source code is included under CvGameCoreDLL - just search for UncutDragon to find my changes.
You can adjust the behaviour somewhat with the Config settings in the included xml file:
Spoiler :
LFB_ENABLE - Whether to even use the new code (0-false/1-true) ... if set to false, the code will essentially work the same as it would without the mod ... only faster. It turns off all gameplay changes, as well as the combat odds cache. But it leaves in a couple other (pure) speed improvements.
LFB_BASEDONGENERAL - Whether to treat troops led by Great Generals as more valuable.
LFB_BASEDONEXPERIENCE - Whether to treat troops as more valuable based on experience. This one is a little different in that it's not a straight yes/no - rather experience is evaluated in tiers (10/20/40/80/etc).
LFB_BASEDONLIMITED - Whether to treat units that are limited in the number that can be produced (whether on a world, team, or player basis) as more valuable. This will have no real effect on BtS, as the only limited classes are non-combat (Executives and Missionaries), but can be useful when merged with other mods.
LFB_BASEDONHEALER - Whether to treat units that can heal as more valuable.
(NOTE: All the 'BASEDON' settings are actually weights - each is checked seperately, and the applicable weights added up to determine the 'value' of the unit. e.g: If LFB_BASEDONGENERAL=5 and LFB_BASEDONHEALER=2, then a unit led by a great general will be considered more valuable then a unit that can heal - on the other hand a great general than can heal is even more valuable. The LFB_BASEDONEXPERIENCE will be applied for each tier - so a unit with 80 XP is on tier 4, so is given value 4*LFB_BASEDONEXPERIENCE. The total value is used in the odds adjustment - so units get a larger adjustment the more valuable they are)
LFB_USESLIDINGSCALE - Whether to adjust the ranking based on the odds of winning. If true, units with a 99% chance of winning are unaffected - better odds than that, and they're made more likely to defend - worse odds, then less likely - and the further away from 99% you are, the greater the adjustment. If false, ranking is always reduced - the amount of adjustment is not affected by the odds, but will still vary based on the value.
LFB_USECOMBATODDS - Whether to use combat odds in the best defender/attacker calculations. Turning this off will make it use strength (similiar to the old method, but modified a bit) but still including the value adjustment. I originally put this in since using combat odds slowed things down considerably - but with the speed improvements I was able to make, combat is actually faster now than it was before. Regardless, the option is there - turning odds off will basically cut the combat time in half again (making it take approx 1/4 the existing code).
LFB_ADJUSTNUMERATOR/LFB_ADJUSTDENOMINATOR - These settings let you adjust the degree of adjustment. The actual adjustment is (odds-990)*(value*numerator/denominator)^2
LFB_BASEDONGENERAL - Whether to treat troops led by Great Generals as more valuable.
LFB_BASEDONEXPERIENCE - Whether to treat troops as more valuable based on experience. This one is a little different in that it's not a straight yes/no - rather experience is evaluated in tiers (10/20/40/80/etc).
LFB_BASEDONLIMITED - Whether to treat units that are limited in the number that can be produced (whether on a world, team, or player basis) as more valuable. This will have no real effect on BtS, as the only limited classes are non-combat (Executives and Missionaries), but can be useful when merged with other mods.
LFB_BASEDONHEALER - Whether to treat units that can heal as more valuable.
(NOTE: All the 'BASEDON' settings are actually weights - each is checked seperately, and the applicable weights added up to determine the 'value' of the unit. e.g: If LFB_BASEDONGENERAL=5 and LFB_BASEDONHEALER=2, then a unit led by a great general will be considered more valuable then a unit that can heal - on the other hand a great general than can heal is even more valuable. The LFB_BASEDONEXPERIENCE will be applied for each tier - so a unit with 80 XP is on tier 4, so is given value 4*LFB_BASEDONEXPERIENCE. The total value is used in the odds adjustment - so units get a larger adjustment the more valuable they are)
LFB_USESLIDINGSCALE - Whether to adjust the ranking based on the odds of winning. If true, units with a 99% chance of winning are unaffected - better odds than that, and they're made more likely to defend - worse odds, then less likely - and the further away from 99% you are, the greater the adjustment. If false, ranking is always reduced - the amount of adjustment is not affected by the odds, but will still vary based on the value.
LFB_USECOMBATODDS - Whether to use combat odds in the best defender/attacker calculations. Turning this off will make it use strength (similiar to the old method, but modified a bit) but still including the value adjustment. I originally put this in since using combat odds slowed things down considerably - but with the speed improvements I was able to make, combat is actually faster now than it was before. Regardless, the option is there - turning odds off will basically cut the combat time in half again (making it take approx 1/4 the existing code).
LFB_ADJUSTNUMERATOR/LFB_ADJUSTDENOMINATOR - These settings let you adjust the degree of adjustment. The actual adjustment is (odds-990)*(value*numerator/denominator)^2
Updated to v1.1 - changes:
- Fixed a bug that was causing a python exception in the best attacker code when there was no defender (only appeared if you had python exceptions enabled)
- Changed the experience valuation to use tiers (instead of 25% more than the other unit)
- Changed the odds adjustment to use the value (instead of only adjusting when more valuable) and use difference from 99% (instead of 85%)
Updated to v1.2 - changes:
- Changed value adjustment to (odds-990)*(value*numerator/denominator)^2 - numerator/denominator are config settings with a default of 1/3
- Changed best defender code to ignore value adjustment when attacker has a limit to the damage it can deal (e.g: siege engines)
- Changed best attacker code to factor in chance of withdrawing
(Basically the last two changes are to base the value adjustment on chance of living through the battle instead of chance of winning)