K-Mod: Far Beyond the Sword

A little note : I saw Willem van Oranje defending a flatland city with two Guerilla 1 longbows, while there were two CG 1 longbowmen in his hill capital. He could have easily swapped those around.
 
Karadoc, by looking at the changelog your work seems amazing! One question: did you include the unofficial patch for BtS in your mod?

EDIT: Nevermind, I just went through all the pages of the thread!...
 
You did improve the AI, well done. Gandhi peacevassaled to Boudica in my game at 800 BC at Prince difficulty (I did follow your advice and put the difficulty level one down). I thought '800 BC feudalism at Prince? Impossible, surely karadoc has changed the requirements for vassaling.' A few turns later, when I got alphabet, I found out Boudica did have Feudalism and CG2 Guerilla 1 longbows...
It seems Gandhi immediately went for culture. That's an improvement, too. The AI still can't outpace me in REXing, though :p
EDIT: It was also nice to see how every (and litteraly every) AI dogpiled Willem van Oranje. A bit less nice is the fact that is my favourite leader. Oh well.
I beelined to Nationalism to draft Janissaries. Did you already implement such a feature to the AI, beelining to mass-draft?
I have tried to help the AI's REXing ability just a little bit... I've taught them to sometimes send their settlers to the destination without waiting for an escort (but only when they are pretty sure it's safe.) - But I'm not really sure if it has helped them much.

I haven't taught them a mass-drafting strategy, but I have tried to teach them when the best times to draft are... like for example, if a city is about to starve - it should draft. If the city has plenty of happiness and is working a poor tile, it should draft.

Now that you mention it, I should probably get them to be a bit more aggressive in their drafting when using the "crush" strategy, or something like that.

A little note : I saw Willem van Oranje defending a flatland city with two Guerilla 1 longbows, while there were two CG 1 longbowmen in his hill capital. He could have easily swapped those around.
That's hard to fix completely, but I'll try to make it a bit better. There are already some checks and conditions to help the AI get the best defenders for its cities, but there isn't really anything to reliably let them swap defenders from one city with another - especially when both cities only have a skeleton defence. But I do have an idea for improving it just a little bit...

Karadoc, by looking at the changelog your work seems amazing! One question: did you include the unofficial patch for BtS in your mod?
Thanks. :) I hope it still seems amazing after you play it! (and yes, it does have the unofficial patch integrated, as well as many other bug fixes.)


For the next version, I've made a few improvements to the AI's military tactics. I discovered that there are a bunch of flaws in how the AI moves towards cities they want to attack, and once I know those flaws I can't help myself but to exploit them to make the AI do stupid things... So, in v1.04 the flaws I'm talking about will be fixed - hopefully.

Also, I've finally added a event message for when a religion is removed from a city. It doesn't happen very often, and in the past, when it did happen you probably wouldn't notice anyway! :crazyeye: So in v1.04, the game will tell you when it happens.

.. and there will be a couple of bug fixes and other AI improvements.


Let me know if you have any feedback about the new religion spreading stuff (or feedback about anything else). It's hard for me to tell if it's good or not without playing a bazillion games.
 
I've noticed the AI being a little better at REX, yeah. The settler-escort-meet-up thing was something I actually saw happen in a recent game. Pretty cool. I'm glad you're still finding the AI's military flaws and working on them.

More commentary to come when I have time--playing another game with my S.O. at the moment--but I'm liking the changes. :)

p.s. #1: Karadoc, do you know anything about Favorite Religions? I thought I remembered playing at least one mod in which the Civilopedia listed a "Favorite Religion" for each of the leaders. I'm not sure how this affected their willingness or unwillingness to encourage the spread of a particular religion in their country (or to adopt said religion as a state religion), but it's something to think about for your own mod, in regard to the goal of giving the later religions a fighting chance. But, for example, Isabella's favorite religion was Christianity (as it so was for several of the other Age of Exploration/Renaissance European leaders). I think Gandhi's was Hinduism. Saladin's was Islam. (Musa's would be as well, I figure.) Implementing some sort of personality mechanics about that could potentially help give Christianity and Islam a fighting chance later in the game.

