K-Mod: Far Beyond the Sword

As karadoc said, the AI might ignore these thresholds when it's focused on conquest victory (and I think it makes sense that it pursues its victories ruthlessly). And I don't think that's new compared to BtS vanilla.

I'm not a coder but looking at CvTeamAI::AI_noWarAttitudeProb it seems to me that the vanilla code has been altered by BETTER_BTS_AI for the AI to, as you say, pursue its victories ruthlessly.

Personally, I don't like that change and I would revert it to the vanilla code, but if possible I'd like a confirmation of this before doing that.

Thanks.
 
[...] I was wondering if you could release a K-Mod 1.31 Debug DLL. I'm not sure how much work would be involved, so if you are too busy that's OK. Thanks!
Well, to be honest it would be very little work for me to do, but I'd rather not become committed to doing that little bit of extra work. I think it's best if other modders use the source code to make their own debug version if they are trying to get something working for their mod. -- But if you do find a bug in the K-Mod dll, I'd be happy to fix it - even if it doesn't actually effect K-Mod itself.


@Pleiadian, Thanks for your feedback. Regarding the AI's use of ICBMs, that certainly is something that needs a bit of work. So far, I've only made significant changes to the probability of the AI building nukes. I haven't really done anything with how they are used - and by the example you gave, it sounds like they really could use some more guidance... That's definitely something that I intend to look into at some point. (Not necessarily soon though.)

I'm not a coder but looking at CvTeamAI::AI_noWarAttitudeProb it seems to me that the vanilla code has been altered by BETTER_BTS_AI for the AI to, as you say, pursue its victories ruthlessly.

Personally, I don't like that change and I would revert it to the vanilla code, but if possible I'd like a confirmation of this before doing that.

Thanks.
You're more or less right; the effect of the noWarAttitudeProb thing was changed by the BBAI mod, and I've more-or-less kept their changes for that part of the AI. But old effects from the xml values have not been completely overruled; they still have a very significant effect.

-- To be honest, I think the original functionality was very poor; and the current functionality is only marginally better.

Here's how the system works, roughly speaking:
  • Each turn, the each AI player does some checks to decide whether or not they should consider war. I don't mean war with a particular foe, but just any kind of war. The checks are mostly just random.
  • If the above checks pass, the AI will evaluate the benefit of war with each other civ that they know; but each civ has a probability of being completely skipped over in these checks, randomly. The probability of being skipped over is determined by AI_noWarAttitudeProb.
  • The AI will then start preparing war against whichever team was evaluated to be the best war target. If all teams were skipped, then they won't prepare war against anyone.

That's how the system works in the both original BtS AI and in K-Mod. But here's what's different in K-Mod:
  • In the original BtS AI, AI_noWarAttitudeProb was simply given by the raw numbers found in the xml files. The BBAI mod changed this to subtract 30% to value for all targets if the AI was using the strategy called AI_VICTORY_CONQUEST4 - a strategy which basically means that the AI player is 100% focused on getting a conquest victory. K-Mod has kept this BBAI change.
  • In the most recent version of K-Mod, the evaluation function for potential war targets which pass the attitude test have been completely rewritten, and the original code has been disabled. The old version (which was mostly original BtS code, but with some minor BBAI tweaks) basically just added up populations and power and some other arbitrary numbers. It didn't have any kind of consistent scale; it made no attempt at being a cost-benefit analysis; and the value it returned was always a positive number. By contrast, new version used in K-Mod v1.31 attempts to weigh up the potential spoils against the economic costs of training units and so on. It tries to do this in a balanced kind of way such that if the war is deemed to be unwinnable, or simply not worth the cost, then the evaluation function would return a negative number - and when this happens (when the value is negative), the target is excluded from consideration for war.

At this point it is worth mentioning that the target evaluation function also has some strong dependance on attitude towards the target - so that noWarAttitudeProb is not the only time attitude affects the probability of war.

Ok. So... with all that explained, there are just two more things I want to say:

