K-Mod: Far Beyond the Sword

1. -Snip... Chariots.... Snip-

2. Is there a way to give the Ai full resources for resources that they put forts on? I wouldnt mind giving them that, because sometimes the forts arent always 100% necessary.


1. Just give the Chariot a higher base strength, and a negative % modifier against archers - that will make your in-game UI text and the XML code a lot cleaner (i.e Chariot of strength 6, -30% vs archers)... or something along those lines.

2. The easier way to do that would be just to set a yield change for the resource in the XML file for the fort improvement, but then that would apply for humans as well. It's possible for only AIs, but then the effort of applying a set of conditionals into finding the appropriate yields (i.e. matching the relevant improvement (such as spice -> plantation), rather assigning the fort improvement specific yield values) is not that simple (at least, if you're not hard-coding the yield values in..)
 
I've noticed a few problems with cultural victory:

1) When I gift great artist to AI, it will always use it to create great work in city with highest culture even if it already has legendary culture. This also happens when I add GA to AI player with WB.

2) If I forge permanent alliance with AI, that AI still can be shown as rival closest to cultural victory in victory tab although that AI isn't my rival anymore.

3) Similar to 2nd, when in permanent alliance two players only need 3 legendary cities combined but victory tab shows their cities separately (both in the position of current player and best rival).
 
3 Thoughts...

1. Is anyone working on the ai taking into account promotions when attacking a city, it was discussed before...you know like maceman upgraded with bonus vs seige are really good vs seige units. Machine gun defenders are usually more powerful than they appear to the ai, because of the first strikes etc etc.

2. Sometimes the AI does alot of little drops instead of one big effective drop...wish I could do something about that.

3. <CommerceInfo>
<Type>COMMERCE_CULTURE</Type>
<Description>TXT_KEY_COMMERCE_CULTURE</Description>
<bFlexiblePercent>0</bFlexiblePercent>
<Button>Art/Interface/Buttons/Process/ProcessCulture.dds</Button>
</CommerceInfo>
If culture isnt set to flexible, does that mean the ai cannot focus culture for a culture win? This might be intended.

Extra thought: Good to see karadoc checking in now and again.
 
I've made some changes to how the AI uses great artists, to how it ranks culture cities. I think will make it more effective at going for cultural victories. The use of great works was the only action left out when I rewrote the AI for great people. (I left it out just because I didn't feel like dealing with it. Actually, infiltration missions are also left out. The AI doesn't consider doing those at all.) Great works are now evaluated, compared, and used just like other great person actions. The evaluation is completely new, so hopefully it works well...

The bigger problem with the AI's treatment of culture was that it ranked it culture cities based only on their culture rate. Generally it would focus on adding culture to it's 3rd best culture city. The problem is that it didn't even consider the possibility that the third best city (or any other city) already had lots of culture. Usually the 3rd highest rate will be the 3rd city to reach legendary, but it isn't always like that. Sometime the 3rd highest rate could be a low culture city that was only recently captured by happens to have a lot of towns around it or something... So sometimes the AI made very poor decisions about where to put it's culture for a cultural victory. I'm working on fixing that right now.

The list of best cultural cities in the victory screen is already fixed in the version I'm working on.

The fact that culture isn't 'flexible' means that no player can adjust how much commerce is allocated to culture. i.e. they can't adjust their culture slider. Discovering "drama" set it to flexible.

The AI does take promotions and first-strikes into account already in all it's combat decisions - but it only uses approximations, and sometimes those approximations don't work well. One way to trick the AI is to use lots of promotions with bonuses against particular types of units, such as 'shock' or 'pinch'; machine-guns' bonus vs gunpowder is another example. It's difficult to estimate the power of those kinds of bonuses, and the AI's current method very simplistic. (It's difficult because it's hard to know which defenders are going to be matched against which attackers. Shock isn't going to do anything if all the shock defenders get killed by elephants before the swordsmen start attacking...)
 
You are awesome Karadoc, thanks for clearing that stuff up.

