TechCost mod

jdog5000

Revolutionary
Joined
Nov 25, 2003
Messages
2,601
Location
California
Tech Cost Mod
Version .5
By jdog5000

The goal:

In many of my games, I start to pull away with a large tech lead in the Renaissance. Sometimes Mansa Musa can hang with me, but otherwise the game is effectively over. Instead of just raising the difficulty, I decided to experiment with dynamic tech costs. The idea is that technology diffuses, particularly in the modern era, and that should lower the cost for civs catching up.

How it works:

Basically, whenever a civ acquires a new technology, the cost of that technology decreases for all the other civs. The formula is scaled linearly by tech era, with no effect on ancient techs but cost of techs in the modern era can decrease up to 40%. Future techs are never discounted. Currently, the maximum discount is multiplied by the fraction of civs who have discover the tech to the 1.6 power. So when one civs learns the tech, the cost only drops a small amount. Once half the world knows it, the cost for the laggers is much lower. There is also a factor that reduces when there are a small number of civs (when 1 of 3 civs know (barbarians count), the effect is much smaller than when 6 of 18 know). In the mod folder is a excel spread sheet that models the effect of the reduction for all the eras and % who know, with the variables used in the mod easy to manipulate and then change in TechCost.py.

Why a DLL?

Certainly doing whatever is possible in Python alone is a noble cause, but I don't believe all that I'm aiming for can be acheived in Python. The issue was that there's no method for modifying the cost of a tech, and clearly a changing tech cost was not part of the Civ 4 setup. Many functions retrieve tech cost directly from the c++ side of the game, for example in the TechConquest Mod, Bhruic uses the following lines:

pNewTeam = gc.getTeam(city.getOwner())
iTechCost = pNewTeam.getResearchCost(lTechDiff[iRandTech])

Or, in the tech chooser popup:

szTechString += str(gc.getPlayer(g_civSelected).getResearchTurnsLeft(i, ( gc.getPlayer(g_civSelected).getCurrentResearch() == i )))

I believe for these to return the proper result, the value returned by the C++ getResearchCost function has to be modified.

That being said, you could acheive most of the results by simply giving civs free beakers when they start a tech that many people already have. However, the appropriate costs won't be displayed when choosing techs, and this may affect the choices of the AI. Plus, it would be hard to handle the case where you researched a tech for one turn, then switched for a long time, then came back after many others had gotten it.

What the DLL does:

Creates one new member variable for CvTechInfo, the modified research cost. Changes getResearchCost() to return this variable, and creates setModResCost(int) and getOrigResCost(). All of the modifications to tech cost occur in Python. Since the modified research cost is initialized to the original, if you never modify it the cost never changes.

Potential mod side effects:

With this model, costs decrease for civs that have never met. While the decrease doesn't start until the classical era, and then is never more than ~8%, it seems this would decrease the potential tech divide when you find a "new world." Future versions may attempt to take into account the time since first discovery, which would also help solve the next issue.

While unlikely, there is potential for a strange race condition with the current implementation. If several civs finish a tech at nearly the same time, the cost for the last will be significantly lower for the last civ even if the others just got it the turn before. While unlikely in a game that starts in the Ancient Era, this could cause issues for games starting in the Middle Ages or later and is therefore not recommended for those situations.

Finally, the effect of this on the state of Barbarian research is unknown. They don't do normal research, but it could mean non-obsolete units on say a Terra map. Results similar to sugar pill.

Installation:

Unzip TechCost.zip and move to your Mods folder. The new DLL will load instead of the original one. Haven't tried putting it in the My Documents one, don't know if there are issues with that.

Note to fellow modders:

Python events handled using Dr_Elmer_Jiggles custom event handler. All changes in the C++ source code are commented with // ------ TECH_COST_MOD start ----------
and // ------ TECH_COST_MOD end ----------
Sources are attached.

TechCost.zip

View attachment TechCost_sources.zip
 
Hey, this sounds like a FANTASTIC MOD, and will go quite well with the TechConquest mod. Have you considered the following tweak though?