Firstly, the reason I said I didn't like this system is that to me it seems mostly random and arbitrary. Ideally, the AI would consider war against everyone on every turn (and only decide to actually go through with the war plan if the value of war was positive). It seems silly to me that the AI can simply completely ignore the very best war targets just because it got a couple of unlucky random dice rolls. If the evaluation function worked correctly, it could include all of the necessary probabilities and personality adjustments required to just check every potential target every turn.
However, implementing this ideal from the current state of the code is not an easy task, and it isn't even something I intend to do (for various reason that I won't go into at the moment).

Secondly, the -30% from AI_VICTORY_CONQUEST4 is completely necessary if you want the AI to ever be able to get a conquest victory. Otherwise, there will (almost) always be some team somewhere that the AI simply refuses to ever go to war with; and therefore conquest would be impossible. So if you want AI players to actually try to win the game, then there simply must be some way to overrule the usual 0% chance of declaring war at friendly.

Again, let me just reiterate that the 'noWarAttitudeProb' is not the only effect attitude has on war probability. Attitude is taken into account in the evaluation function itself; and so if you are friendly with a nasty-looking war-mongering civ who is en-route to a conquest victory, then it's actually pretty unlikely that you'll be their first target - unless you are a particularly tantalizing target.

The question of whether or not AI players should try to get conquest victories is an entirely separate issue. I've made the decision that in K-Mod, the AI will indeed consider going for that kind of victory, and thus they need to be allowed to backstab their friends in order to get that victory.

Short version:
The xml values are not ignored, but they are no longer the only part of the no-war probability. If they were the only part of the no-war probability, then the AI would never be able to win a conquest victory. I don't intend to revert this change.
 
Thank you very much Karadoc for this very detailed and comprehensive answer.

I guess I was a "particularly tantalizing target" but Indians are not supposed to be a "nasty-looking war-mongering civ"! :lol:

I should also say that I'm on a version of k-mod wich dates back to November 2011! I had to merge it with my mod and it was such a long and tedious job that I'm a bit afraid of updating it. I don't see changes from you on this particular part, so, for myself, I will revert to the vanilla code for now.

I understand your reasoning on all this and it is certainly an improvement on both vanilla and BBAI but personally, I usually don't go for a conquest victory against reliable friends so I don't want to allow it for the AI. I play for fun, not so much for victory and to be stabbed in the back like that embitters my vision of the game. On top of all, Asoka was largely winning by the points so I felt it totally unnecessary. As it happened, a second poor experience like that on the following game made me want to look into this problem.

What I might want to do is to change in the CIV4LeaderHeadInfos.xml file some 'friends' to 'unreliable' friends (in other words decrease some of the 100% value).

Many people are rightly criticizing the diplomacy aspect of the game but if you screw it in the back for a conquest victory, then it's simply no use to even try to be on friendly terms with certains Civs unless you are afraid of them.
 
If you want to have the possibility of some leaders being unreliable friends, but not other leaders, I think the easiest way to do that would be to change the noWarAttitudeProb in the xml to be something _above_ 100%. As I said, me most it can be reduced by is currently 30%, and so if you set it to 130 in the xml, they will never declare war. If you want to allow a very small chance of war for the conquest strategy, try 125 or something like that.

(I haven't tested this, and I haven't looked closely at the code to see if there are any caps on the xml number - but I expect that this technique would work.)