1. You ever think of increasing the asset rating for machine guns, so the Ai will use them more- currently I have mine set at asset 5, and ai cities are generally much much harder to take. Machine guns are good vs seige and gunpowder units and dont take collaterol dmg. I also use the unitais for city defense/counter and the notunitais for stuff like attacking, in the xml.

2. Trade increases income, but doesnt reflect increased production from trade. One thing Ive thought about is balancing islands vs mainlands by giving harbors and custom houses some production per turn to reflect arms shipments, raw materials offloading, and of course, just to make islands more of a threat to a mainland continent.

I also made the unique building quality for the netherland dike (unique levee) which is +1 hammer per ocean/river tile, the standard for the levee now and gave the netherland dike additional bonuses to compensate. I also slightly buffed Moai Statues/the Palace, to give some island civs a more England or Japan or Venice type feel...+10% discount towards ship building.

So if you have a capital (with palace ofc) by the ocean and it ends up building the Moai statues then you get 20% discount off your ship building.

Its leading to much more interesting dynamics between island civs and said island civs are becoming real threats to mainland civs.

Edit: is your current version have the privateer bug, where privateers are never made when other civs have access to frigates and above. I can see that in alot of cases, privateers being terrible, so probably not important.
 
Also some vassal info isn't displayed:

When human player is involuntary (by capitulation) vassal to another human player there's no independence possibility info (area and pop ratio of vassal and master, original area) displayed anywhere.

This also happens when AI player is involuntary vassal to another AI player and then when master forms permanent alliance with someone that information stops being visible.
 
Anyone know what these do?


OCCUPATION_CULTURE_PERCENT_THRESHOLD

REVOLT_TOTAL_CULTURE_MODIFIER


Ive tried adjusting them...but they might be things that a person would need to start a new game to change....like drafting changes.
 
They are variables that adjust how many units is needed to sufficiently subjugate or otherwise suppress a city's population from revolting if the other civ has dominant culture presence.
 
Thanks,

I made the military academy buildable (at huge building cost), how do I disable great generals from making military academies in the xml? I dont want the ai potentially wasting great generals.
 
Thanks,

I made the military academy buildable (at huge building cost), how do I disable great generals from making military academies in the xml? I dont want the ai potentially wasting great generals.

In UnitInfos.xml, under the Great General unit class

Spoiler :

<Buildings>
<Building>
<BuildingType>BUILDING_MILITARY_ACADEMY</BuildingType>
<bBuilding>1</bBuilding>
</Building>
</Buildings>



Just clear out that section and you're good to go!

Although from a balance perspective, allowing the GG to build a MA might still be necessary (think of it this way: if you're using it the GG to build a MA, it's either in a very high production city, where u can churn out your most expensive units in 1 turn, or in a low production city, when you've run out of Heroic Epics to build.... in either case you don't have the hammers to spare for a large building regardless).
 
Thanks again for that info,

I think disabling might be better because I play on emperor and the AI gets pretty decent building cost discounts and then over time (per era) those discounts get even better, so I figure the AI needs experienced units over a quicker building.

Case in point, I wish the ai added great people as specialists a bit more than they do now. I very slightly buffed the great people added to cities, mostly because Ive always hated using great people for tech only...I only use specialists for certain strategic techs like theology, where I can build the Apostolic palace and get a production bonus afterwards.

I also made changes like forge providing +20% hammers and 2 base hammers per turn...try and make everyone not so dependent on slavery for so long.

Edit: I swear I looked in unitinfos before and didnt see it, and now I do, must be code mesmerized or something.
 
I am experimenting along those lines as well - giving the vanilla % multiplier buildings more flat production/commerces/specialists.

