K-Mod: Far Beyond the Sword

Hi Karadoc,

I have not been able to duplicate the case with too many workers, however I found a save from when I first noticed the problem. The log shows lots of worker builds.

Hope it's of some help.
 

Attachments

I'm still intend to do some testing on the next version before I upload it. (Because I've made some back-end changes which I'm not certainly won't break the game.) But I just want post a quick note about a new option that I just finished implementing last night.

In the previous updates, I made the AI players faster... well in the next update I'm going to make the human players faster!
Spoiler :

attachment.php

I've been testing this new option, and I'm pretty happy with it. I think that once people have tried this, for people who like to play fast there will be no turning back.

--


@Charles555nc,
I agree that the naval invasions are still pretty weak. Sometimes they can pull it off, but usually they either don't land enough forces, or they have their boats destroyed en route. I don't have any big idea to improve it at the moment, but I am making small changes that I think well help them a little bit.

Regarding having an AI teammate. I rarely play in team games but I do intend to make some improvements there. In a recent update, I changed the AI so that they can still make resource trades when they are allied with a human player. (previously, AI's would refuse to talk with anyone if they were allied with a human.)

Some time in the future, I intend to add a diplomacy option so that you can tell your AI teammates and vassal to start preparing for war. I'm not sure how much this will help them, but I think it's probably worth doing.

As for the AI being slow and disorganised in their war efforts... well that's definitely something that I'd like to improve, but like the naval stuff I don't have any concrete plans at the moment. Most of my AI changes so far have been about improving their economy, because economic management is less situational compared to military tactics.

@Axios, I agree that the strategy you described in your post can sometimes be extremely effective - and the AI currently does not handle it well. I haven't made any changes for that yet, but now that you mention it, I can think of a few ideas for how to improve it. So I'll try to do that. (but I can't promise it will be soon.)
 

Attachments

  • Civ4ScreenShot0019.JPG
    Civ4ScreenShot0019.JPG
    188.1 KB · Views: 573
Are there any known side effects of the AI speed fix yet? I'm holding off on including the speed fix in my mod until I'm confident there are no side effects (of considerable pain to to the player).
 
Personally, and this is a personal choice of someone who plays at the emperor level with k mod :D, I'd like to see the ai get like 10% less research bonus, and like a 10-15% non wonder production bonus, even a higher amount of units in its city garrisons (it seems to keep 4 or 5 units max in a city not directly next to someone they were at war with , 7 or 8 units total would be better imo) . Even with #1 gnp i lose massively in research while the ai loses to military forces more often then being out researched-especially after nationalism- drafting.

I am in amazement at how smart Karadoc is about programming.
 
...

@Axios, I agree that the strategy you described in your post can sometimes be extremely effective - and the AI currently does not handle it well. I haven't made any changes for that yet, but now that you mention it, I can think of a few ideas for how to improve it. So I'll try to do that. (but I can't promise it will be soon.)

Thanks for the reply. Dont'worry, I perfectly understand how difficult is to develop a mod of this kind.

Good work! :goodjob:
 
I am EXTREMELY excited I came across this mod. I have played, religiously, several mods for BTS. Whether they be: BetterAI, LoR, Rise of Mankind: A New Dawn, Better BAT AI, etc.

I had not ever noticed this mod (probably because I have been intent on attempting to help improve A New Dawn), when I noticed that BBAI had a new post.

Upon reviewing that post, I can't say how truly excited I am to play this mod. I read all the changelogs, etc., and this looks just tremendous. I saw in posts way back that you were "replying to your own thread"....well, trust me, there are still many committed players who love this game and are going to be playing it for a long, long time. Thank you very much for the time and effort you have put into this mod!
 
Found a bug: When using the culture slider to increase happiness the city bar doesn't update. You have to click on the bar then it update the value. Just an interface problem but it significantly impacts game play.

Otherwise,
Good mod, the speed changes are completely awesome. Playing this on large terra with 15 civs on my old and rubbishy computer and getting less than 20 secs turntimes by 1600s. That is indeed a 100% speed increase.

AI seems to be playing well, but after playing just over half a game its still difficult to tell yet. I found that religion had less relevance, the AI were more Machiavellian which I like, but I found it a bit weird that two Buddhist countries spent a large amount of the game at war and slowly cancelling each other out of the game. Again it might just be a particular circumstance in this game.

Love the culture spread changes, much better. Oh, did you take 'Lead from Behind' mod out? I kind of like it because I only use GG as super medics.

I'm seriously thinking of rebuilding my personal mod on top of k-mod. (Github list changed files right?, from release to release so I can add your changes to and updates to my dll as you go along)
 
I've just uploaded version 1.06.

There aren't really any new AI features, but there are lots of bug fixes which will probably help the AI.

As I mentioned in a previous post, I've added a new UI option called rapid unit cycling. (Which is in the "BUG" options, even though it isn't actually part of the BUG mod.) When this option is enabled, the game does not wait for units to move before switching to the next unit. This isn't necessarily a good thing - because often you'll want to watch the outcome of your action. For this reason, rapid unit cycling is turned off by default. But I know there are some players who like to play super-fast, and so I hope this new option will be appreciated. :)
Spoiler :
It was a bit fiddly to get rapid cycling to cycling at the right time, and to not cycle at the wrong time. I've tested it quite a bit, but there still might be some cases where it does something wrong. Let me know if you notice any problems or strangeness.
By the way, rapid cycling doesn't really help much in multiplayer mode - because there is a bit of a delay for the game to send the commands over the network anyway. So it isn't much faster.


Are there any known side effects of the AI speed fix yet? I'm holding off on including the speed fix in my mod until I'm confident there are no side effects (of considerable pain to to the player).
The AI will not be identical to how it was before the change. In particular; when the AI splits up a group, the units that get split off will be moved last (instead of some other ordering that depends on the situation). So... that's a side effect, but I don't think anyone would notice that. I don't know of any other side effects.

Personally, and this is a personal choice of someone who plays at the emperor level with k mod :D, I'd like to see the ai get like 10% less research bonus, and like a 10-15% non wonder production bonus, even a higher amount of units in its city garrisons (it seems to keep 4 or 5 units max in a city not directly next to someone they were at war with , 7 or 8 units total would be better imo) . Even with #1 gnp i lose massively in research while the ai loses to military forces more often then being out researched-especially after nationalism- drafting.
I haven't yet consider changing the AIs bonuses. I guess it's worth considering. I don't think there's any reason to think the AI's difficulty handicap bonuses are any more balanced that all the other stuff I've changed already... But I'm going to leave it alone for the time being. I also play on emperor, and I typically find that the AI's tech is much better than mine while I'm trying to expand... but I catch up in the early renaissance era. As for units though. I'm glad you mentioned that. As it turns out, I'd inadvertently changed something which was sometimes causing the AI to build fewer units. ... so, hopefully it should be a little bit better now. Ultimately though, I think that if I can improve the AIs military tactics a bit more, then that would be better than telling them to build more units. -- I don't think many human players win by simply outnumbering the enemy.

I am EXTREMELY excited I came across this mod. [...]
Thanks for the support. :) I just hope the mod lives up the your expectations when you play it!