Instead of an automatic reduction in tech cost for ALL civs, maybe you should tie the cost reduction to those civs with whom the tech leader has trade routes. That way a civ on the other side of the world, with no contact with the leading civ, will be much further behind those civs with whom the leader has regular contact. Think of it in terms of Europe vs South/Central America in the 15th-16th centuries.

Yours,
Aussie_Lurker.
 
I have definitely considered something along those lines ... was thinking small benefit for contact, med benefit for potential trade, large benefit for active trade, and maybe even a med benefit for war (you'll certainly be seeing plenty of the opposing civ). It makes things more complicated, as each civ then has its own cost for each tech and the cost changes with several additional factors. Would probably have to be updated every turn instead of on tech acquired. It would certainly up the realism factor!

Anyway, glad you like the idea! I intend to make changes based on how it plays out ... and this is certainly on the list.

Cheers,
J
 
Why isn't there a CvModName file??
Also, can it be moddable to change the decreasing % of research so that, say, it drops by 10% whenever a new civ discovers it, up to a maximum of 50%?
 
Interesting mod, the technique of changing the cost querry means that its limited to a global effect, I am not shure Aussies idea would even be implementable without some major reworking of the Python UI, functions would need to be changed to take a Player input in addition to the Tech enum. I ran into a similar problem when doing UU for leaders.

I think a possible solution to the "several discoreryies = very sudden price drop" would be to add up the % completion of each Civ and plug that floating point total into the equation rather then an int. So each each Civ inches up turn by turn the cost drops turn by turn without any sudden movment.

Also the 1.6 power, could this be taken from a new Global define to allow people to control the strength of the bonus. Any other magic numbers involved should also be put in global defines.

I see you have done several well recived SDK mods, have you considered joining up with the Civ4 CoreCommunity Project. Were aiming to create a mega combined mod DLL for universal play, all the mods being optional and as easily configured in XML and Python as possible. Quality mods like this would likley get targeted for inclusion regardless but merging is a time consuming process (and ever more so as our DLL acumulates many changes and you cant just fire up win-merge and Alt-> Alt-> everything in). If you join up and get access the the SF CVS repositor you can write the mod directly into the combined DLL and all the merging is avoided. I could possibly merge this mod in but I too crave making my own stuff.
 
yeah I had the same problem in tech research... I would beat most civs where they would not be competitive...


I think I might want to use this mod component in the mod I am developing...

I have some questions...

does the mod work in MP?

how difficuit would this mod be in merging with another mod?

The mod I am developing (in playtesting) is basically XML modded (less Out of Sync errors in MP :rolleyes: ) but here are some minor Python modding...



is it me or the link doesnt work anymore? :mischief:
 
Fachy said:
Why isn't there a CvModName file??
Also, can it be moddable to change the decreasing % of research so that, say, it drops by 10% whenever a new civ discovers it, up to a maximum of 50%?
In this case there's no need for a CvModName file as there is no config file and therefore no need for the mod to find anything in its own folder (all the python files are loaded automatically, the ini has to be found). Check out the included excel spreadsheet, mess with the different values in there until you get the graph you're looking for, then change the values in the python code ...
 
Officer Reene said:
yeah I had the same problem in tech research... I would beat most civs where they would not be competitive...


I think I might want to use this mod component in the mod I am developing...

I have some questions...

does the mod work in MP?

how difficuit would this mod be in merging with another mod?

The mod I am developing (in playtesting) is basically XML modded (less Out of Sync errors in MP :rolleyes: ) but here are some minor Python modding...



is it me or the link doesnt work anymore? :mischief:
It should work in multiplayer, but everyone would need the new dll etc. I haven't tried it though, so let me know if you test it out.

It should be simple to merge with a mostly XML mod ... just drop the XML folder into this mods folder and you should be on your way.

And the link seems to work for me ... :confused:
 
Impaler[WrG] said:
Interesting mod, the technique of changing the cost querry means that its limited to a global effect, I am not shure Aussies idea would even be implementable without some major reworking of the Python UI, functions would need to be changed to take a Player input in addition to the Tech enum. I ran into a similar problem when doing UU for leaders.

I think a possible solution to the "several discoreryies = very sudden price drop" would be to add up the % completion of each Civ and plug that floating point total into the equation rather then an int. So each each Civ inches up turn by turn the cost drops turn by turn without any sudden movment.

Also the 1.6 power, could this be taken from a new Global define to allow people to control the strength of the bonus. Any other magic numbers involved should also be put in global defines.
This idea seemed to kind of fall flat when I first released it a few months back, so I just moved on to other things instead of going back and making easily configurable settings once I got more modding experience :) ...