On the slavery-dependence thing, I think buffing the other civics, and/or increasing the "hurry modifier" (you'll find most wonders have a large modifier on them) might serve to get people out faster..... although I have not looked into the part of the C++ to see what governs the AI civic preference beyond whats available and what their favourite civic is...
 
When couting score for time victory the score of permanently allied players is added together, so does this mean that points they get from technologies is counted twice? If it does, isn't that unfair?
 
@ Karadoc

Hey, in CvPlayerAI.cpp, line 3870:

(code snippet)
Spoiler :
// K-Mod. Note: iValue is an int, but this function only return a short - so we need to be careful.
FAssert(iValue >= 0);
FAssert(iValue < MAX_SHORT);
iValue = std::min(iValue, MAX_SHORT);
// K-Mod end
return std::max(1, iValue);

Error message:
Spoiler :

Assert Failed

File: CvPlayerAI.cpp
Line: 3870
Expression: iValue < MAX_SHORT
Message:

----------------------------------------------------------



Whenever I try to load a game with a custom map size (i.e. different/bigger than the default sizes), I run into the aforementioned error.... what exactly does the snippet of code there do...?

I did re-compile the DLL, but pretty sure all I changed was to comment out the section that limits the blitz promotion to units with >2 moves.

EDIT: It only happens with a debug-DLL, it works fine (well, the game loads... unsure if problems might crop up later on...) with a normal 'release'-DLL..... but still curious.
 
@ Karadoc

Hey, in CvPlayerAI.cpp, line 3870:

(code snippet)
Spoiler :
// K-Mod. Note: iValue is an int, but this function only return a short - so we need to be careful.
FAssert(iValue >= 0);
FAssert(iValue < MAX_SHORT);
iValue = std::min(iValue, MAX_SHORT);
// K-Mod end
return std::max(1, iValue);

Error message:
Spoiler :

Assert Failed

File: CvPlayerAI.cpp
Line: 3870
Expression: iValue < MAX_SHORT
Message:

----------------------------------------------------------



Whenever I try to load a game with a custom map size (i.e. different/bigger than the default sizes), I run into the aforementioned error.... what exactly does the snippet of code there do...?

I did re-compile the DLL, but pretty sure all I changed was to comment out the section that limits the blitz promotion to units with >2 moves.

EDIT: It only happens with a debug-DLL, it works fine (well, the game loads... unsure if problems might crop up later on...) with a normal 'release'-DLL..... but still curious.

Well, I haven't delved into the source code too much, but the error indeed pops up only with a debug-DLL because FAssert is active only if the 'state' is 'debug'.

The assertion error actually has been prevented by the next line, where iValue is forced to be not larger than MAX_SHORT.

( Personally, based on the code snippet, I think the assert should be for iValue <= MAX_SHORT )

PS: Where did you comment the code that limits blitz promotion?


.
 
Well, I haven't delved into the source code too much, but the error indeed pops up only with a debug-DLL because FAssert is active only if the 'state' is 'debug'.

The assertion error actually has been prevented by the next line, where iValue is forced to be not larger than MAX_SHORT.

( Personally, based on the code snippet, I think the assert should be for iValue <= MAX_SHORT )

PS: Where did you comment the code that limits blitz promotion?


.

CvGameCoreUtils.cpp

Approximately line 350 or so

Spoiler :

// Lift restriction on Blitz promotion
//
//if (kUnit.getMoves() == 1)
//{
// if (kPromotion.isBlitz())
// {
// return false;
// }
} */
 
Code:
// K-Mod. Note: iValue is an int, but this function only return a short - so we need to be careful.
	FAssert(iValue >= 0);
	FAssert(iValue < MAX_SHORT);
	iValue = std::min(iValue, MAX_SHORT);
	// K-Mod end
	return std::max(1, iValue);
[...]
If "iValue" was used with a value bigger than "MAX_SHORT", then the value would actually wrap around and become a big negative number rather than a big positive number. That would result in some AI confusion.

pepoluan is right that that kind of 'overflow' effect is prevented by the line after the FAssert. The FAssert is really just there to warn us that the values being used are too big.

