K-Mod: Far Beyond the Sword

Hello again, karadoc!

I've spent the last hour or two studying a nasty AI bug: workers won't build pastures.

The cause, as far as I can tell, is that Realism Invictus includes a number of civ-specific improvements, one of which is a Ranch - American flavor of a Pasture, but a bit better. This 'civ-specificity' is implemented in an indirect way - each civilization has its own civ-specific worker unit and only American workers can build Ranch.

Apparently, when determining the best improvement, AI picks Ranch, but there are no workers that can actually build that Ranch.

I noticed you made many changes to that area of the code. Could any of them affect this? Any ideas how to solve in an efficient and general way?

Thank you!
Sorry to keep pestering you with my merge, but you're invaluable. :p
 
I have one question.

Nuke messages (eg. player X's nuke exploded, or player Y intercepted X's nuke) are now only shown to civs who player who have met the civilizations involved in the event.

What happens if i nuke a neutral territory? This was the common notification strategy in multiplayer with my mates. It was used to "send a message" to the rest of the human players that they shouldnt mess with me (or any other that has nukes). Plain words "dont do that (or do that) or i will nuke u" dont often work since some might consider it a bluff. Nuking a neutral spot is something like a strength demonstration to the rest of human players.
Maybe this strategy isnt widely used but its a useful stuff my mates and i do and i wouldnt like to see it disappear just like that. :(
 
@Ungomma, did that stuff work in the first place? I would have thought that the original AI would have failed to handle that as well. Anyway, I suppose the only way to fix it is to strengthen the conditions which are checked to decide if a certain improvement can be built or not. As far as I can think of, the only choice is to scan through all worker units, see which ones the civ can build, and see then see if any of them can build the improvement in question. -- That doesn't sound efficient though... maybe it's going to need yet more cache.

I can think of two good places to put these extra checks: either at the start of CvCityAI::AI_getImprovementValue, when it is checking to see if the improvement is 'valid'. Or alternatively, inside CvPlayer::canBuild, which would seem to make more sense but could lead to unintended consequences...

That should fix that particular problem, but I can think of a bunch of other problems...
#1. players could build the special improvements if they have the special worker gifted to them - but unless the new check we were just talking about actually scans through every unit the player owns, it probably wont' pick up the fact that the improvement is actual buildable. (ie. the AI won't be know to use the special worker to build the special improvement; and in fact, the special worker won't be able to build the normal improvement either - and so it will be quite confusing for the poor old AI.) -- (** note: if the check is inside CvPlayer::canBuild, then the gifted special worker simply will not be able to build the special improvement (or the normal improvement). AI or otherwise.)

#2. In AI_techValue, the AI makes a rough estimate of the value of each improvement enabled. As with bestBuild, this evaluation assumes that there are no civ-specific improvements; and so what will probably happen is that the AI will add points for both the standard improvement and for the special improvement - thus overvaluing the tech.

There may be other problems like this, but that's all I can think of at the moment.

@En Dotter, your show of strength will still work fine. If you drop a nuke anywhere, anyone who has met you will get the message (even if you nuke neutral territory, or even if you nuke a 3rd civ who no one else has met). The only prerequisite for getting the "nuke exploded" message is that they've met you. -- However, if the nuke gets shot down, only civs that have met both the nuking civ and the intercepting civ will get the message.
 
Hey Karadoc,

1. Im playing on a continents map and there are 5 of us packed on a continent (version 1.32), there was a jewish guy that got vassaled and converted but now everyone is Buddist...and its just nothing but 100s of turns of peace...because we are all Buddist and "friendly"

Can you/should you, perhaps increase the chance of war if EVERYONE on a land mass is friendly/the same religion, I mean it makes sense for everyone to play nice as long as there are nearby heathens...but after the heathens fall...I think it would better for the game/gameplay for the remaining faithful to compete to a higher degree.

2. Also, the ai often gets early privateers now, (awesome usage btw), but I am almost always, way behind in sea tech, trying to hold onto my land territory. Perhaps allow seige equipment to bombard 3% of the health off of a nearby sea unit (obviously numbers are changeable)? I just had a privateer blockade two cities at the same time and their power is 6 and the best sea power I can build is 3 lol. Even with 3 of them, not that a great chance Ill win...just a thought.
 
A minor issue from a copy and paste: canContactAndTalk in CvPlayer.h line 201 is unnecessarily marked as DllExport
 
Hello again, karadoc!

I've spent the last hour or two studying a nasty AI bug: workers won't build pastures.

The cause, as far as I can tell, is that Realism Invictus includes a number of civ-specific improvements, one of which is a Ranch - American flavor of a Pasture, but a bit better. This 'civ-specificity' is implemented in an indirect way - each civilization has its own civ-specific worker unit and only American workers can build Ranch.

Apparently, when determining the best improvement, AI picks Ranch, but there are no workers that can actually build that Ranch.

I noticed you made many changes to that area of the code. Could any of them affect this? Any ideas how to solve in an efficient and general way?

Thank you!
Sorry to keep pestering you with my merge, but you're invaluable. :p

Ranch is a building in Realism Invictus, not an improvement. As far as I know, RI has no civ-specific improvements.
 
There's a piece of K-Mod code in CvStruct.h which I think you are missing. It defines the '<' operator for the IDInfo type.
Code:
	// K-Mod
	bool operator< (const IDInfo& a) const
	{
		return eOwner < a.eOwner || (eOwner == a.eOwner && iID < a.iID);
	}
	// K-Mod end
(C++ error messages are notoriously cryptic when templates are involved.)

Thanks, that indeed was the problem. Not sure how I missed that.

Anyhow, I got it compiled and up and running. I have some bugs to squash but I hope to have those ironed out soon. When I've got it in a good state, I'll release the merge for those who are interested.
 
Ranch is a building in Realism Invictus, not an improvement. As far as I know, RI has no civ-specific improvements.

In fact, for 3.2 version RI decided to add new improvements. Some of them are totally new (like the Aztec one - Chinampa) and others are replacements/flavor. Ranches are among these ones.
One worker only is allowed to build a Ranch: the US Worker. (Take a look in our SVN).
 
Hi Kara! I have successfully merged your mod with the original BTS sources in an effort to know what I should add to my own mods. In the process I commented everything you changed very similar to what you did for individual line alterations(e.g. //KMOD). For the parts where seemingly whole functions or more were changed, I deleted out the commented out original BTS code and just put this around the changes:

Spoiler :
Code:
/************************************************************************************************/
/* KMOD                       START(or END)                                                  */
/************************************************************************************************/

Given what we discussed earlier, you may or may not like it, but I though I might let you know because perhaps it may be what you wanted afterall.

Here is the link to the attachment.
 
if I can make a humble suggestion:
-protective is underpowered
-siege weapons are overpowered
-the drill promotion line is underpowered (combat is usually better)

we can kill 3 birds with one stone. Give a buff to the drill promotion line. Currently drill works such that it reduces collateral damage by 0, 20%, 40%, 60% at D1, D2, D3, D4 respectively.
If we change this to 20, 40, 60, 80% it will make drill better because it would reduce collateral damage and often battles are decided by collateral damage. This would make drill a viable option, would make protective better, and would mean siege weapons would dominate less. I think it could make the game much more interesting.
 
if I can make a humble suggestion:
-protective is underpowered
-siege weapons are overpowered
-the drill promotion line is underpowered (combat is usually better)

we can kill 3 birds with one stone. Give a buff to the drill promotion line. Currently drill works such that it reduces collateral damage by 0, 20%, 40%, 60% at D1, D2, D3, D4 respectively.
If we change this to 20, 40, 60, 80% it will make drill better because it would reduce collateral damage and often battles are decided by collateral damage. This would make drill a viable option, would make protective better, and would mean siege weapons would dominate less. I think it could make the game much more interesting.

:agree:
 
if I can make a humble suggestion:
-protective is underpowered
-siege weapons are overpowered
-the drill promotion line is underpowered (combat is usually better)

we can kill 3 birds with one stone. Give a [collateral resistance] buff to the drill promotion line.
That has been suggested a couple of times now, and I may well make a change like that in the future - although probably not as big as you're suggesting. Keep in mind though that although there has been a lot of discussion in the past about how protective / drill is underpowered, essentially all of that discussion refers to the standard BtS rules. Protective & drill have already been buffed slightly in K-Mod and don't think that has quite seeped into the general player consciousness. (They're probably still both a bit weaker than their counterparts, but it's worth keeping in mind that they getting slowly stronger...) ... anyway, maybe one day I'll give -10% collateral to Drill I - but I think 20% is probably a bit too much.

Hi Kara! I have successfully merged your mod with the original BTS sources in an effort to know what I should add to my own mods. In the process I commented everything you changed very similar to what you did for individual line alterations(e.g. //KMOD).

Given what we discussed earlier, you may or may not like it, but I though I might let you know because perhaps it may be what you wanted afterall.
That sounds pretty neat, and it's probably pretty useful for other modders such as yourself. But I'm still not going to adopt that style, sorry. In my view, the tracking what's changed and what's not changed should be handled by external 'diff' programs, such as those included in git (and viewable on github). If people are already using tools like that, then the extra source comments aren't required, and so they're just a bit of extra work to maintain, and a bit of extra clutter to scroll past. (but I do appreciate that they are useful for modders who don't use those kind of external tools...)

The main reason I put 'K-Mod' comments onto things, and sometimes leave the original code there, is that it sometimes helps me work out if bugs are due to my own change, or due to the original code; and also, I think it's probably helpful to signal to modders that such-and-such original function has been removed and replaced by a new function. ie. I think it's a good idea to flag changes in the API, but not necessarily changes in the body of the functions. -- particularly when the changes in the body don't even change anything. (eg. I sometimes rearrange stuff in the original code just to make it easier for me to read without changing the functionality.)

A minor issue from a copy and paste: canContactAndTalk in CvPlayer.h line 201 is unnecessarily marked as DllExport
You're correct; it was a copy/paste mistake. Thanks.

Hey Karadoc,

1. Im playing on a continents map and there are 5 of us packed on a continent (version 1.32), there was a jewish guy that got vassaled and converted but now everyone is Buddist...and its just nothing but 100s of turns of peace...because we are all Buddist and "friendly"

Can you/should you, perhaps increase the chance of war if EVERYONE on a land mass is friendly/the same religion, I mean it makes sense for everyone to play nice as long as there are nearby heathens...but after the heathens fall...I think it would better for the game/gameplay for the remaining faithful to compete to a higher degree.

2. Also, the ai often gets early privateers now, (awesome usage btw), but I am almost always, way behind in sea tech, trying to hold onto my land territory. Perhaps allow seige equipment to bombard 3% of the health off of a nearby sea unit (obviously numbers are changeable)? I just had a privateer blockade two cities at the same time and their power is 6 and the best sea power I can build is 3 lol. Even with 3 of them, not that a great chance Ill win...just a thought.

For the first point... well... It's kind of tricky. On the one hand, I agree that sometimes the game can get a little bit dull if everyone gets all buddy-buddy with each other; and it might be good to have some kind of destabilizing rules like you described. But on the other hand, I think it's good that it's possible to occasionally encounter a peaceful world. I think it's good for variety. And it doesn't happen very often, because usually there are a couple of decently sized religions, and even when there aren't there is usually still someone who will be willing to disrupt the peace... either someone like Willem, who tends to switch to Free Religion and then start killing people, or just some other leader who doesn't care so much about Religion - and, of course, the human player is always free to start a fight if they want one. -- Also, the attitude points rules have not been changed at all by K-Mod so far; and so there's a bit of inertia there. (The attitude rules aren't great, but I think it's good to keep things the same unless there are strong reasons to change them.)

For the second point &#8211; a whole new form of ranged combat &#8211; I think that's out of the scope of the mod. It would require new UI buttons and such, new AI, new documentation of some kind to describe that it can be done (eg. in the civilopedia, and in button tooltips, and in the loading hints, and so on.)


[edit]
Also..

Hi Karadoc,

we observed this crash several times while using K-Mod but always thought it must be some bad luck, but yesterday we explicitly tried to open multiplayer games and it crashed every time, so it might be a K-Mod problem.

It will crash, when
the host loads a multiplayer save with Direct IP connection and does not wait for the other player to join before clicking on the launch button. The game crashes on the client side (when he finally has joined) after it is finished loading for the client.
It will not crash, when
the host loads a multiplayer save with Direct IP connection and does wait for the other player to join before clicking on the launch button.​
I tested this, and did not observe any crash. When you say "does not wait..." do you mean that you load the game fully, and get the 'waiting for players' screen thing in game, and then the second player starts joining? Or do you mean that the second player tries to join immediately after the host launches the game, so that the second player is trying to join while the first is still loading?

I find it very frustrating that there are apparently important bugs like this which I can't reproduce in my testing. :( Speaking of which, has anyone tested that python stuff satrapper and I were talking about? I'm interested to know what the 'normal' behaviour is. ie. whether it is normal for the python to be automatically cleared when starting a new game, or whether it is normal for it not to be cleared. (If it's normal for it to not to be cleared, then I guess I'll have to find some kind of work-around to fix the side-effects of the left-over python data. But if it's normal for it to be cleared... then... well... I'm not really sure. I guess I'll just keep an eye out for what might cause it to not be cleared, and then take it from there.)

--

If there was a K-Mod forum, then I suppose the discussion about bugs would be in one thread, and the discussion about merging and modding and so on in another thread (or threads), and the discussion about various balance things... and so on. Maybe that would be good. ... or maybe it would be bad, because people merging mods might be interested to hear these balance suggestions, so that they can put them in their own mod. Or maybe they want to hear about bugs so they can fix them without waiting for K-Mod to fix them, or whatever. -- I suppose that if people wanted exposure to that extra stuff, they could just check the other threads in the forum, but that might be slightly harder to keep track of. I don't know.

In any case, is anyone actually going forward with that?
 
Hi Karadoc,

I launched the game before the other player joined, and stared at the waiting screen. When the other person joined, the screen disappears and the GUI is half-usable (no commands).
Then it crashed on the client PC when its loading has finished just before the GUI should have appeared, and I get the waiting screen again.

I can't confirm, that the other person has everything installed correctly. But at least we can play without any other problem for the last months ;) Depsite the AI being so strong now, that we start to think about switching from immortal to emperor...
 
I think increasing the chance of war on a continent, or other land mass where all the civs are the same religion, increases gameplay, doesnt decrease it.

When there is no war, the game becomes about culture and tech rate. Therefore the big civs will win 95% of the time and a smaller early game wonder whore/cultural whore civ will win the other 5%. Its a slow and painful process.

I know it is pleasant about preserving the thought of a warless game, but what game can u get away with not having culture, tech, or any espionage. Every game, you will always need to use these. Having a game without war is unnatural in this context.

I know the human player can start a war, but the rules of diplomacy are set against him. First the human player, at higher difficulties, will not be as large as the ai civs, early game. So while the human player is catching up/preparing for war, everyone switches to the same religion. So when the player finally decides to declare war, not only does he piss off a stronger ai nation- which he might be able to handle- but also all the other neighbor ais who now say "you declared war on our friend".

Soon it becomes a dogpile fight against the human player, who was already behind. Not very interesting imo.

Just my thoughts...


Edit: ETA on next patch? :D
 
That has been suggested a couple of times now, and I may well make a change like that in the future - although probably not as big as you're suggesting. Keep in mind though that although there has been a lot of discussion in the past about how protective / drill is underpowered, essentially all of that discussion refers to the standard BtS rules. Protective & drill have already been buffed slightly in K-Mod and don't think that has quite seeped into the general player consciousness. (They're probably still both a bit weaker than their counterparts, but it's worth keeping in mind that they getting slowly stronger...) ... anyway, maybe one day I'll give -10% collateral to Drill I - but I think 20% is probably a bit too much.

I still think the best idea would be to swap the first strike chance from Drill I with one of the first strikes from Drill IV, as the PIG mod does. The Drill line isn't really that bad, it's just too top-loaded (Drill I may well be the worst promotion in the game).

By the way, I hope I'm not sounding like a broken record with the balance ideas.
 
It's not even the first strikes that I care about, it's the collateral damage reduction. That ends up being the main reason I ever use the drill promotion. I've always thought it boring and lame how siege/collateral make combat bland and the unit counters (pike vs knight, crossbow vs mace) don't matter. So I put 2 and 2 together and realized that a counter to siege weapons would make combat more interesting, and would have the side effect of making drill/protective a bit better as well.
 
I'm wondering if a problem that I had in the past (about a year ago) still exists.

If I start a game in advanced mode, where I start, say, in the modern era, The K Mod doesn't start properly.

With vanilla BtS the game just starts up with a few units and when you build a city there will automatically be some buildings in it.

If I try to start an advanced game with K Mod I get a different screen that asks what units I want to place on the map, but then doesn't even let me place the units.
Because I like to play from an advanced start I had to stop using K Mod.

If I remember correctly, it also broke vanilla's ability to start in advanced mode and I had to reinstall the game.

Do advanced starts work properly now?
 
I'm wondering if a problem that I had in the past (about a year ago) still exists.

If I start a game in advanced mode, where I start, say, in the modern era, The K Mod doesn't start properly.

With vanilla BtS the game just starts up with a few units and when you build a city there will automatically be some buildings in it.

If I try to start an advanced game with K Mod I get a different screen that asks what units I want to place on the map, but then doesn't even let me place the units.
Because I like to play from an advanced start I had to stop using K Mod.

I don't recall anyone reporting that. So, if it was broken, it is probably is still broken. I'll check it out now.

but, as for this:
If I remember correctly, it also broke vanilla's ability to start in advanced mode and I had to reinstall the game.
That seems extremely unlikely. K-Mod doesn't alter any of the vanilla files; and so unless there is some horrible virus-like bug which somehow only affects advanced start games; I really don't believe this would happen.
(but I guess I'm about to find out...)

[edit]

I just tested it, and it seemed to work flawlessly. I started in the industrial era, and I was able to place cities and units, and the cities got some free buildings, and so on.

As I said before, I don't recall anyone reporting that advanced start was broken in the first place. Maybe that's just my bad memory; but on the other hand, could it be yours? Maybe you were thinking of a different mod?
 
I know K-mod is supposed to make the game run faster, but will it also allow me to play on larger maps? I've never been able to play anything above medium due to lag. Will I be able to play large or huge now that I have the mod? (I am reluctant to test it by playing for 4 or 5 hours and then potentially have to quit because of lag).
 
Back
Top Bottom