I'm contemplating making a new version, as I don't like leaving around such obvious trouble cases as the "several discoreryies = very sudden price drop" ... your idea could work, but I was thinking something along the lines of what Aussie suggest could be done by, instead of changing a tech's cost, giving each civ a little research credit if they're friends with someone who already knows the tech. It does have the downside that the turns to completion will not always be true, as you may be getting a little boost when researching known techs, but it would solve the other issues and not even require the SDK ... it'd be kind of like a non-violent version of the tech from conquest mod :p

Anyway, when I get back to this idea, I'll definitely include a config file.

Impaler[WrG] said:
I see you have done several well recived SDK mods, have you considered joining up with the Civ4 CoreCommunity Project. Were aiming to create a mega combined mod DLL for universal play, all the mods being optional and as easily configured in XML and Python as possible. Quality mods like this would likley get targeted for inclusion regardless but merging is a time consuming process (and ever more so as our DLL acumulates many changes and you cant just fire up win-merge and Alt-> Alt-> everything in). If you join up and get access the the SF CVS repositor you can write the mod directly into the combined DLL and all the merging is avoided. I could possibly merge this mod in but I too crave making my own stuff.
Thank you for the invitation :)
 
jdog5000 said:
It should work in multiplayer, but everyone would need the new dll etc. I haven't tried it though, so let me know if you test it out.

It should be simple to merge with a mostly XML mod ... just drop the XML folder into this mods folder and you should be on your way.

And the link seems to work for me ... :confused:

nope the TechCost.zip doesnt work for me :sad:


EDIT: finally got the link to work *Hooray*
 
dont know if anyone is using this...

but it DOES work in MP...

(well up to rifling so far)

I am playing over LAN

2 Human players 11 AI players

Prince Level

Civ4 original version (not warlords)

The only thing is that I dont notice that much of a change in Tech cost when other CIVs discover techs


The human players are lagging behind in techs while the top 4 AI's are creaming us!

For example the human players just got Musketmen while the top 4 AIs have infantry!

that's a big jump and gap in tech advancement

Note the human players are in them middle of the 13 civs... but the lower civs are even more primative!


any way to lower the tech cost once a tech is discovered? (lower than default that is) :confused:


or is the tech mod not working?
 
Officer Reene said:
dont know if anyone is using this...

but it DOES work in MP...

(well up to rifling so far)

I am playing over LAN

2 Human players 11 AI players

Prince Level

Civ4 original version (not warlords)

The only thing is that I dont notice that much of a change in Tech cost when other CIVs discover techs


The human players are lagging behind in techs while the top 4 AI's are creaming us!

For example the human players just got Musketmen while the top 4 AIs have infantry!

that's a big jump and gap in tech advancement

Note the human players are in them middle of the 13 civs... but the lower civs are even more primative!


any way to lower the tech cost once a tech is discovered? (lower than default that is) :confused:


or is the tech mod not working?
Good to know it works in multiplayer, thanks for the report.

The formula used doesn't reduce costs much after a single team discovers a tech, but reduces costs substantially for later game techs that have been discovered by a few players. To check if it's working, just before you discover a tech, open the Tech Advisor and check how much the tech costs, and compare this to what it costs after you discover it.

Unfortunately, the only way to adjust the mechanisms of the mod is to edit the Python file. I intend to update this component when I'm finished with some other projects.
 
jdog5000 said:
Good to know it works in multiplayer, thanks for the report.

np.... I like to keep an eye out for mod components that work in MP...
I may use this one in my mod (if I ever release it :crazyeye: ) giving you credit of course :goodjob:

some odd stuff in MP:

unsure if your mod affects it... but since your mod is the only SDK/python that I use (which effects gameplay - my changes are XML only)