For updating merged K-Mod stuff, I'd suggest that the best way to do it would be to use git to automatically merge whatever it can. For example, if you have some merged version from way back in November, you could start by checking out that version's source code from github, then replace the source code with your merge and commit the changes; and then use 'git pull' to get the most up-to-date version of K-Mod. The bulk of it would probably update very smoothly; and any conflicts would be clearly marked. -- (If it turns out that it doesn't update smoothly, and there are too many conflicts to bother trying to fix; then I don't think it's a really great loss, because the steps I described don't take very long. (Unless you have no idea what I'm talking about, in which case it might take significant time to learn.))


--

On an unrelated note; I'm considering buffing Ship of the Line. In particular, I'm thinking of allowing them to be built with copper or iron, rather than only iron; or possibly increasing their movement from 3 to 4 (to be the same speed as frigates); or both; or something else. What do you guys think? Keep in mind that SotL is currently more expensive to build than frigates (120 vs 90); and it takes more advanced tech to build them as well.
 
ships of the line were big heavy buggers though weren't they? i'd say it's fair enough that they are slower than frigates. a buff of some kind would def be a good thing though, more of an incentive to build them then. what about simply upping it's strength from 8 to 9?

(edit) maybe that would be too extreme on reflection. the 50% versus frigs is pretty powerful already. something more subtle required. perhaps the allowance of building with copper might be best, prob unrealistic - but gameplay uber alles i suppose.
 
A resource change for ship of the line would have little effect in most games. I think a speed increase would be the best option. I rarely use them because the speed limit means even galleons just run away, and they are on a dead-end tech path.
 
I think the ship of the line was kind of hurt by my buff to ironclads (which had a moves increase from 2 to 3). Now, ship of the line just feels like a dud version of an ironclad to me. Obviously they have the advantage of being able to go into the ocean, but since they are slower than galleons and frigates it usually isn't a good idea to use them in over-seas battles anyway. Also, SotL is on a dead-end tech, and it costs more to build than an ironclad. ...

It would kind of be nice to have a movement speed somewhere between 3 and 4... but that doesn't really make sense; and I still don't regret the moves buff to ironclads. (One way to get closer to a half-way between 3 and 4 movement speed is to give them Flanking I for free, which naturally leads to Navigation I as their first promotion... but I'm not sure if that's a good idea.)

I just think the Ship of the Line is currently lacking a raison d'être. If the moves were increase to 4, it could be used as a beefy escort / war ship, alongside frigates and galleons. If the ship could be built with copper it would at least have a niche use as being the warship for ironless civs. (Currently, the toughest ship that can be built without iron or oil is a privateer. I think it would be kind of nice if they had another option; and I think SotL is a good candidate because it would encourage ironless civs to take a different tech path to iron-rich civs.)

Alternatively, the ship of the line could be completely rebalanced; for example, it could be increased to strength 9, have its frigate bonus decreased to 30%, and... well.. pretty much anything else.

I'd guess that this unit is least build unit of all in the games that I play. I certainly never build them, and the AI doesn't like to build them either. And grenadiers aren't too hot either, so the Military Science tech in general would probably benefit from a boost to this ship. (For me, the military academy is by far the most useful part of Military Science.)

I would like for the Ship of the Line to be useful, but still niche. I don't want it to be so strong that it becomes the most built ship of its time. I just want it to be at least worth considering; at least some of the time. -- If it was enabled with copper, but had nothing else changed, then it would become the ship of choice for ironless civs; which is a good start, but it might not be enough; and it might be a bit strange from a realism / consistency point of view. On the other hand, if it had it's moves increased to 4, it would become the best ship of its time -- but it would have the significant drawback of being far more expensive than frigates. I'm not sure if that change would be too big or not.
 
Thanks for the tips, Karadoc. But as you said, I have no idea what you're talking about the automatic merges with the git but it's good to know and I will have a look at it.

Personally for Military Science, I got rid of it since I thought it was a useless addition to the game. My Ships of the Line require Chemistry (as for Grenadiers). However, I do agree with Satrapper that since they were really heavy ships fully loaded with cannons, they should be slower than the other boats. I think that your idea of increasing their strength while diminishing their added strength against Frigates is correct.

As for Iron, that's a different story. It has always seemed to me unrealistic that a nation could suffer from a lack of Iron at a certain point of time. Personally, I have Iron Houses which provide that as from 400 BC. A Great General is required to build it as a national wonder. But that's just me...
 
How about increasing SOTL strength (from 8 to 9 or 10) and reducing their bonus vs frigates to perhaps 25%. I like little trade offs like that. I think a movement speed increase would be sensible as well, but I dont feel as strongly about that.

Its so awesome that you look into balancing alot of the underused units/civics!

Edit: Looks like you already said the same stuff in your last post. How about boosting Grenadiers attack vs rifles to 60% from 50%, and/or give them a free first strike?

On that note, representation is like mega popular for the ai Ive noticed in my last game of 1.3. Anyone else notice that?

Also, can we maybe rethink the cap on spies suppressing other spies? Like allow for multiple passive spies in cities (that you use for high risk targets)...it just gets mega annoying for enemy spies to continually blow up buildings in a city with barely any production, even with a counter espionage spy in it.

Maybe cap it at 2 or 3 counter espionage spies...or provide a negative chance at success for enemy spies in recently sabotaged cities...

I often get the feeling that my cities are just crawling with 100s of spies...lol. I usually get counter spies in most cities as well and manage my espionage advisor alot.
 
Started a new 1.31 game after I got destroyed, was playing donut map and the guy to my right (Zulu) got partially crunched by his neighbor (Persia), and so my neighbor (Zulu) vassaled to the neighbor to the north (Dutch) who hates me and 10 turns later I gotst crunched.
 
Well, to be honest it would be very little work for me to do, but I'd rather not become committed to doing that little bit of extra work. I think it's best if other modders use the source code to make their own debug version if they are trying to get something working for their mod. -- But if you do find a bug in the K-Mod dll, I'd be happy to fix it - even if it doesn't actually effect K-Mod itself..

It's OK. I understand completely. This is a forum for big kids and hand-holding should not be necessary. I just ran through a tutorial on how to set up the compiler and got your source files from Github. I'm planning on using K-Mod as a base for my little mod. There's only so much that I can do with Python/XML, so I'm taking the plunge back into C++. I just successfully compiled the source code a few minutes ago. I'm new to Civ4 coding, but have some experience coding for a Half-Life mod I made about three years ago. I should be able to get back into the swing of it. :)
 
One thing I haven't seen mentioned yet is that Ships of the Line currently get a bonus against frigates but not against privateers. So it's more efficient to take them down with privateers than with frigates, even though frigates are presumably supposed to represent more powerful ships than privateers given their higher base strength. I feel this should definitely be addressed; maybe with something like either 1) eliminating the bonus versus frigates and increasing base strength significantly, or 2) increasing it less significantly and giving at least some bonus against privateers.