Of course, that runs into the problem of some religions being hard to place: Judaism has no associated leaders in the standard game (that I can recall off the top of my head). Confucianism and Taoism are also kind of doomed, from an historical perspective, since (as well as my 5 minutes of research can tell me) neither Qin Shi Huang nor Mao Zedong were fond of either of them historically.

Which is funny since Confucianism is frequently one of the big players in a game of Civ4 anyway, due to being a common result of slingshotting CoL with the Oracle.

I dunno. Would some sort of religious personality predisposition system potentially help flavor up the game and address some of the subtle problems with midgame religions being doomed to obscurity? Maybe as a toggle-able option at the game creation screen?
 
Thanks. :) I hope it still seems amazing after you play it! (and yes, it does have the unofficial patch integrated, as well as many other bug fixes.)
I would love to play your mod! However, I do have a problem: I love my personal mod so much that I would try to do this another way:crazyeye:.

First, I have no programming skills, neither in Python nor in C++. But I'm a good copier/paster! I made quite many changes to the XML, adding Religions, Buildings, Units.

I can compile a dll and so far my changes to it are just a few. I started with Aforess' Advanced Diplomacy at a time when I could not modify the dll yet. Since 1 month, I just added Dom Pedro II's Units Obsolete with Techs (a bit like for buildings - very important for me) and two or three minor adjustments.

So I was wondering if you think that it is feasible that I would play my mod with your dll.

I see this in 3 phases: start with you dll files (and not the contrary since you worked so much on them already) and try to insert Aforess', Dom Pedro II's and my own small adjustments in them.

In a second phase, look at the Python files (here again I borrowed some codes from Civ Fanatics) and see what I would need to do (so far I don't have BUG/BULL and that might be a big problem).

Third: check the XML if I have to change things, add new tags, etc. Of course, I might have to deal with this issue earlier, right after the dll changes.

So, do you think that it is feasible? What could be the major obstacles?

I'd greatly appreciate your views on this. I also sincerely hope that you would not feel offended by this. Your work would be the base of my personal mod. You see, I particularly like in it the additions of the religions (mainly thanks to Just Another Religion Mod created by JustATourist and Refar). And of course the way you intend to change to spread religions interests me a lot because I have some problems with the vanilla way too.

Thank you in advance.
 
There is some xml and a little bit of dll code that relates favourite religions; and I think you're right that enabling it would probably help some of the later religions. (after all, regardless of the religion changes I've made so far, the AI are still much more likely to prefer the first religion they found)

But I'm not sure if it's a good idea to enable it. One problem is that more often than not, the AI probably won't even have access to their favourite religion - because it will be founded by someone else. Also, for some leaders it seems very unnatural for them to have a favourite religion - for example, leaders whose favourite civic is Free Religion. It could also sometimes be annoying for gameplay... if you want to spread your religion around, you basically have to choose the favourite religion of your neighbours, otherwise your spreading of religion will be in vain.

.. anyway. I don't intend to enable that feature for the time being, because of those sort of problems.


@isenchine
Regarding merging mods. It is feasible, but I can't really say how difficult it would be. The main problem will be there places where we've both changed stuff but in different ways. This could be particularly difficult if you aren't comfortable messing with the programming code. I'm not sure what changes those mod you mentioned make to the C++ code. If they change stuff that I haven't touched, then it should be fine to just do a drop-in replacement of the original code. But if they change one of the functions that I've mangled (of which there are many) then it might be hard to know where stuff is meant to go.

Starting with the K-Mod dll is essentially the only option, because there are about a bazillion dll changes. It would be mad to try to copy them one by one. The K-Mod python isn't nearly so important. I suspect the mod would work well enough if you just put in a completely different set of python files. The main thing you'd probably want to grab from the K-Mod python is EconomicsAdvisor.py - which has the environmental advisor screen. As for the xml changes... they should be easy enough to merge, but perhaps a bit tedious if we've changed the same files. (winmerge is useful for that kind of stuff)

So yeah... I'm not really sure how difficult it will be. With a bit of luck, it might even be easy. So.. goodluck!