there are times when combat units (during/fight) seem to "run off" screen whether they win or lose... it doesnt seem to affect gameplay (the unit is still in the stack after combat is over and if they win :lol: )

when buildings/units are created the city bar does not update unless you go to next turn or "zoom in" on to city screen...

unsure if this is related to your mod... but I'd thought I report it...

(hopefully it doesnt lead to OOS:mad: )

the only major change in respect to units and combat... I only change ALL units to 1 single unit in the XML files (mesh taglines and such)

this may effect the "run off screen" thingy but Im not sure since single units have existed (and I copied that format) in the vanilla version...



jdog5000 said:
The formula used doesn't reduce costs much after a single team discovers a tech, but reduces costs substantially for later game techs that have been discovered by a few players. To check if it's working, just before you discover a tech, open the Tech Advisor and check how much the tech costs, and compare this to what it costs after you discover it.


hhmmm I'll keep an eye on this :mischief:


jdog5000 said:
Unfortunately, the only way to adjust the mechanisms of the mod is to edit the Python file. I intend to update this component when I'm finished with some other projects.


damn... since I dont know crap about python and SDK (except that python gameplay changes for the most part cause OOS errors :crazyeye: ) I guess I'll have to wait...:p


thx for the help ;)
 
Officer Reene said:
some odd stuff in MP:

unsure if your mod affects it... but since your mod is the only SDK/python that I use (which effects gameplay - my changes are XML only)

there are times when combat units (during/fight) seem to "run off" screen whether they win or lose... it doesnt seem to affect gameplay (the unit is still in the stack after combat is over and if they win :lol: )
I used to get this in Vanilla before 1.61, but next recently ... it certainly is pretty funny. I think there are some screen shots of units running across water in an old humorous screenshots thead.

Officer Reene said:
when buildings/units are created the city bar does not update unless you go to next turn or "zoom in" on to city screen...
Never seen this, but I'll keep an eye out. Doubt it's related to this mod though ...
 
jdog5000 said:
I used to get this in Vanilla before 1.61, but next recently ... it certainly is pretty funny. I think there are some screen shots of units running across water in an old humorous screenshots thead.


yeah it's funny and it doesnt affect gameplay :D (I think)


jdog5000 said:
Never seen this, but I'll keep an eye out. Doubt it's related to this mod though ...

started a new game (played the last one until 1910...besides the lag and other previously mentioned oddities :mischief: tech mod work fine in MP:goodjob: )


I started watching tech costs....and yeah it's working in MP :)


My brother an I can see the tech cost changes :p


I'll keep ya posted if I discover anything else... or not ;)
 
Now it seems I my civs are behind the curve....

I start out more advanced... but then when I reach gunpowder some other civs (usually the top 3 civs)

this wouldnt be a big issue...

except that the AI's now beat me to almost all the later wonders

I dont even have a chance!:mad:


is there a way to greatly reduce the tech discovery cost (let say 50%-75%) when the tech is discovered originally? :confused:

this way it would be more competitive for ALL civs (because the other AI civs, besides the top tier civs, are woefully behind too! :mad: )

I find usually 1 or 2 civs competitive while the rest are not even close...

this would not be bad if it happened with the modern techs, but when there is a huge difference in tech advancement at gunpowder where one civ has infantry and the rest only start to have musketman (yes musketman :eek:) is just plain crazy!

I think that tweak in discovery cost reduction would greatly reduce my problem!

FYI I am playing in Prince level and not the expansion version (using 1.61 patch)


Note: On a separate matter I am not experiencing the weird graphics as posted before... at this time :lol:
 
I intend to completely rework the concept behind this at some point. My new thought is to have the cost drop based on how long the technology as been around and who knows it ... by the end of the game, things that had been known for 30-40 turns might be half price, so no one's too far behind.
 
jdog5000 said:
I intend to completely rework the concept behind this at some point. My new thought is to have the cost drop based on how long the technology as been around and who knows it ... by the end of the game, things that had been known for 30-40 turns might be half price, so no one's too far behind.


any idea how long that's gonna take? :mischief:
 
Top Bottom