Found a bug: When using the culture slider to increase happiness the city bar doesn't update. You have to click on the bar then it update the value. Just an interface problem but it significantly impacts game play.
I haven't noticed a bug like that, and I'm not entirely sure what you mean. Either from the main map, or from inside the city screen, adjusting the culture slider should update the number of angry citizens in your cities. Are you saying that it does not do this? Do you have a save game which demonstrates the problem?

AI seems to be playing well, but after playing just over half a game its still difficult to tell yet. I found that religion had less relevance, the AI were more Machiavellian which I like, but I found it a bit weird that two Buddhist countries spent a large amount of the game at war and slowly cancelling each other out of the game. Again it might just be a particular circumstance in this game.
Yeah, that kind of stuff really varies from game to game. Some AIs care a lot about religion, and others don't really care at all. So depending on who-founds-what-and-where, some games are heavily influenced by religion and others aren't.

Oh, did you take 'Lead from Behind' mod out? I kind of like it because I only use GG as super medics.
I didn't take out LFB, but I did change it quite a lot, and super medics will be a bit more willing to fight than in the original LFB. Are you mentioning this because your super medics are getting killed? The main goal of my LFB changes were to make it so that combat GGs (ie. non super medic great generals) would actually defend when you needed them to. Because in the original LFB I got really frustrated when I used a GG to create a super-city defender to help me out of a tight spot, and then LFB wouldn't let my super defender actually defend until everyone else in my city was killed. The new system should still protect super medics, but not quite as much as before.