And a belated thank you, karadoc, for your reply to my question about vassal power a while back. :)
 
Some random thoughts and gaming experience.
1) In one of my games I started near Inca and noticed that he had lots of quechas and very few archers (Emperor level). It was the reason he lost to my rather late axe-rush. May be it should be addressed somehow...
2) In a game I currently playing Huayna built Pyramids only to stay in monarchy until renaissance. I also often saw AI building TGL in their only coastal city and doing other stupid things of this kind with wonders. Do you plan to look into wonder-building code? Because now AI decision-making in this regard looks completely random and sometimes it really cripples it. I mean, TGL and Pyramids are very expensive wonders and you shouldn't build them if you are not going to leverage their advantages.
3) Game I'm now playing is extremely fun in general. It is marathon speep, huge map, 18 civs, hemispheres, 3 varied continents (my most preferred settings). Difficulty level is Emperor (my usual Immortla is too strong for me in this mod). On my continent I have a company from myself, playing as Hannibal, Inca, Liz, Wang Kong, Isabella and Justinian. Isabella founded buddhism (surprise, surprise!) and spread it to everyone. She built a shrine early and also built Spiral Minaret and University of Sancnore (missed AP, alas) and that gave her a monster economy. And all the others (except Justinian) are naturally good techers.
The result was eternal peace, absurdly low power numbers for everyone and the most cutthroat tech ratrace I ever had which left barbarians on other continents far behind.
Like all golden ages it ended in a world war. It was triggered, just as I foresaw, by Liz switching to free religion which made Justinian annoyed with her.
Regarding Justinian - I really feel sorry for him. He clearly didn't fit in our company and fall rather far behind in technology. He tried to compensate for his disadvantages by rushing Liz early in the game. For usual BTS Liz it would be lights out (I seldom saw her surviving after middle ages) but K-mod Liz fought him off. And then Justinian has become buddhist as everyone else and it locked him in perpetual peace (he actually can't DOW at pleased and has a very low prob. of going into conquest mode).
Of course, when Liz rejected the true faith, Justinian couldn't miss an opportunity. He attacked her with, I think, the most formidable army of pre-gunpowder age (cataphracts!).
It may be a coincedence, but Liz actually acted better than I would in her place. She had no army to speak of but she was far ahead of everyone else in GNP (and shared with me 1-2 places in Mfg. goods as well); she was researching chemistry when the war started. If I were her, I would panic and go for military science after chemistry, though grens don't really give an advantage against cataphracts.
She did the following:
1) Finished chemistry.
2) Finished building Taj Mahal.
3) Researched Printing Press very quickly.
4) Traded with someone for Replaceble Parts.
5) Researched Rifling at lightning speed.
She got Rifling one turn ahead of me, though I started researching it just about when the war began at 100% research AND during my own golden age!
(For some reason she didn't revolt to Nationhood, though she easily could. Any ideas, why?)
She also asked me to join the war and I agreed for reasons of my own. And soon after that Capac DOWed Isabella (I think he became distressed after she switched away from monarchy). Wang Kong joined this war, being Capac's vassal, so everyone on my continent is at war now.
Justinian is doing pretty well in his war. He took 3 English border cities and razed one core city. But this, I think, was his last heroic deed: Liz already fielding redcoats in quantities and I about to invade his land with the strongest army in the known world.
Fun game so far, thanks to improved K-mod AI!
 
Regarding SotL, I suggest a strength of 10 with a 20% bonus vs Frigates. This would make them more capable vs privateers and give them a better chance against Ironclads.

Also maybe give Frigates a free Sentry promotion? Frigates were the "eyes of the fleet" during the Age of Sail and this would reflect that. Frigates could then act as scouts.
 
I like the fact that in Kmod there are no completely reliable friends. But that's probably just my style of play. I'm less into the "roleplaying" aspects of the game, where you can give gifts to the AI to make it like you more. I'm more into a hardcore AI that plays to win - basically a computer that plays like a human adversary would.
 
One thing I should mention when playing the 2009 scenario is that when the AI decides to use nukes they will literally use all their ICBM's in one turn, even if it means nuking just one city.

The silly thing is the city that they pick on might be completely demolished after about 4 ICBM's but they will continue to nuke it anyway till they run out, leaving themselves at the mercy of any civ that has nukes and now having no way to retaliate.
I looked at the source code for this and was a bit shocked at how bad the AI was. It really is as you say; they will just use every ICBM they have on the first turn. (The original AI for tactical nukes was a bit better.) -- The trigger for them using their ICBMs was that they needed to be at war, and 'furious'. That's all. With those conditions met, the AI would just go berzerk.

Anyway... I've actually rewritten the system now. I think it'll be a lot better, but it will need some testing. The new system handles both ICBMs and tactical nukes; but in slightly different ways. The new AI for using ICBMs now has some minimum value threshold for using the nukes; and the evaluation includes a rough distinction between a "military target" and a "civilian target". In general the AI will aim mostly for military targets, but will start leaning towards civilian targets if they are losing the war, or if they strongly dislike the civ they are at war with, and so on. Currently, the AI will still always target cities with the ICBMs, but the particular target value of each city will depend on those weights; and the new AI allows the nukes to be targeted off-center from the city, so that they hit particular plots around the city rather than just whatever happens to be there.

Also, can we maybe rethink the cap on spies suppressing other spies? Like allow for multiple passive spies in cities (that you use for high risk targets)...it just gets mega annoying for enemy spies to continually blow up buildings in a city with barely any production, even with a counter espionage spy in it.

Maybe cap it at 2 or 3 counter espionage spies...or provide a negative chance at success for enemy spies in recently sabotaged cities...

I often get the feeling that my cities are just crawling with 100s of spies...lol. I usually get counter spies in most cities as well and manage my espionage advisor alot.
Well, I can assure you that you don't have 100s of enemy spies in your cities! :) The AI actually doesn't build heaps of spies. They are just very active about using them. They send them straight into a city, and then do a mission as soon as the discount hits 50%. (except under special circumstances.) -- I'm always open to suggestions about how the system should work; but to be honest, I think it's ok that it's possible to shut-down particular cities by repeatedly blowing up their buildings. It's quite costly keep blowing things up like that, particularly if there are counter-espionage missions, counter-spies, and security bureaus. In a sense it's just another kind of war. It's just another possible way to channel one's resources to defeat one's enemies. (The switch-civic thing is probably currently a bit too powerful; and I do intend to look into it again at some point [I already increased the cost of it a lot in a previous version, ages ago]. -- But I personally don't use that strategy much; and neither does the AI.. so I'm still kind of gathering data on what should be done.)

Regarding SotL, I suggest a strength of 10 with a 20% bonus vs Frigates. This would make them more capable vs privateers and give them a better chance against Ironclads.

Also maybe give Frigates a free Sentry promotion? Frigates were the "eyes of the fleet" during the Age of Sail and this would reflect that. Frigates could then act as scouts.
I was thinking the same thing about SotL. In fact, I was just about to implement it... and then I didn't. I'm having second thoughts about the whole thing.

The thing is, there are heaps of unit imbalances in the game - and originally I didn't really want it to be K-Mod's business to deal with all that stuff. I have already made some pretty significant balance changes -- but I'm just not really sure where I should draw the line. ... SotL is piece of junk in its current form, so I still think I should do something about it; but first I'm just going to pause and consider before making more changes. I have to put some kind of boundaries on the scope of the balance changes one can expect in K-mod.

Here are some further ideas for potential balance changes:
  • Siege units (cannons, catapults, etc) should suffer collateral damage. (I don't see any strong reason why they shouldn't.)
  • Late game siege units should have a lower unit-cap. (Partially to compensate the above change, and partially because they are already very strong just from their base-strength increase and their max-damage increase.)
  • Submarine units should get attack bonuses. (As I understand it, subs are actually pretty easy to destroy, but are extremely dangerous if they go undetected. For example, a sub should be able to sink a battle ship while attacking, but be defeated easily while defending.)
  • War elephants should cost more to build, perhaps 80:hammers:. (They're way stronger the other units of their time, but their cost is actually pretty low. War elephants are too powerful in the current balance of the game, and I think a cost increase is the best way to correct the imbalance.)
  • Grenadiers should – well, I'm not really sure, but I think they should be changed. Perhaps they should get +20% city attack, or something like that. As I understand it, their main role is for attacking enemy fortifications...

Anyway... What I'm really getting at is that if I just went ahead and changed everything that I disagreed with, then we might end up with quite a different game to the way things are now. I'm just not really sure which direction to take.. and so I'm inclined to just take things slow.

The next version of K-mod will only have the most minor SotL change - they can now be built with copper as well as with iron. (This just happens to be the change that I've been testing for most of the development of the new version.) -- And I'll consider other other potential changes later.

I welcome opinions and insight on these topics from everyone!

--

@Gavagay, about the AI's building of wonders -- the evaluation of the wonders is actually pretty good (believe it or not). The thing is, however, that there are also some cases where the AI will choose to build a wonder simply because it is a wonder; and in that case, it may end up building something unuseful. There are various reason why they do this.. but rather than go into all that, let me just say it's related to the AI's "WonderConstructRand" part of their personality, which was part of the base-game; and let me point out that lots of human players do this as well!


--
In desperate need of updates, status reports :D
I'm uploading the new version now.
 
I really like the idea for grenadier to get a city attack bonus, so that with the *potential* artillery nerf they will be a much better unit for conquering cities. I wouldnt mind seeing them get a free first strike or incoming bombard dmg reduction as well. I also agree that late game artillery units are incrediblely strong.

I wouldnt mind elephants getting maybe a 5 hammer increase, or maybe requiring a stables before being built, but I kinda liked the idea of a fairly rare resource providing a nice military bonus.

Submarine attack bonus sounds fun too.

NEW UPDATE! :D
 
Anyway... What I'm really getting at is that if I just went ahead and changed everything that I disagreed with, then we might end up with quite a different game to the way things are now. I'm just not really sure which direction to take.. and so I'm inclined to just take things slow.

Ill give u some of my thoughts about this, in a form of a question.
If you spend so much time perfecting AI and other important mechanics (culture, trade...) and neglect other things that are not as good as your changes so far, dont you think that you are making a crippled game? If you are teaching surgeon to be the master of his trade and u give him a rusty scalpel will he be able to do his job as intended?
The only line you should draw is how fast your updates are being produced and how much testing they require before you release them. So things are obviously broken in the game (like war elephants - so easy to conquer all if u have them) and no matter how well u do AI programing this things will still be broken.
You can always do one thing that would satisfy both parties (ones that desire better AI and others that desire better AI with balances) by uploading 2 versions - AI only and AI with balances. (if its not too much work)
 
Back
Top Bottom