1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

CAR Mod: Civ AcceleratoR

Discussion in 'Civ4 - Modpacks' started by stmartin, Aug 18, 2009.

  1. stmartin

    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.​
     
  2. Agent327

    Agent327 Observer

    Joined:
    Oct 28, 2006
    Messages:
    16,052
    Location:
    In orbit
    Seems ideal for FF mods. Will have a look definitively. :goodjob:
     
  3. PieceOfMind

    PieceOfMind Drill IV Defender Retired Moderator

    Joined:
    Jan 15, 2006
    Messages:
    9,312
    Location:
    Australia
    Looks great!

    Can't wait to merge this into my mod. :goodjob:
     
  4. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    Will definitely be nice for RoM. We get 2-3 minute turn times in the late game.
     
  5. jdog5000

    jdog5000 Revolutionary

    Joined:
    Nov 25, 2003
    Messages:
    2,601
    Location:
    California
    Will be interesting to see how BBAI compares to your test runs ...
     
  6. stmartin

    stmartin aka. poyuzhe

    Joined:
    Aug 4, 2007
    Messages:
    640
    Location:
    Shanghai
    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.
     
  7. Rhye

    Rhye 's and Fall creator

    Joined:
    May 23, 2001
    Messages:
    9,468
    Location:
    Japan / South America
    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())
     
  8. stmartin

    stmartin aka. poyuzhe

    Joined:
    Aug 4, 2007
    Messages:
    640
    Location:
    Shanghai
    I commented out those lines because the upgrades available are already cached in each CvUnitInfo.
     
  9. avain

    avain (key)

    Joined:
    Jul 29, 2006
    Messages:
    2,770
    Location:
    Budapest, EU
    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?
     
  10. stmartin

    stmartin aka. poyuzhe

    Joined:
    Aug 4, 2007
    Messages:
    640
    Location:
    Shanghai
    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.
     
  11. keldath

    keldath LivE LonG AnD PrOsPeR

    Joined:
    Dec 20, 2005
    Messages:
    6,294
    Location:
    israel
    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.
     
  12. civ editor11

    civ editor11 Ruler

    Joined:
    Jan 24, 2009
    Messages:
    999
    Location:
    U.S.
    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.
     
  13. stmartin

    stmartin aka. poyuzhe

    Joined:
    Aug 4, 2007
    Messages:
    640
    Location:
    Shanghai
    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:



    If star wars Mod uses it's own dll, merge it with CAR's dll. If not, just use CAR's dll.
     
  14. civ editor11

    civ editor11 Ruler

    Joined:
    Jan 24, 2009
    Messages:
    999
    Location:
    U.S.
    Thanks, I think you've done an amazing job for "the good of us all".
     
  15. keldath

    keldath LivE LonG AnD PrOsPeR

    Joined:
    Dec 20, 2005
    Messages:
    6,294
    Location:
    israel
    visa...:)


    a good side effect then :))
     
  16. os79

    os79 Chieftain

    Joined:
    Mar 14, 2009
    Messages:
    3,067
    Location:
    Eastern USA Coast
    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!
     
  17. os79

    os79 Chieftain

    Joined:
    Mar 14, 2009
    Messages:
    3,067
    Location:
    Eastern USA Coast
    Is CvTeamAI.cpp only file that you modded? Or are there more?

    Thanks :).
     
  18. JujuLautre

    JujuLautre Chieftain

    Joined:
    Apr 9, 2007
    Messages:
    3,112
    Location:
    Kansai, Japan
    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.
     
  19. stmartin

    stmartin aka. poyuzhe

    Joined:
    Aug 4, 2007
    Messages:
    640
    Location:
    Shanghai
    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.
     
  20. darkedone02

    darkedone02 The Suggestor

    Joined:
    Mar 9, 2006
    Messages:
    1,728
    Location:
    Louisville, Kentucky
    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.
     

Share This Page