CAR Mod: Civ AcceleratoR

stmartin

aka. poyuzhe
Joined
Aug 4, 2007
Messages
640
Location
Shanghai
Civ4 gets slower? Why not drive the CAR?

Welcome to CAR Mod.
This Mod increases BTS's speed by about 15%.


Our main Mod---The History of Three Kingdoms, which is a Mod that reworked everything and added the complex Legion System, became a bit slow.
So we spent countless hour improving its speed.
The result is unbelievable, so we decided to apply our changes to BTS, to share with everyone.

CAR Mod keeps game rules intact, keeps AI ability intact, in fact, keeps everything intact.
You may wonder how we did it. In a word, we exchange high CPU time with tiny piece of extra memory usage.
Technically, we cached those values that AI keeps recalculating, and invalidate that cache value whenever it's supposed to have changed.

The magic number---15% speed increase, is the test result of following experiment:
we run BTS's AD1000 scenario with China, emperor for 90 turns, 5 times using CAR, 5 times using nothing.
The experiment was on a laptop with 1G memory.
The detailed experiment result is in the download package.

Download CAR Mod V0.3​


This mod is available to all players and modders.
For modders who wants to use CAR in their Mod, we don't need any personal credit, just a request:
go play HoTK, and if you happen to love it, put its link in you Mod's readme.
Source Code included.


Credits: xienwolf, EmperorFool, davidallen for providing technical support; jdog5000 for AI Autoplay, which we use for testing.​
 
Will definitely be nice for RoM. We get 2-3 minute turn times in the late game.
 
Will be interesting to see how BBAI compares to your test runs ...

I'd be interesting too, there's only 1 thing: since CAR do not change nothing, so 90turns with CAR and without CAR produce the same high scores, same tech progression, same map reveal and so on, so the test result can only be due to CAR improvement. With BBAI though, if the AI got so smart that they revealed all map within that 90 turns, got a lot more advanced in tech tree, then the result will be biased.
 
very interesting, if the performance enhancement is truly effective it's a great improvement!
As this issue is very important for Rhye's and Fall, too, I'd like to integrate the code.
Is gameplay completely unaltered? For instance, regarding unit upgrating (as you commented out some lines in CvUnit::upgradeAvailable())
 
Excellent effort, great achievement!

" invalidate that cache value whenever it's supposed to have changed."

Was this straightforward enough to know all the occurrences, or does/did it need testing to be sure nothing is lost?
 
Excellent effort, great achievement!

" invalidate that cache value whenever it's supposed to have changed."

Was this straightforward enough to know all the occurrences, or does/did it need testing to be sure nothing is lost?

Thanks!

What you have pointed out is the only risk of the unaltered gameplay standard. What we do is to examine the function calls that we cache carefully, and do our best to put the invalidate code everywhere it should be. However, we are not machines, so I'm sure there will be places we missed. Since now the source code is available to the public, all the great modders' eyes would help catch these missing pieces sooner, I hope.

However, it's pretty safe to say nothing significant is missed. Because in our test runs, after 90 turns, the score distribution, tech progress and map reveal situations in both CAR and non-CAR game are almost identical.
 
thank you, thank you thank you!

its so nice to know that there are modders who publish their work for the better of us all.


great work all of those who participated.


p.s.

as one of the veteran modders on the site,

hotk, is one of the most unique beutyfull mods ever to be made.
 
This is great how would i integrate it with a mod thats already been made. (mostly)
I'd love to use this for the star wars mod.
 
thank you, thank you thank you!

its so nice to know that there are modders who publish their work for the better of us all.


great work all of those who participated.


p.s.

as one of the veteran modders on the site,

hotk, is one of the most unique beutyfull mods ever to be made.

Thanks Keldath, I still remember the days when I sit in front of my computer and admire Visa.

PS. I didn't publish for the better of us all, I just did it to let more players know HoTK. For the better of us all is a side effect.

:lol:


This is great how would i integrate it with a mod thats already been made. (mostly)
I'd love to use this for the star wars mod.


If star wars Mod uses it's own dll, merge it with CAR's dll. If not, just use CAR's dll.
 
Thanks, I think you've done an amazing job for "the good of us all".
 
I'm working on merging source files of your cool CAR and RevDCM. Can you tell me which source files precisely that have all changes relevant to your CAR? Because when I downloaded your source, you had STARTLING number of files. Also, RevDCM already modded many vanilla BtS settings in its source.

After I'm done with merging, I plan on uploading it to RevDCM thread and RoM forum.

Your speedy help will be HELPFUL! :D
Thanks!
 
Is CvTeamAI.cpp only file that you modded? Or are there more?

Thanks :).
 
Is CvTeamAI.cpp only file that you modded? Or are there more?

Thanks :).

Much more. Search for "sanguo" in the files (Notepad++ has a nice search function that searches every file in a folder); there are like 108 places where some code is changed ;)

Just don't use winmerge; there are so many places where just some tab disappeared that it seems that all the file was changed, when in fact it's just graphic. If someone knows a way to make winmerge ignore all the spacing and tabs I'd be glad to here that btw.
 
Is CvTeamAI.cpp only file that you modded? Or are there more?

Thanks :).

You surprise me.

Here's a list:

CVDeal.cpp
CvGame.cpp
CvInfo.cpp
CvInfo.h
CvPlayer.cpp
CvPlayerAI.cpp
CvPlayerAI.h
CvTeam.cpp
CvTeamAI.cpp
CvTeamAI.h
CvUnit.cpp
CvUnitAI.cpp

These are for v0.2. future versions will change. So if would help if you could find out by searching all files in the source with 'Sanguo' keyword.
 
hopefully, you or someone could make civ 4 somehow became multi-core supported. With that support, some of us will no longer feel this terrible lag any more... or see a single hint of lag.
 
Top Bottom