(btw. I'm not at all offended. I've tried to make K-Mod be the game that I would want to play; but I acknowledge that it isn't necessarily the same as what other people would want. I'm sharing the mod and the code etc not because I think everyone should play it my way, but just because its easy to share and I think others could get a lot of enjoyment from the work I've put into this.)
Spoiler :
-- the only bad part about sharing is that I have to write a changelog. That's my least favourite part. :sleep: I'd prefer to just mention a few of the key features and tell people to read the git commit log for more details... but I know that it's much better for everyone (except me) if there is a more readable changelog.
 
I'm not sure how Favorite Religions work (mechanically speaking) in the other mods that use them, but my thinking was that it _might_ be a good implementation here if (and probably only if) you could find some way to get the AI leaders to not be idiotic about it.

By that, I mean making it so that if you totally fill a leader's empire up with Buddhism, but the Leader happens to have Christianity as a favorite religion, and that leader happens to get 1 or 2 cities with Christianity in it, the leader doesn't suddenly do a turnabout and switch to Christianity immediately (and start aggressively spreading it). But if there were a more gentle formula ... say, if they would favor that religion at a lower (but not super low) threshold compared to others, that wouldn't be too bad, I wouldn't think. It would need to be paired with other changes though.

Also, I figured some leaders would prefer "no state religion" as their "favorite" religion (e.g. WVO) and would be (for the first time ever) a hard sell on getting them to adopt a state religion in the first place. Currently, AI leaders will adopt their initial state religion seemingly without regard to diplomatic repercussions at all. I think it would be interesting to see the AI in general (and especially some leader personalities) be more skeptical and cautious than others, while others are a little more easily swayed (but carry other dangers in dealing with them).

I do conclude, though, that the bigger solution doesn't lie in changing the AI's mentality so much as in tinkering with how religion works in general. I just figure that tweaking with the AI's mentality (especially on a leader by leader basis) could be a way to add a bit more flavor to the religious diplomacy aspect of the game. Currently, religious concerns regarding diplomacy can hardly help devolving into an incredibly childish form of Machiavellianism from the very beginning--"I'd better adopt Buddhism so Montezuma will like me, and then we can team up and destroy that Hindu tech spammer Mansa Musa so that he won't cause us problems thousands of years from now!!"--and that is a decent start, but it doesn't feel quite as robust as it ought to be.

My hope is that your changes will end up helping that quite a bit once the right balance and types of changes are found. :)

Still playing 1.3 :) and still loving it. If I think of more commentary to give in the near future, I'll write it up.
 
@Karadoc: thank you very much for your detailed answer. I will give it a try next week.

@Lenowill: I can only second your views on favorite religions. But what I particularly don't like in the game is rather the way religion is spread effortlessly and so quickly, without missionaries and even without open borders agreement. And just one religion in one city will make an instant conversion if it's the first religion to spread in a country.
 
Yeah, the whole thing where the AI will instantly convert to whatever religion they first happen to receive (even if it's in a city that's nowhere near the happiness limit, and even if converting will put them diplomatically at odds with all of their neighbors, and even if the Anarchy is sooooooo not worth it) is one of the worst aspects of the Civ4 religion system imo. At best it's an unrealistic suspension-of-disbelief breaker, and at worst it's an exploit that the player can use to play civilizations against each other -- but only if the player doesn't get unlucky and have another, different religion randomly spread to the nation in question first. x.x
 
I agree that the AI shouldn't immediately switch to the first religion that enters their land. But I haven't gotten around to changing that yet...

In any case. I think it's time for me to upload a new version. I haven't properly finished testing it - in particular, the new air-strike AI is very untested - but the rest of the changes are too good to keep on the shelf. :)

The main change that I'm happy about is just a small interface change that most people probably won't care much about: in the diplomacy screen, if you click "Lets stop this fighting..." it now brings up the trade screen with the AI's suggested terms for peace, ready for you to agree to. In my view, this is a major major improvement. I would have changed it ages ago but I didn't know how. (most of the diplomacy stuff is not handled by the dll). Originally, clicking that button just immediately made peace with no other peace trades. It was a button that needed to be avoided... because if you pressed it you would miss out on free techs, gold, or cities that the AI would have been willing to give to you. It was a trap; and an annoyance; and now it is fixed. Now it is actually a useful button, because it brings up the trade terms that you'd always want to see before making peace.

