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

How can I improve turn load times?

Discussion in 'Civ4Col - We The People' started by Icevulture, May 9, 2019.

  1. Icevulture

    Icevulture Chieftain

    Joined:
    Aug 26, 2004
    Messages:
    49
    Location:
    Hamilton, ON
    Great mod. As I get later into a game, around 1650-1700AD, the turn load times start getting quite long. They get progressively worse the longer into a game I am. I've got a 7th gen i7, 16gb ram and an ssd, so thinking hardware isn't the issue. Was most recently playing south america scenario, but this happens with other maps as well.
     
  2. CptBadger

    CptBadger Chieftain

    Joined:
    Nov 3, 2018
    Messages:
    25
    Gender:
    Male
    Idk if it is just my imagination or what, but I recently cleaned out all my old unused save games, and it seems to have made everything ingame run much faster and smoother. Of course I had an insane number of files. But just a thought...
     
  3. FaarmAnimal

    FaarmAnimal Chieftain

    Joined:
    Mar 28, 2019
    Messages:
    56
    16gb ram isn't going to help because the game is 32bit and won't use more than 2gb (4gb if the large address aware flag is enabled - I don't know if it is)

    The game relies a lot on python code, which is slow and inefficient. If you save and reload it should help, but it is an old game and modern hardware is not going to have much of an influence on the way it runs.
     
  4. Hecur

    Hecur Chieftain

    Joined:
    Jun 24, 2017
    Messages:
    52
  5. Jarlaxe Baenre

    Jarlaxe Baenre Chieftain

    Joined:
    Feb 17, 2010
    Messages:
    1,941
    Location:
    Calgary, Alberta, Canada
    There's a 4gb patch that does that.
     
  6. Nightinggale

    Nightinggale Chieftain Supporter

    Joined:
    Feb 2, 2009
    Messages:
    3,987
    It's hard to do anything about it yourself. The "turn load times" isn't actually loading, but rather the AI trying to figure out what to do. It doesn't intuitively know the results of a lot of stuff like human players do and it tries a lot of stuff and calculate on expected result to see if it wants to do that. This means if the colony has a fisherman on a fish, the AI will try to move it to the water plot without a fish each turn, only to figure out that's a bad idea and then not do it.

    The real problem is mainly pathfinding. For each AI unit the AI tries to figure out where to move the unit. The time spend on this increases linearly with the number of units (2 units takes twice the time as one unit). However the time spend on figuring out what to do with each unit increases exponentially with the number of available options. This means it spends longer on each unit for each plot, which is discovered. In late game pathfinding can take up more time than all other tasks combined.

    Without changing the code itself, what you can do is to use a smaller map. If the map is smaller, the pathfinding for each unit will be significantly faster. That's really the only thing you can do in software as a player.

    If you are to invest in hardware, what you need is something, which can look up data really fast. Most of the pathfinding isn't calculations, but rather looking up data. If a unit tries to enter a plot, it has to look up the terrain on that plot, look up the terrain data and unit data to see if the unit can move on the terrain in question, then it looks up stuff to figure out the movement costs etc.

    For hardware this means you want low latency memory. Intel CPUs have faster memory access than AMD for this kind of work. The higher the single core performance, the better.
     
  7. devolution

    devolution Chieftain

    Joined:
    Oct 7, 2016
    Messages:
    241
    Gender:
    Male
    Location:
    Stavanger, Norway
    I agree with what @Nightinggale wrote, pathfinding is indeed the single biggest consumer of CPU time. From profiling I've seen that CvUnitAI::AI_update() per unit approaches of 90% of AI turn time in the late game.

    Other large consumer of CPU time:
    1) AI Job assignment
    2) Plot storm processing
    3) surprisingly enough, achievements on huge maps
    4) The industrialization victory condition, if enabled, often consumes 10% of cpu time by itself.

    I have parallelized 1-4 with some success but that work still has beta status. I have only pushed my work concerning 1) so far: https://github.com/We-the-People-civ4col-mod/Mod/tree/task_parallelism

    The "holy grail" would be to parallelize pathfinding which would require us to replace calls to the "stock" pathfinder (in the EXE) with (most likely) instances of the K-Mod pathfinder. We'd also have to restructure CvUnitAI::AI_update() to allow units to be processes at least partially in parallel. Note that some Civ4 mods like Caveman 2 Cosmos did implement multithreading for unit processing but for various reasons they did not achieve any meaningful improvements in performance. My approach would be a bit different than theirs though and should be able to overcome the issues that they encountered by using several nested levels of task based parallelism.

    I think the main problem that WTP has right now is the lack of active programmers :(
     
  8. FaarmAnimal

    FaarmAnimal Chieftain

    Joined:
    Mar 28, 2019
    Messages:
    56
    It was explored and abandoned due to it being too challenging because of the lack of native multithreading support in the civ iv engine.

    In fairness, C2C is an incredibly OTT mod, so you can understand why they would want to do that.

    FTP is never going to be comparable to that style of mod.
     
    Last edited: May 15, 2019
  9. Hydrok9

    Hydrok9 Chieftain

    Joined:
    Jun 14, 2012
    Messages:
    71
    C2C has a workaround, start a hotseat multiplayer game and set the turns to simultaneous. Set yourself as the only human player. AI will take all its turns at the same time.

    I don't think/know if you can play a scenario that way though, so you might be limited to random maps.
     

Share This Page