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

Supply & Stacking

Discussion in '[MAC+WIN] Civ4 - History Rewritten' started by Civ4Gandalf13, Aug 10, 2019.

  1. Civ4Gandalf13

    Civ4Gandalf13 Warlord

    Joined:
    Sep 8, 2015
    Messages:
    116
    One of the issues that has arisen a number of times over the years has been stacking and supply. As to supply, there are no supply requirements for military units. They can trapse across the known (and unknown) world and suffer no effects from being thousands of miles from their home Country . Seriously unrealistic and detracting from the playability of the game. As too stacking, any Civ player with any experience has faced the "Stack of Doom" with 80 some odd units stacked in a single tile bearing down on a single hapless City. This effect is not only unrealistic - it is down right depressing fro ma playablity perspective. I have even suffered a Stack of Doom from a Country of only three Cities which never should have been allowed to accumulate so many units - such a small Country should not have been allowed to support them.

    I play tested war games (board and computer for several decades some time ago and decided to apply that experience to dining a solution for these two issues for Civ. War games usually have very complex rules concerning supply but very simple rules concerning stacking.

    To address the issue of supply, I used the general rule that any older units that were not gun powder units (i.e., allowed to be built in the Ancient/Classical/Medieval Eras) could essentially live off the land - as they did in the real world. The primary problem with supply was transportation - getting the supplies to the troops. Once the Renaissance Era was reached, I created a new unit that was a Horse Supply Unit. It had a movement factor of two but essentially no defense strength (like workers/settlers). The supply range of a Horse Supply Unit was 8 tiles from the nearest friendly border. Friendly units who were up to 8 tiles away from the (and stacked with a Horse Supply Unit would be deemed in supply (Horse Supply Units could not provide supply to Armor/Mechanized/Motorized units). For units that were built after the discover of the Automobile, I created a new Motorized Supply Unit with a movement factor of three and also no defense strength. Friendly units who were up to 12 tiles away from the nearest friendly border were (and stacked with a Motorized Supply Unit) would be deemed in supply. If a Supply Unit was lost or separated from the stack, that stack was automatically considered out of supply and suffered the consequences - being that any unit that was out of supply had their movement factors reduced by one and their combat factors halved (rounded up). Supply routes could not be traced across lake or mountain or desert hexes. Any units that captured a hostile City were automatically deemed back in supply if the captured City was not blockaded and a route could be traced back to a friendly coastal City. All Scout/Recon/Commando units were exempt from any supply requirements. All Paratrooper units were automatically in supply for two turns.

    To address the issue of stacking, after much experimentation, I arrived at the following limits for each stack of units in a tile: 10x line units (warrior/spear/sword/musket/rifle/infantry/motorized infantry/mechanized infantry), 4x mobile assault units (cavalry/armor/modern armor), 4x siege/artillery units (ram/catapult/bombard/cannon/artillery/motorized artillery/mechanized artillery), 4x support units (AT/SAM), 2x recon units (Scout/Explorer). This general rule took away the problem of the "Stack of Doom" but still allowed large attacks by forcing the players/AIs to use multiple tiles. Much more realistic

    As related in a concurrent post, for the last several years I have play tested a number of my suggestions (including the additional food/commerce/culture and negative culture) for approximately 40 games. I used World Builder to implement each game change for each turn (for me as a player and for the AIs), which became quite tedious at times. However, the work paid off in the long run. I had no AI problems (although the changes had not been programmed in but were manually inserted each turn) but much more important was that the game became more playable and realistic and much more interesting with no added significant frustration (or cursing at the game) because of the impossibility of stopping a "Stack of Doom" or helplessly watching a stack of hostile units unrealistically run rampant through the countryside destroying your carefully and lovingly built empire even though they realistically should not have been able to do so without supply.

    Testing was easy - I did so with voluntary limits I used World Builder to chop AI "Stacks of Doom" down to size and move them back when they exceeded their supply range It was tedious but the testing was successful

    Stack limits can be easily implemented (in the same way that certain units are forbidden from entering certain tiles - instead of a terrain limit place a number limit on the units allowed in enter the tile. Supply limits are also easy because an AI algorithm could be made that simply observes whether a unit would be out of supply if it entered a tile and not implement such a move. If a Supply Unit was lost, the AI could then decide to either return to friendly borders or bring up another available Supply Unit.

    Thoughts anyone?
     
    The 13th Earl likes this.
  2. Xyth

    Xyth History Rewritten

    Joined:
    Jul 14, 2004
    Messages:
    4,052
    Location:
    Aotearoa
    Stacking

    This is something modders have been trying to address ever since Civ4 first launched. I've not seen any particularly successful implementations, but I've not looked for ages. The AI changes necessary would be absolutely massive, unless someone has found some clever shortcuts. Far beyond my capabilities.

    Supply

    There is a very simple unit supply mechanic in game already but it's a just an increase in unit maintenance and only considers whether units are in friendly territory or not. Expanding/improving this mechanic would probably be the best way to go for something like this. To do it via actual units would be even more complicated than unit stacking limits, AI-wise.
     
    The 13th Earl likes this.
  3. Civ4Gandalf13

    Civ4Gandalf13 Warlord

    Joined:
    Sep 8, 2015
    Messages:
    116
    Would you give me a brief review of the AI changes for Civ4 and HR that have been implemented? Does Civ4/HR use any particular base AI program? Counting the number of tiles a unit is in enemy territory or the number of types of units in a hex does not appear to be difficult. It seems I might have to try and update my computer degree - I have obtained a few books on AIs. Also, what langaue is Civ4 and HR written in? Thanks.
     
  4. DarkLunaPhantom

    DarkLunaPhantom Prince Supporter

    Joined:
    Feb 4, 2013
    Messages:
    417
    The bulk of Civ4's AI code is contained in several C++ source files that can be found in CvGameCoreDLL folder, namely in:
    Spoiler :
    Code:
    CvCityAI.cpp
    CvGameAI.cpp
    CvPlayerAI.cpp
    CvSelectionGroupAI.cpp
    CvTeamAI.cpp
    CvUnitAI.cpp
    

    In HR these files collectively have over 70.000 lines of code.

    That's trivial, but also irrelevant. Real challenge with limiting unit stacking or limiting unit movement based on availability of supply is the AI and writing new AI code to accommodate that would be an immense undertaking.

    C++, Python, and XML.
     
    Last edited: Aug 15, 2019
  5. Civ4Gandalf13

    Civ4Gandalf13 Warlord

    Joined:
    Sep 8, 2015
    Messages:
    116
    Hi DarkLunaPhantom. Thanks for joining the discussion. I take it you are an experienced Civ4/HR modder? Are you still active or just a player?

    Thanks for the info on the AI. 70,000 lines of code is rather daunting. Let me ask for some clarification/explanation.

    Does the Civ4/HR AI operate from a central controlling routine or do the various AI tasks operate independently from each other? Could you identify what particular aspect of the AI each of the Civ/HR folders you identified control/execute. I am trying to get a handle on the way the AI operates.

    Also, is there an overall flowchart or diagram which illustrates how the AI operates? Many decades ago I did a little programming and did some systems analysis. I am probably going to try and dust off those old skills. Thanks
     
  6. DarkLunaPhantom

    DarkLunaPhantom Prince Supporter

    Joined:
    Feb 4, 2013
    Messages:
    417
    If you are serious about wanting to learn about Civ4 modding there are 2 things you should do.
    1) Setup an environment for modding by downloading required/recommended software (visual studio, notepad++, etc.) and test it by compiling the DLL for either BTS or the mod you are interested in. Various guides for this are available on the modding subforum.
    2) Try to implement a simple change, e.g. have the game spawn a barbarian warrior near every newly founded city or something like that.

    Game's code is simply too large and convoluted to be presentable in a flowchart form with enough details for this representation to be at all useful. Modders often simply use Notepad++'s "Find in Files" search function when they want to locate code which deals with something specific they are interested in since largest single source code files have dozens of functions and more than 20.000 lines of code.

    I could answer these, but this is not really going to help you. To be able to mod AI you first need to have the ability to compile, search and edit source code. At that point, when you are able to read the code and implement some changes, you will be able to ask the right questions and then other people might be able to point you in the right direction or help you with something.
     
  7. Civ4Gandalf13

    Civ4Gandalf13 Warlord

    Joined:
    Sep 8, 2015
    Messages:
    116
    Thanks for the directions. Many decades ago I had a course in Assembly language but I guess that it is a bit dated now .....

    I am not familiar with either Notepad++ or Visual Studio. What are their basic functions? Must I purchase them or are they free on line?
    I use Windows 7 - is that sufficient as an OS for these other programs?

    What are the hardware requirements for this software? What about of RAM and disc memory will I need?
     
  8. Civ4Gandalf13

    Civ4Gandalf13 Warlord

    Joined:
    Sep 8, 2015
    Messages:
    116
    Thinking about what you said about the size of the code and the enormity of the files, it makes me realize how difficult the coding must be without a managable flow chart to reference. Missing one piece of code relevant to the mod in the search of the files could make the entire mod fail making debugging it a herculean task. Makes the COBOL and FORTRAN programs I used to write seem like basic grammar. LOL
     
  9. Xyth

    Xyth History Rewritten

    Joined:
    Jul 14, 2004
    Messages:
    4,052
    Location:
    Aotearoa
    The AI is pretty much the most formidable aspect of Civ4 modding and really not the best place to start. I've been modding Civ4 since 2010 and I'm still mystified by a lot of it. My advice would be to get used to working with the XML first, then the Python API. You have a lot of cool ideas for Events and that is all that's needed to make those. Furthermore, both the XML and the Python API are defined by the DLL (where the AI is) so learning these is an important step on the way to understanding the structure of all that anyway.
     
    DarkLunaPhantom likes this.
  10. Civ4Gandalf13

    Civ4Gandalf13 Warlord

    Joined:
    Sep 8, 2015
    Messages:
    116
    Understood.Could you help with my previous questions about cost and locations (free or purchase) of the progams DarkLunaPhantom recommended? Also,the hardware requirements?
     
  11. Xyth

    Xyth History Rewritten

    Joined:
    Jul 14, 2004
    Messages:
    4,052
    Location:
    Aotearoa
    All you need is a good programmer's text editor. NotePad++ is free and seems to be the go-to for Windows users. I'm on Mac and am currently using Atom, which is cross platform (and BBEdit which is not). As for hardware, if it's good enough to run Civ4, it's good enough to mod it.

    If or when you want to start compiling the DLL you'll need more software, and there is a good guide to that here. You don't need any of that if all you want to do is explore the DLL source files though. That can be done in your text editor.
     
  12. Civ4Gandalf13

    Civ4Gandalf13 Warlord

    Joined:
    Sep 8, 2015
    Messages:
    116
  13. eysteinn

    eysteinn Chieftain

    Joined:
    Jul 11, 2018
    Messages:
    11
    I like the stacks of doom. Its what sets this apart from civ5 and 6. There is a lot of satisfaction in positioning your armies to where they wipe out invading doomstacks and then the enemy is open to counter invasion. It takes planning and strategy to win. I would rather face 1 doomstack than chase dozens of lone units running around, and you could probably cheese an ai that did that.
     
    cobbaut and DarkLunaPhantom like this.
  14. Civ4Gandalf13

    Civ4Gandalf13 Warlord

    Joined:
    Sep 8, 2015
    Messages:
    116
    It might be satisfying to wipe out a stack of 60 units, but it flies in the face of even quasi-reality. If my suggestion was adopted, you would not be chasing dozens of lone units around. Each tile could hold a more realistically sized army, balanced around the various different types of units with a max of approximately twenty units a stack..
     
  15. Civ4Gandalf13

    Civ4Gandalf13 Warlord

    Joined:
    Sep 8, 2015
    Messages:
    116
    One aspect of my Supply Proposal I forgot to include in the original post was that there should be a new naval unit called a Cargo Ship. Any naval unit that is outside friendly ocean tiles for more than ten turns is out of supply (half combat/movement) unless it has a Cargo Ship stacked with it.
     
  16. Zeta Nexus

    Zeta Nexus Deity

    Joined:
    Jan 23, 2014
    Messages:
    3,495
    Gender:
    Male
    Location:
    In a constant brainstorm...
    Just a little side note on the supply issue:
    AND2 has successfully implemented a movement limit. Read more here if you are interested: Movement limits in early eras
     
  17. Civ4Gandalf13

    Civ4Gandalf13 Warlord

    Joined:
    Sep 8, 2015
    Messages:
    116
    Thanks for the heads up. I will read it.

    On the issue of movement itself, one of the ideas I had come up with was a new schedule of movement. The general rates were:
    1 MP for foot units
    2 MP for horse units
    3 MP for motorized units
    4 MP for mechanized/armor units (5 MP for German panzers due to blitzkrieg tactics)
    I also extended the drop range for parachute units to 8 tiles to more accurately reflect the actual range in WWII - for example, US paratroops flew from Great Britain to North Africa to drop during Operation Torch.
    The movement of naval units was also problematic with naval units being limited to the same movement as certain ground units. I played with using base movements of:
    5 MP for sail ships
    10 MP for powered steel ships
    I just could not accept movement rates of sailing ships being the same as movement rates of battleships or cruisers.
     

Share This Page