... anyway. That's just a small change, but I'm pretty happy about it. So I'm going to write the changelog and upload the new version.

[edit]
The new version is up. Let me know if there are any problems with it.

[edit again]
Regarding that "favorite religion" feature that I was saying I didn't intend to enable... Embarrassingly, I just noticed that it is active already - and has always been active. A bunch of leaders have a favourite religion, and they take that into account in their choice of state religion. But the effects aren't really noticeable because they are dwarfed by some other factors. (The favourite religion of each leader is set in CIV4LeaderHeadInfos.xml.)
I'm currently in the process of rewriting AI_religionValue, which is used for deciding which religion to switch to.
 
Ok... new version again. v1.04b.
I found a crash bug in the new air unit AI. (triggered when AI bombers try to work out the value of bombing an unowned resource.) -- I figured I'd better upload a version that doesn't crash; and since I've already uploading a new version, I might as well include the new religion AI that I'd just written... More untested than ever - exempt that I'm pretty sure it doesn't crash!

But seriously, although this new religion thing is very much still a work in progress I think it is already going to be better than the original system. So since you guys were saying you wanted improvements in that area of the AI... well tell me what you think of this new version. (if you can notice any difference.)
 
Will do. :) Downloading now, will likely play within the next couple of days.
 
I've just discovered yet another bug... :(. The bug is that sometimes defenders will get bumped off their tile instead of defending. Based on my understanding of what causes the bug, it's mostly likely to happen on the turn the AI declares war - but in some rare cases it can happen mid-war as well.

I guess v1.04 really just wasn't ready for release... expect v1.04c soon. -- :thumbsdown: depressing. On the bright side, I guess it's good that I'm finding and fixing the bugs rather than them going unnoticed / unfixed.
 
No worries, I'm glad you're finding them. :) Sometimes I don't notice when subtle things like that happen (and I'm not much of a warmonger to begin with). That seems like a really weird bug.

I played around with the mod some today and haven't had any problems myself, so I'll probably keep playing that save to its conclusion while I await 1.04c. :)
 
Yeah. It's a weird bug. Basically what's happening is this:
Whenever a unit moves to another tile, some a game-mechanics things have to happen.
- the game checks whether moving to the tile would cause a fight, and if so it does the fight.
- the units position is changed so that it is at the new tile
- the game checks whether all the units on the tile are allowed to be there, and if they aren't it moves them.

However... for some (misguided) reason, the original developers decided to integrate the AI into the game mechanics. ie. In many parts of the game mechanics, which govern the rules of what happens in the game, there is some AI stuff. This is a problem because it basically means that changing the AI can change the rules of the game - which is what has happened here when I changed the AI.

In this particular case the problem is in how the AI chooses when to declare war. As human players, we have to declare war before we can move our units into the enemy. But the AI doesn't do that. It decides when to declare mid-way through the move action itself, inside the game mechanics. So in the case of the bug, here's what happened:
- The AI wants to move its stack towards an enemy city to attack. So it issues the move command.
- The game checks whether moving would cause combat - it decides that it would not, because the AI hasn't declared war yet.
- The game then checks to see if the AI is intending to declare war... the answer is yes, and so the AI declares war.
- The units positions are changed so they are at the new tile
- The game checks whether all the units on the tile are allowed to be there... if find that there are units on the tile from different teams who are at war - and so it moves the units from one the teams to some other tile.

The root of the problem is that the AI declares war mid-way through the move mechanics. The check to see whether combat needs to happen is done before war is declared.

Anyway... so although it's my changes that caused this bug to happen, I pretty much blame the original developers - because in my view it is a mistake to put anything AI related inside the game mechanics. The AI should decide whether or not to declare war before issuing the move command, not mid-way through the mechanics of move. These kinds of pitfalls are peppered all through the game because of the design mistake.
 
The more I learn about modding Civ4, the more I feel like the developers kludged and cobbled together the game's systems. :/ It's a wonder (ha ha) that the vanilla game plays as well as it does in the first place.

So are you going to have to somehow completely redo the way movement occurs in the game in order to fix this properly? That sucks if so, but gah! Developers!! xD

