K-Mod: Far Beyond the Sword

I see now. They weren't actually trying to reinforce anything. They were just confused, and they are walking around more or less at random...

It's caused by some inconsistent logic from the BBAI mod. The stack is not "ready to attack", because it doesn't have any units that can actually capture cities; but the stack is big enough to count as a full attack stack - so it doesn't want to move back to a staging area. The result is that the group basically just wanders around aimlessly, hoping that another stack will come to merge with it. It's a silly mistake from the old AI that I hadn't noticed before. The stack really should just go back to their home land to group with the new units being built.

Thanks for pointing it out, I'll fix it for the next version.
 
:D no thank you Karadoc!

On a more positive note, I think I might win this game...provided I dont get globally declared war on.

I made a massive number of pikemen with triple city attack bonus, then spent 12-14 turns saving money to upgrade them to redcoats, so when the Japanese declared war I let them have a city and then destroyed their 3 main stacks inside of cities. And then they vassaled to me :D
 
Hi Karadoc. Did you consider or try OpenMP for paralelizing loops in your mod? I tried it with some modded bts code, but could not improve performance which I think is because I did not know which loops to optimize. That dreadful "idling" you mentioned in the other thread was also in code. Anyway if you could give some clues where the slowest parts are I could give it another shot.
 
I have considered trying to parallelize some of the code, but I haven't attempted it. The thing is, most of the code is written in such a way that it needs to be run sequentially. For example, most of the CPU time between turns is spent on AI decisions for individual units. The AI units can't decide on their individual move at the same time, because the choices of one unit may depend on the outcomes of the another unit's actions. Also, the decision making process for individual units currently goes along the lines of if I can do X, then do that; otherwise, if I can do Y, then do that; otherwise ... and so on.

There are many individual loops which could be sped up with multiple threads, but generally they are low cost loops anyway. I suspect that to get significant gains, a lot of loops in a lot of places would need to be changed.

Anyway, if you want to get an idea of where all the time goes, here is a copy of the profiling data that I was looking at today. That's the data from a single turn, on a big map with lots of players and units etc. the turn took around 9 seconds.