I'm seriously thinking of rebuilding my personal mod on top of k-mod. (Github list changed files right?, from release to release so I can add your changes to and updates to my dll as you go along)
Yes. Github list everything. You can see diffs between any selected version, and so on. Github is pretty much designed for the kind of thing you're talking about. -- I should mention though, I don't always upload things to github right away. For example, just then I uploaded 22 commits.
 
Sorry, I think that was a miscall regarding the bug, reloaded my game and everything was fine. Weird. If the happiness in the world view starts doing it again I'll try and get a save game for you.

I see your point regarding LFB. In fact, I never did lose a super medic in my current game, got a little worried when 'El Cid' started attacking all of a sudden. He won all his battles though.
 
I've had the same glitch happen with the happiness not updating on the city bar until I go inside the city-screen of a city (any city) and come back out of it. But I've had it happen with other mods than this one.

The most common culprit is using the culture slider, btw. If I have a city that's unhappy and raise the Culture Slider to fix the happiness, the unhappy icon commonly doesn't go away until I enter a city screen. I can't remember if ending the turn also will fix it.

I think it's a little more common in multiplayer than in singleplayer, also.

Not sure if it's an original BTS bug or if it's BUG-mod related, but I believe I saw it happen in other BUG-including mods like PIG Mod as well.
 
Possible bug:
1.06

Lots of ai battles, mostly distant ais fighting each other, very strange. Long wars with only occasional city loss. Canceling each other out for the most part.

Then an army invades me, and then I put a couple troops in the way on hills ( i dont want them taking the hills next to my city ) the ai stack will spend a full turn doing nothing, then the next turn after that, they will either attack the couple units or move around towards the city.

In the one case where they attack the units on the hill, a stack of 13 used one cat to hit the two units on the hills, losing a cat, then attacked one unit and killed it, then left a wounded unit on the hill, the rest of the stack did nothing. I kill their stack the turn afterwards, but if they had taken that hill, it wouldve been great for them for the defensive bonus.

In most cases they stare at the two units on the hill for a full turn and then the next turn they move around.

Also werid situation:

-Gilgamesh declares war, two horse archers rush into my territory and I killed them with pikemen,

-Shortly after that Genghis Khan declares war, and two bigs stacks, 4 or 5 turns apart, enter my territory and get obilterated by me, if they had been together, it wouldve made a huge difference.

-Then Julius caeser declares war right after I finish those 2 stacks of Ghengis Kahn. Again I use 4 or 5 cats first and then use my unique muskets to finish off the rest, with some losses

-Finally Gilgameshs army arrives and hes got alot of knights and can maybe just stack attack my city and win. I have a massive number of severely wounded. I go to diplomacy mode and he pays all his money for peace. And his dangerous stacks walks back home.

Clearly Ive reached some "gang up on the human who is close to becoming uncontrollable" mode. That bug with the stacks wasting a full turn when faced with a couple units on hills, combined with Julius not sending in his stack in (declaring war) until after I dealt with Ghengis's stack, and Gilgamesh not sending an army until Julius and Ghengis's stacks were both dead. Neted me like 4 great generals in short order.

4 or 5 turns after tha,t the russians declared war just as I am about to invade Khmer (who is still fighting the native americans) and I hit their stack with 4 or 5 double upgraded cats, then mopped up with janisarys (I was the turks).