Maybe if you fixed the way movement worked it would finally be easier for other modders to do nifty things like make the square grid emulate hexes without making the engine explode (something PieceOfMind was trying to do once upon a time), and Zone of Control type stuff. (Is there a Zone of Control type mod for Civ4's warfare anywhere yet? I need to search around for that.)

Good luck with it in any case!
 
Actually, yes. This game is loaded with things like this.

But at least it's not Civ V. At least we CAN mod, unlike those poor people over at the civ V forums who currently lack an SDK.
 
Yeah, I bought Civ5 eagerly the week it came out. I was disappointed that I could win my entire continent using nothing but 3 or 4 Horsemen units. I also disliked the art style, the interface, and the dumbing down of various systems. And I didn't like the annoying interaction between unit movement, roads that cost gold per turn in maintenance, and the 1UPT military system. And I didn't like how most of the buildings were useless red herrings: not worth their opportunity-cost in hammers and not worth maintaining in the first place due to upkeep.

I waited for months for patches to go by, then tried it again recently while messing around in Steam. I am still disappointed and pretty much would like to see the essential "good stuff" from Civ5 modded into Civ4, but keep Civ4's overall system. (That includes, in my mind, things like ranged bombardment, non-decisive combat even between units without withdrawal chances, and so on, and a reasonable limitation on how many units can be in a single tile.)

I'm especially interested in Karadoc's modding because he's one of the few modders I've found who are competent enough and persistent enough to fix Civ4 code bugs the right way: by going back and rewriting whole systems of the code, and dealing with the consequences as they arise ... rather than trying to put a bandaid on kludge.

There's a lot of weaknesses in Civ4 that I am glad people like Karadoc are trying to address.

For instance, Civ4 needs to run faster--a LOT faster. For the late game to be fun for me and my significant other (and for some of our friends) on any map size above standard. And the AI needs to be smart enough that they can give us a decent run for our money without needing to start with Archery, a free worker, and a ton of other advantages.

The combat system also needs to be better. A lot better. The weakest system in Civ4 has always been the combat. In no other game do siege units go in first as cannon fodder, usually die, and then allow the grunt troops to go in afterward and clean up what's left over--resulting in the grunt troops coming out with next to no casualties. Meanwhile, archers are borderline useless for any purpose except defense and siege units are only useful on defense if they suicide-attack the invading enemy stack to weaken it. What kind of backwards madness is this!? Also, the idea of "cannon fodder" barely even applies in Civ4's combat system because Cannon are so terrible at defending. Unless you suicide them by running them at your foes, which was NEVER THE ROLE OF CANNON in history! D: Seriously, what part of "you protect your artillery and let them rain down big boom-boom for you" did this game's developers not understand?

And then there's the whole unit healing system (which is broken and unrealistic to stupid degrees, and is no better in Civ5). Promoting a unit with a promotion I saved since it came out of the barracks should not instantly restore ~half of its fighting strength, and I shouldn't be able to magically reinforce my units to full in enemy territory in little to no time just because my army includes a General who is also a doctor and a guy who spent too much time in the forest learning about herbs. x.x Unit healing should take a lot longer and should be essentially impossible if you don't have an open line of transport to your home country. (Making suicide attacks with a few Cannon against an invading army might be a lot more meaningful if the above stuff were true.)

The above truths about the combat system are also a big part of why Walls and Castles are widely regarded as joke buildings by serious players. I really don't like that the game's like that, because it isn't realistic in the slightest (Walled cities were greatly feared in antiquity, and Castles were so costly to dislodge that commanders would starve the defenders out instead--something which can only halfway-sorta-kinda-but-not-really be done in Civ4).

Dale made a lot of progress toward improving all of that with his Dale's Combat Mod, but I've yet to find a version of that wonderfully ambitious mod that isn't horrifyingly buggy (in at least some of its modes) and gets used properly by the AI. Sooooo ....

Even if Karadoc doesn't end up wanting to make a combat mod someday (and I might beg him to, because the rest of what he's changed has worked out so well), this modding of the base game system looks like a good baseline off of which someone else could hopefully build.

