Limiting Stacks of Doom

SilencerNate

Chieftain
Joined
May 12, 2010
Messages
9
I've been playing FFH now for a few weeks, and love the mod. However, even with a decent gaming rig, on huge maps with 20+ AIs, the thousands of units nearly bring me to a halt, and I'm not even going to comment on multiplayer out of syncs.

I'm beginning to believe the problem lies in a combination of two elements.

1) The AI moves together
2) The AI builds zergs



If you play vanilla civ, then FFH, one thing I noticed was that the AI worked as a human player might. In effect, after the beginning of a new turn, within a few seconds, it would move its units, and operate normally. In FFH, I noticed that instead, the game will freeze momentarily while all AIs move as a single force, after which the human(s) may move.

If these changes were intentional, I'm curious why they were changed. Otherwise, it would be great to have them reverted to vanilla.


Secondly, we've all seen the massive stacks of doom on defense. I understand the creators wanted to prevent player-side SoDs, but I ran into an AI city awhile back with 177 units defending. 77 units I feel would be borderline too much, but 177 is just impossible to imagine. Worse yet, they make cities nigh impossible to conquer.

I assume that short of modifying the AI behavior a lot, which could be a lot of work, there's no simple fix for curing the AI creating hundreds of units. However, a search did turn up a possible solution so that might curb the problem.

JUnitSpace
http://forums.civfanatics.com/showthread.php?t=276637

In a nutshell, it limits the amount of units on a tile at any given time. Higher limits can be set for certain conditions, such as tile has a city. So defense of cities could be set higher, as they should be for example.

I would think that stacks of 10 could be a cap, and 20 maximum for cities. Note that the mod does not affect AI behavior at all, so the zerg army would still be present, but instead of being in a city fortified, the AI would be forced to move it elsewhere. I assume it would either roam defend its borders, or it would act more aggressively, and use the excess units to attack.

Either way, it would lower the overall amount of units moving each turn, and would encourage smaller, higher promoted strike forces rather than hundreds of units clogging bandwidth.


I'd love if someone could incorporate some of these changes into FFH. If the creators wanted to go a different path, this could be a great modmod. At the very least, although I have 0 experience doing any mod work myself, if someone could point me into the direction how I could make these changes myself, I would do the legwork myself.
 
This might also be placed well over here. Unless you really request a modmod, Nate.

By the way, :goodjob: Welcome to the forum!
 
I did this in my old Civ4 mod, it's pretty easy to impliment as you really only have to touch one method in the SDK (a few more if you want to read XML values and adjust handling of unit production in 'full' cities).

The default Civ4 AI took to the changes just fine despite all of my fears. The AI controls units by assigning orders to one unit and assigning other units to that unit (e.g. a 'stack') and a stack limit per tile forces the AI to have more stacks which, believe it or not, turns out to be a very good thing as they can adjust orders per stack. This means that the invasion AI is better overall since they don't have a single stack that can suddenly change it's mind and then end up moving back and forth for a few turns until something changes that makes it decide to do something else.

My 'rules' were simple, I allowed 8 units in a tile, +2 in a fort and +4 in a city. Special unit types (great people, settlers, workers, missiles) didn't count towards the limit, air units had their own limit of 4 per city and naval units in cities didn't count nor did any unit in cargo. A lot of people worry about the defender being at a disadvantage but they really aren't since they have a lot of defensive bonuses, especially in cities so the attackers numerical advantage didn't really kick in unless you completely surrounded the city. On the flip side, a city with only one adjacent land tile was hell to conquer.

The downside is that you really can't use the 'move-to' command without being careful so it creates some extra micro managment for players. This is caused by using the 'canMove' method to enforce the stack limit, preventing units from entering a tile if it's full. So moving a stack of four units though a tile occupied by six units was possible but tedious.

While you can impliment it in python it will be very, very slow. This would be especially true in FfH with so many units with high moves since the check would have to be performed for every tile that every unit wanted to move into. As an SDK change it has virtually no effect on game speed even in the late game with thousands of units in play. This may not be the case in FfH due to the extra orders that would have to be processed for units with special abilities and spells.

I'm pretty sure the source code for my old mod is still available, just search the forums for 'World Piece' (not 'peace') and the source code should be attached to the first post. I believe the file you'll want to look at is CvUnit.c but that's really stressing my memory :)
 
Dot
Thanks for the welcome. I've copied this thread there with the hopes of attracting attention.



Seven05

Hopefully this:

http://forums.civfanatics.com/showpost.php?p=6032481&postcount=2

is the link you're referring to? If so, excellent. Do I simply insert that code into Civ4>CvGameCoreDLL folder, filename: CVUnit.CPP? It looks simple enough to change the numbers around. Of course I understand I'll need to replace the file on both computers.
 
http://forums.civfanatics.com/showpost.php?p=6032481&postcount=2

is the link you're referring to? If so, excellent. Do I simply insert that code into Civ4>CvGameCoreDLL folder, filename: CVUnit.CPP? It looks simple enough to change the numbers around. Of course I understand I'll need to replace the file on both computers.
That works too, I forgot about that post. It's a bit more simple there so it fits in a single file code snipet. Like Valk mentioned though, it's an SDK mod so you have to rebuild the DLL to get it to work and then share the compiled DLL with anybody else.

The post I was referring to links to this file: http://forums.civfanatics.com/attachment.php?attachmentid=171648&d=1205789611

Thats the full source for my old mod and the CvUnit.cpp file in there contains the more complete version using values read from XML for the tile limit and additional units allowed in cities. It's not an easy change to make though, you'll still have to merge those changes inthe FfH source and rebuild the DLL, sorry :)
 
So for someone illiterate in programming, what are the chances of me accidentally building and merging the DLL together correctly? Is my best hope praying someone picks up the job or hoping that its done with the Ice phase?

If my chances aren't that bad, where can I learn the basics of doing it?
 
So for someone illiterate in programming, what are the chances of me accidentally building and merging the DLL together correctly? Is my best hope praying someone picks up the job or hoping that its done with the Ice phase?

If my chances aren't that bad, where can I learn the basics of doing it?

Seeing as Kael has stated that the patch that was recently released would be the last one, I think you only have two options here.

  1. Pray someone picks it up.
  2. Attempt to learn how to do it yourself.

I'd have to recommend option 2; Most modders have their own projects. :p

As for where to learn... I'd recommend Xienwolf's guide. http://forums.civfanatics.com/showthread.php?t=314201
 
Top Bottom