Nevertheless, if the assertion fails (i.e. if iValue is not less thatn MAX_SHORT) it still indicates that there is a problem. If iValue is more than MAX_SHORT, then it will get capped. If this is happening a lot, then the AI won't be able to tell the difference between a good city location, and a really good city location, because both of them will have the same value: they'll both be MAX_SHORT (because that's the maximum). That's a fairly minor problem...

What I'd be more worried about is why is the value so high? The values that I typically see in my games around around 4000. Really good city sites might be as high as 5000; but MAX_SHORT is 32768. That is not insanely huge, but it's still significantly bigger than I'd expect. So I'd worry that there is a bug somewhere that is causing the values to be much bigger than they should be. I wonder how big the values actually were in your case.

When couting score for time victory the score of permanently allied players is added together, so does this mean that points they get from technologies is counted twice? If it does, isn't that unfair?
I haven't checked how that works. But I agree that it would be unfair if the tech scores were added. If that is what is happening, it should be changed. (But I can't look into it right now.)
 
Nevertheless, if the assertion fails (i.e. if iValue is not less thatn MAX_SHORT) it still indicates that there is a problem. If iValue is more than MAX_SHORT, then it will get capped. If this is happening a lot, then the AI won't be able to tell the difference between a good city location, and a really good city location, because both of them will have the same value: they'll both be MAX_SHORT (because that's the maximum). That's a fairly minor problem...

What I'd be more worried about is why is the value so high? The values that I typically see in my games around around 4000. Really good city sites might be as high as 5000; but MAX_SHORT is 32768. That is not insanely huge, but it's still significantly bigger than I'd expect. So I'd worry that there is a bug somewhere that is causing the values to be much bigger than they should be. I wonder how big the values actually were in your case.

Oh, so that's what it does.

The error only occurred when I used a map size larger (about 30% larger width and height) than the default "huge"..... maybe the extra excess tiles had something to do with it? Guess I'll debug to find out.

EDIT: Does anyone know what controls the rate of Barbarian research/tech acquisition? Looking to let them upgrade their galleys into triremes/caravels automatically sometime during the medieval/renaissance.
 
That that MAX_SHORT assert message come up while you're in the middle of a game, or does it only come up at the very start of the game? I've got a hunch about what the problem is...

The units / buildings that the barbarians are allowed to build (or spawn) are defined in xml\civilizations\CIV4civilizationinfos.xml - which is currently not included in K-Mod because I haven't changed anything there.

In that file, in the barbarian civ section, there are a whole lot of things like this:
Code:
	<Unit>
		<UnitClassType>UNITCLASS_TRIREME</UnitClassType>
		<UnitType>NONE</UnitType>
	</Unit>
Those things are what blocks the barbarians from having those units.

Barbarian tech is handled in CvTeam::doTurn(). Essentially the barbarians tech is designed to lag a bit behind normal civ's tech. (You'll see that I've made some adjustments to the code.)

One thing to watch out for if you enable barbarian caravels is that they'll probably spawn a lot, even into the late game - because there will always be a lot of unseen ocean plots. You might have to adjust the spawn rules to stop that from happening.
 
That that MAX_SHORT assert message come up while you're in the middle of a game, or does it only come up at the very start of the game? I've got a hunch about what the problem is...

At the beginning of the game, during the loading screen.

Barbarian tech is handled in CvTeam::doTurn(). Essentially the barbarians tech is designed to lag a bit behind normal civ's tech. (You'll see that I've made some adjustments to the code.)

One thing to watch out for if you enable barbarian caravels is that they'll probably spawn a lot, even into the late game - because there will always be a lot of unseen ocean plots. You might have to adjust the spawn rules to stop that from happening.

Ah, thanks!

The general idea is to give barbarians something stronger to fight renaissance/industrial era units, since I'm trying to implement/balance a 'tier'ed strength balance system for combat (i.e. an advanced era's units will be significantly stronger than its previous counterparts, similar to how destroyers will make mincemeat out of frigates and ship-of-the-lines..... well, maybe not that extreme).
 
Top Bottom