But yeah. Karadoc has basically made it possible for me to play Prince difficulty and have fun again (I normally play at Emperor in regular BTS), and I respect that (and his diligence) a lot.
 
v1.04c is up. I'm pretty sure the defender-bumping thing is completely fixed.

The more I learn about modding Civ4, the more I feel like the developers kludged and cobbled together the game's systems. :/ It's a wonder (ha ha) that the vanilla game plays as well as it does in the first place.
I agree!

So are you going to have to somehow completely redo the way movement occurs in the game in order to fix this properly? That sucks if so, but gah! Developers!! xD
I'm not going to completely redo it, but I'm trying to go one step better than just a band-aid fix. I've fixed the problem in two ways: firstly, inside the movement function, I've moved the declare war check to be before the should-we-fight check. That's the band-aid fix. But in addition to that I've put some declare-war code into the AI itself, so that it should declare war before issuing the move command. My intention is to phase out the move-internal declare war stuff. For the debug version of the mod, I've made it so that I get an error message every time the AI tries to declare war inside the move function. Sometime in the future, when I'm satisfied that it doesn't need the internal stuff anymore, I'll just remove it completely.

Yeah, I bought Civ5 eagerly the week it came out. I was disappointed that I could win my entire continent using nothing but 3 or 4 Horsemen units. I also disliked the art style, the interface, and the dumbing down of various systems. And I didn't like the annoying interaction between unit movement, roads that cost gold per turn in maintenance, and the 1UPT military system. And I didn't like how most of the buildings were useless red herrings: not worth their opportunity-cost in hammers and not worth maintaining in the first place due to upkeep.
I agree with that stuff. And in particular, I think the 1UPT is a big mistake for a Civ game - (for many reasons that I don't want to go into right now). I think Civ4 is actually on a stronger foundation than 5. So even if the Civ5 SDK was available, I'd still be modding civ4.

...The combat system also needs to be better. A lot better. The weakest system in Civ4 has always been the combat. In no other game do siege units go in first as cannon fodder, usually die, and then allow the grunt troops to go in afterward and clean up what's left over--resulting in the grunt troops coming out with next to no casualties. Meanwhile, archers are borderline useless for any purpose except defense and siege units are only useful on defense if they suicide-attack the invading enemy stack to weaken it. What kind of backwards madness is this!?
I agree. It's stupid. It's mad. It's backwards... but currently it isn't something that I intend to change. (sorry) The reason I don't intend to change it is that I think the suicide-siege thing is pretty ingrained in how Civ4 is played - and this mod is not meant to change how the game is played, it's just meant to improve it. I think the gameplay and balance of the suicide-siege mechanics is ok, so from that point of view I'm not inclined to dramatically change it. .. and similarly for the other combat problems you've described. It's possible that I will decide to change that stuff one day, but I don't intend to at the moment. (Originally all I intended to do in this mod was improve serfdom - and nothing more - so the scope of the mod has certainly grown...)

Thanks for the kind words.
 
*nods* You're welcome.

I figured you wouldn't want to attempt a rework of the combat system for K-Mod purposes. When I mentioned that, I meant it more as a different project (for waaaaay down the road) that could perhaps be merged with K-Mod or use it as a base..

But it's true, the balance of Civ4's combat is heavily tied up in suicide-siege and melee-range archers (and gun units). Everything from the siege units' base strength numbers to the size of collateral damage and the overall flow of combat is affected by it. To truly make it sane, you'd need to not only rework the combat mechanics to include ranged bombardment and other stuff (and teach the AI to be very good at using it), you'd also need to completely redo a lot of the Promotions system (for instance, to give players more countermeasures against ranged bombardment), change the combat strengths and special abilities of numerous units in the game, add whole new units (e.g., perhaps some snipers in the modern era to replace the ranged archer volleying of antiquity), implement stack-versus-stack combat that actually made sense and wasn't buggy, and so on. Leader traits might even need looking at as a result. Doing it right would be a huge undertaking and would completely change the face of how war (and, probably, military-infrastructure-building) works in the game. So while I eagerly hope this will be possible one day, I can also understand why it hasn't properly happened yet and why you don't want to undertake that at this time.

I'll give the new version a try shortly. :)
 
Top Bottom