(I was testing to make sure that my new code for evaluating maintenance changes in civics was not going to be too slow. The old code used an awful approximation which was nowhere near the true value.. the new code is precisely the true value... and it took less than 1 millisecond of that 9 second turn, so I think it's ok for general use. :) )
 
I have considered trying to parallelize some of the code, but I haven't attempted it. The thing is, most of the code is written in such a way that it needs to be run sequentially. For example, most of the CPU time between turns is spent on AI decisions for individual units. The AI units can't decide on their individual move at the same time, because the choices of one unit may depend on the outcomes of the another unit's actions. Also, the decision making process for individual units currently goes along the lines of if I can do X, then do that; otherwise, if I can do Y, then do that; otherwise ... and so on.

There are many individual loops which could be sped up with multiple threads, but generally they are low cost loops anyway. I suspect that to get significant gains, a lot of loops in a lot of places would need to be changed.

Anyway, if you want to get an idea of where all the time goes, here is a copy of the profiling data that I was looking at today. That's the data from a single turn, on a big map with lots of players and units etc. the turn took around 9 seconds.

(I was testing to make sure that my new code for evaluating maintenance changes in civics was not going to be too slow. The old code used an awful approximation which was nowhere near the true value.. the new code is precisely the true value... and it took less than 1 millisecond of that 9 second turn, so I think it's ok for general use. :) )

Looks like time is almost evenly spread among 3 functions CvPlayerAI::AI_unitUpdate , CvPlayer::doTurn and CvSelectionGroupAI::AI_update each taking about 3s. This does give some idea and it is not really promising. Before I tried to play with doTurn function, but now i see it is only 30%... Optimizing small loops might produce more overhead in creating threads then performance gains plus these dependencies make it risky to introduce some really bad bugs. I will check out those ai update functions. Thanks for the info.
 
I've uploaded v1.22. It might not look like it, but there are actually a lot of back-end changes in this version. I tested it quite a bit, but I wouldn't be surprised if I created a couple of bugs by messing something up. So please let me know if something goes wrong.

As usual, it's mostly a bunch of AI changes; but there are some interface changes in there as well. In particular, I've completely rewritten the mouse-over text for pretty much everything related to resources. I think the new text makes things a whole lot clearer. It should be more obvious that forts connect resources (although it still isn't specified explicitly, the resources will no longer say "requires [improvement x]" when they have a fort on them.); it should be more obvious that resources do not give +yield to your civilization, but only on the plot that the resource appears on; and... well.. other stuff should be clearer to. I hope everyone agrees that the new format looks better, and conveys the information more clearly!

I've also changed the symmetry breaking mechanism in the pathfinder again. I think it should be better than ever. :) I dont' know of any examples which cause the symmetry breaker to fail now. (For those who don't know, or have forgotten, the pathfinder symmetry breaker is something that I created to fix the problem of the user-interface displaying a different path to the path that the unit will actually take. You've probably experienced times when you use the go to command to move a unit, and it doesn't move where it said it was going to move... that's the problem I'm trying to fix.)

By the way, the build route to command still doesn't work correctly. That's actually caused by a separate bug that I haven't gotten around to fixing yet. The symmetry breaking stuff I'm talking about only fixes the go to command.
 
Those change notes for 1.22 are so friggin awesome. (I saw my observation about those 50 cannons roaming around has been fixed already). Is it lame to feel a little proud about that? :D

+1 Karadoc
 
Ran into problem with the version before 1.22.

Im actually running into alot of situations where "show enemy moves" isnt working quite right, I just lost 2 cities and never saw the enemy enter my territory. I dont know if anyone else is noticing this as well?

I do have "show enemy moves" selected. And Im in the ww2 era.
 
Fixed many (minor) bugs caused by inconsistencies in how the original code checked whether or not a plot improvement gives access to a resource.

Does this mean that if i have, say a coastal city and there is an island (single plot) with a resource on it and improvement build (with or without road on it) i will have access to it?
 
Does this mean that if i have, say a coastal city and there is an island (single plot) with a resource on it and improvement build (with or without road on it) i will have access to it?
I don't think so, no. I basically took the assumption that all of the game mechanics were 'working as intended', and so the only things affected by that set of bug-fixes are the UI and the AI.

For resources to cross the ocean, they need access to a sea port, which can either be a city or a fort on the coast. That rule has not been changed. (At least not deliberately!)


@Charles555nc, if you have a save which demonstrates the problem you described, post it up. I can't think of any changes I've made which made have affected that, but I don't really know much about it, because I never play with show enemy moves turned on. (I find that show enemy moves takes too long, but I have quick combat (defence) turned off, so that I can see what the AI is doing.)
 
Ill have to think to pick a save where I dont see the enemy entering my territory. I do the same thing with quick combat defense turned off so if I miss something I can at least see how it happened.

Maybe its because there are two infantry guarding resources near the our common border...would that negate showing me an army coming into my territory?
 
Maybe its because there are two infantry guarding resources near the our common border...would that negate showing me an army coming into my territory?
I really don't know. If you like, you could test it by setting up a situation with the world-builder; and you could test it without K-Mod as well to see if it works the same way.


...
I really look forward to K-Mod one day becoming a modding base that other experienced modders use to merge really good AI with really fun gameplay alterations.
Well, this is possible already, and I think there are already a couple of other mods that use K-Mod as a base. (People have mentioned them to me, but I haven't been following their progress.)

What I'd like to see is for K-Mod to become a defacto standard mod. The kind of mod that gets suggested to new people when they ask what to do to get started with the game. (Like in this thread.) Currently, whenever that question comes up, everyone suggests the BUG mod; and sometimes people suggest the Better AI mod. -- But K-Mod has far better AI than the Better AI mod, and in many ways it even has a better interface than the BUG mod. (If BULL is included with BUG, then K-Mod has some missing features, but K-Mod still has the advantage of things like pathfinding bugfixes; group paradrops; smarter automated cities and workers; more consistent mouse-over text; and so on.) So in my view, K-Mod should be the #1 mod that people play if they just want to refine the BtS experience. ... or maybe I'm wrong. Maybe the things I think are compelling features that everyone will like are actually – not. I don't know.

Actually, it doesn't really bother me how popular the mod is; but I do believe that more people would like it if they tried it.
 
My vassal is amassing a large tank army, has the largest gnp, is racing towards a cultural and possibly space race victory. Yet for the last 10 turns or so, he hasnt helped the war effort or done much of anything, even vs the weak French. While the super powers fight it out...seems very crafty.

Carthage, America, Greece, and Napolean have stretched me very thin. Im trying to stay with free speech for the econ, but I may have to go Nationalism for drafting. Ive been slaving industrial buildings to try and catch up in production (was behind in tech).

Greece seems to be keeping up with my military despite me winning 2 or 3 pitched battles in the south and being twice as large as him. In the north I pushed too soon and my army is maybe trapped on the hills inside enemy territory, surrounded by evil tanks. :(

1. Im not complaining but does the japan ai really realize they could win by just sitting tight? I wouldnt change it if thats the case, would just like to know the real reason why they spontaneousy stopped helping.

2. The greeks have a massive advantage in espionage, and are destroying factories left and right. Do defensive spies stack in their catching of offensive spies. In other words if I get 2 spies in my own city, do i have a better chance at preventing enemy spies. I got Democracy really late (I needed security bureaus awhile ago).

3. Btw theres also a destroyer "trapped" on a desert fort (maybe thats already fixed in the latest version).
 

Attachments

I fight Greece to a stand still, every turn they burn a factory or stock exchange with spies, Japan surges forward in mega GNP (5000), building a super tank army but not using it, as my vassal. I offer peace to Greece and they give me Sparta (a holy city worth 98 gold per turn from religious gold), has 2 wonders, is in the middle of their territory, with several super specialists inside...

Here are the saves, maybe the AI should offer me a less valuable city to make peace, or only offer a city when one of their cities is in actual danger. I wouldve accepted just their gold and no city from just my own attitude towards my position. Constant spies burning down buildings really set me back.
 

Attachments

I know atleast 1 popular mod is switching its AI to K-Mod from BBAI (forgot which one). Releasing a K-Mod Minor Modcomp that is purely unaltered game play fixs like the paratroop, modifer keys fix (Alt, CTRL, Shift), and pathing, point that out on BULL+BUG so it hopefully gets included in BULL as with the credit there people will look at K-Mod Minor, see the Full K-Mod and likely give it a try. More people playing it and rating it, more it becomes the 'standard'. Overall thou there is less Modding done now then when BBAI was made, so less mods are going to use K-Mod as a base I feel.
 
I know atleast 1 popular mod is switching its AI to K-Mod from BBAI (forgot which one). Releasing a K-Mod Minor Modcomp that is purely unaltered game play fixs like the paratroop, modifer keys fix (Alt, CTRL, Shift), and pathing, point that out on BULL+BUG so it hopefully gets included in BULL as with the credit there people will look at K-Mod Minor, see the Full K-Mod and likely give it a try. More people playing it and rating it, more it becomes the 'standard'. Overall thou there is less Modding done now then when BBAI was made, so less mods are going to use K-Mod as a base I feel.

Dawn Of The OverLords.

And we of RI would like to have the K-Mod AI.
 
Rhye's and Fall of Europe (and AFAIK some other main RFC mods too, like Dawn of Man) also includes parts of your K-Mod
Thanks for putting so much effort in this, it has some amazing improvements! :goodjob:
 
Karadok, you need to get a separate forum section! All buzzing mods have it. It is really easy to NOT notice this thread. If it was a forum section in Civ4 - Project & Mod Development it would make it more popular for sure. Also I would advertise a little more aggressively on the first page that you mod has started from BBAI and BUG and progressed quite far with some explanations what it does better (like you just did). imo.
 
Back
Top Bottom