Another stack from Genghis and I finish it easily.
I just invaded Khmer as they are the number one nation in points right now. Already razed one of their cities. But they had been at war against a much smaller natio (native americans) for like 45 turns already, so their defense is only 2 or 3 units per city (needs more defensive beef imo)

Are any of the flaws in the ai strategys fixable in this scenario Ive given?
 
The case where the AI wastes a turn and fails to completely kill the stack on the hill - that case is probably my fault. It sounds like its trying to use the new AI I wrote in the previous version, which is meant to consider fighting through weak defence in order to get better land for itself. (in your case, it wanted to stand on the hill, and it knew it could kill the hill defenders easily enough...) Anyway, it sounds like that's what it's trying to do, but obviously it isn't working properly. Thanks for mentioning it. I'll try to work out what went wrong. (see edit)

As for sending in horse archers and to be slain by pikemen, and sending in stacks that aren't big enough... that's unfortunate -- but it's probably trickier to fix. The horse archers were probably intending to try to pillage stuff -- and I guess they just weren't too concerned about their own safety. The divided stacks is the trickiest thing. Because although it might be better in your case if the AI put all its units in one stack; in some cases its better to keep them split up (so that they don't get completely destroyed by a counter attack with artillery or something. ...

By the way. The AI treats humans the same way it treats other AI players (except that it doesn't contact other AIs to tell them to change their religion or civics, or stuff like that).

As for the happiness update bug thing, I'm going to put this into CvPlayer::setCommercePecent
Code:
gDLL->getInterfaceIFace()->setDirty(CityInfo_DIRTY_BIT, true);
Hopefully that will fix the problem.

[edit]
I've found and fixed the bug which caused the AI to stop attacking when it was trying to take the hill. Thanks again for reporting that.

I'm not sure whether or not it is the same problem which was causing them to waste a turn before acting. I wasn't able to produce that behaviour in my test cases. Hopefully it was just a side effect of the same problem.
 
This is a request:

One thing that always bothered me about the Civ4 AI is their city placement: 4 times out of 5 they place new cities only 3 squares away from the previous city (at the beginning that's the capital) which leads to an inevitable overlapping city fat crosses when the city borders expand.

This seems very poor play by the AI since the city can't work all 20 plots, but seems to happen even if there's a ton of great land to move into.

Overlap should really only occur when land area is small or for the acquiring resources.

I'm wondering if you have any plans to improve the AI in this respect?
 
Continuing that game in 1.06 I got a couple spies and looked into foreign wars going on.

Seems like the ai is moving towards a city, bombarding once, then shuffling around alot, later they invade me and do the same thing.

Mongols invade me one big stack makes it onto some hills right next to my city, they bombard me once, then shuffle between a plains and two hills. In the meantime, two other stacks from the mongols show up and make their way to the hills. I wait until the largest stack moves to the plains, use cats, and mop up. The other stacks are much smaller and I can kill them on the hills.

So they got the hills next to the city, bombarded once and stopped, and moved back down to plains (still next to the city).

Idk if this was addressed but ai still doesnt attack with cats defensively. They seem to make 2x as many catapults as normal units, but dont use them in a defensive way other than to sit in a city (and receive no defensive bonus).

Idk if this is a bug either, but I got 3 or 4 people declaring war on me every 5-10 turns from the far side of the map.

In fact the mongols have to cross through 2 other nations just to get to me.

I just finished the war with the khmers- direct neighbors and leading points nation, razed four of their cities which each had 2 or 3 longbows and maybe 2 catapults in defense. They were in a foreign war with the native americans, but they would not make peace with the native americans- I tried to make them make peace in diplomacy- but they would not accept it until the romans jumped in and obliterated 2 of the native american's last 3 cities.

Now the romans, the mongols, and the russians are taking turns sending in large stacks of troops against me (knights vs janisarys in the best case for them). Ive gotten probably 10 great generals so far. My cap probably has 4 or 5 great generals providing experience. One as a greathealer, and the rest as secondary experience givers in different production cities.

I guess the constant invasions are kinda working, I was first to liberalism, but I had to add 10% to my culture slider to keep my dwiddling population happy from all the slavery Im having to do And occasionally I lose a couple 60- 75% chance battles and take casualities. So my military isnt growing by much and I had to wait to build universities. But Im filling in a city I burned out from the khmers...

I guess my ending impression is that the ai needs larger aggressive stacks which dont shuffle ( you may have already fixed that), maybe slightly longer times between wars, higher defensive city stacks, defensive use of catapults when their city defense rating drops, perhaps even when several ais planning on attacking someone, they should do it on the same turn, or setting a higher priority to enlarging their own nation rather than declaring war on the far side of the map like the romans, mongols and russians are doing.

But who knows how smart the ai can get, amirite?
 
The AI has always been terrible at city placement; this mod already improved that quite a bit thankfully. I find myself thinking, "Yeah, the AI built their city exactly where I would have built it" about 33% of the time now (up from like 10%) and "It isn't where I would have put it, but I can see the merits of putting it there" another 33% of the time.

Overlapping tiles isn't a bad thing if it's leveraged properly, and in the early game it can be very strong. The AI may do it a bit too readily (though, until the AI's wartime defense AI can be improved quite a lot, it's probably for the AI's benefit that its cities are tight-knit: easier to move defenders around that way). I know Karadoc tried to tighten up the AI's city placement in general, not being shy about overlapping borders, but not doing it in the moronic fashion they were known for doing it in the base game (hello Ice City spam) either.

As for the shuffling thing, I haven't seen that in quite that form, but that does sound like it could maybe have been caused (or made worse) by the changes intended to make the AI play faster. Fortunately, I suspect that Karadoc can fix a lot of that as the bugs become well-defined and understood.

By the way, I've tried out 1.06 a little bit myself and am loving the Fast Unit Cycling. :) Keep up the great modding! :)
 
The AI certainly isn't very smart about who it goes to war with, or when. That isn't something that I've changed so far. (at least not directly.) They are more likely to go to war with close neighbours that they dislike - but it isn't a sure thing. -- The thing is, although it is definitely bad strategy to fight a long-distance war without enough troops committed to actually conquer anything... I'm reluctant to make them not do that; because sometimes it is entirely appropriate for Role Playing reasons. The AI isn't 100% about winning; they have to role play a little bit.

That said, I do agree the way the AI chooses their war-plans does need some work. But I don't think bugs are causing the long-distance wars. I think that's just stupidity, or perhaps strong emotional dislike for particular civs...

Regarding defensive siege units. The AI does use collateral attacks defensively, sometimes - but it isn't very good at it. It is definitely a major weakness in the AI's defense tactics.

As for the AI shuffling their attack stack around... it sounds like they didn't think they had enough dudes to actually take the city. They were probably just moving around to pillage / choke while they waited for reinforcements. It sounds like it really backfired for them in this case... but I don't think its a bug - just a tactical mistake. ;)

About the city placement... as Lenowill said, I've changed their placement algorithm quite a lot - and I personally think it's much much better than it was. I'm actually a little bit disappointed that you think it's bad. :( When you're placing your own cities, do you disagree with the blue-circle recommendations that the game gives? Those recommendations use the same algorithms as the AI uses (except that the AI also uses some flavour-factors that I programmed into it.) I usually think the recommendations are pretty good. ... but there is one significant weakness with the AI's city placement: it doesn't plan ahead. ie. When choosing city sites, the AI first looks for the very best possible site, and writes that down, then it looks for the next best site given that the first one will be settled on, and writes that down, etc. It does not look for the best combination of sites... and so for that reason it can sometimes get things a bit wrong.
 
Overlapping tiles isn't a bad thing if it's leveraged properly, and in the early game it can be very strong. The AI may do it a bit too readily (though, until the AI's wartime defense AI can be improved quite a lot, it's probably for the AI's benefit that its cities are tight-knit: easier to move defenders around that way).

OK, you have a point. I still would argue that extra yield placement is more worthwhile by the classical era, but perhaps for the AI it is better to play it safe in the early game.

About the city placement... as Lenowill said, I've changed their placement algorithm quite a lot - and I personally think it's much much better than it was. I'm actually a little bit disappointed that you think it's bad. :( When you're placing your own cities, do you disagree with the blue-circle recommendations that the game gives?

I don't think it is 'bad', definitely better than Vanilla. Its just a part of the AI that's up for debate. This 'overlapping' of the cities is something that's been about in Civ since forever.

I don't really pay attention to the AI suggestions circles anymore since I use the strategic layer when planning my empire so I can't say if I disagree or not Anyway, did not intend to be discouraging. I'm really enjoying this mod:goodjob:!
 
RE: Attack stacks shuffling around near enemy cities.

I ran into this same problem in my mod and it seemed to be mostly related to this section of code in AI_attackCityMove which is hit when the AI decides it needs more troops before attacking a city.

Code:
if( AI_pillageRange(0) )
{
	return;
}

Once I commented that section out, the AI seemed to be much less schizo about moving its attack stack when near an enemy city.


EDIT: There's also this section just above the previously mentioned code.

Code:
// Move to good tile to attack from unless we're way more powerful
if (plot()->defenseModifier(getTeam(), false) <= 0)
{
	if( AI_goToTargetCity(0,1,pTargetCity) )
	{
		return;
	}
}

While it seems good in theory, what ends up happening is that the stack arrives at the city on a good defensive tile, sees that it doesnt have enough for a successful assault, hits some later code that tells it to pillage instead, so it moves off the defensive tile to do so. Then, the next turn, it sees that its not on a defensive tile, and moves back. Rinse and repeat. I ended up commenting out both sections of code with no ill effects.
 
Tholal, thanks for the feedback. :)
You're right about the original BBAI AI alternating between pillage and attack indefinitely, but I think I've already fixed in a different way:
Code:
// K-Mod - only move into attack position if we have a chance.
// without this check, the AI can get stuck alternating between this, and pillage.
// I've tried to roughly take into account how much our ratio would improve by removing a river penalty.
if (canBombard(plot()) || (100 + (plot()->isRiverCrossing(directionXY(plot(), pTargetCity->plot()))?GC.getRIVER_ATTACK_MODIFIER()/2 : 0)) * iComparePostBombard >= 100 * iAttackRatio)
{
// K-Mod end
	// Move to good tile to attack from unless we're way more powerful
	if( AI_goToTargetCity(MOVE_ATTACK_STACK,1,pTargetCity) )
	{
		return;
	}
}
The additional condition I've put in there is meant to tell the AI to only get into a better position if it is actually intending to attack... so it shouldn't alternate back to pillage unless some new defenders arrive. I'm not really sure whether or not that is better than just removing it completely. And it's a bit funny that it says "unless we're way more powerful" - because neither of those functions actually check how powerful we are...

As for if( AI_pillageRange(0) ), as far as I can tell, the "zero" is indicates that the group should only try to pillage the tile it is currently standing on. It's the AI_pillageAroundCity a little bit lower down that makes it move.

Anyway, there are definitely some problems in that area of the code. It definitely needs some further work. In particular, I need to try to fix the problem that a few people have described where the AI will try to "choke" the city by standing still on a defensive tile even if they are just going to get wiped out. (choking is often a good strategy, but there are times when they really should just retreat - and they currently never do that.)

But at the moment I'm working on something else. I've been working on improving the AIs usage of defensive collateral units. I've basically rewritten the way the AI calculates their offensive power and defensive power of their units and the enemies units - and I've put in a new function which is specifically designed for collateral units trying to defend cities. I'm not sure how well it will work, but it should be better than the original stuff. (The main problem with the original stuff was that it relied on an "odds threshold"; which basically meant if the stack threatening the city happened to have one strong defender in it, then the collateral units would just say "nope. can't get good enough odds. I'd better not attack." - that's obviously stupid, but that's how it was.)

I've also changed stuff stuff with how the AI joins their groups together, and I think that might help stop the AI from wasting turns on the frontline.

-- All that, and more - coming in the next version! ;p
 
Back
Top Bottom