A lot of people, including me, have asked questions about why there are so few Barbarian Naval units in the game. In the earlier versions of CIV, it was quite common for barbarians to suddenly appear in ships off your coast, and they would unload an invasion force that you had to deal with. Plus, their ships would attack your navy! Not so in CIV4, where you very rarely meet a Barbarian Galley! Sometimes you DO meet one... but it might be that this particular galley was simply built by a Barbarian coastal city, and not spawned onto the map. It is certainly a rarity. Some have modded the game to include more pirates, and the best results I have seen involve events, where Barbarians are created via python events (jkp1187's pirates, for example). But those random spawnings of Barbarian ships have remained elusive.
Well, this weekend I finally sat down to figure out why. And I'm pretty I have finally found the answer!
When the game spawns barbarian units, it does so based on a number of things:
First, it considers if there should even be any barbarians (there's the game option to turn them off).
Second, it checks to see if there are any animals in the game. If not, it will create some.
Third, it will see if enough time has passed to create barbarians (this is a setting connected with difficulty settings).
Fourth, it will determine how many barbarians are required for a certain map area. And this is where it gets really interesting! When you select a difficulty level, part of the difficulty deals with how many unowned tiles there should be per barbarian unit. So if it's set to 100, then the game will basically spawn one barbarian unit per 100 unowned tiles. The Settler difficulty is 150, so 150 unowned tiles to create one barbarian. The higher the difficulty, the lower the number. If you've selected Raging Barbarians, this number is divided by 2. When it's figured out how many barbarians are needed, it then subtracts the existing number of barbarians (including animals) on the map. Whatever is left, is placed on random plots - immediately. The type of units selected is restricted by normal build restrictions - that is, technology and resources, so no Axemen without the Barbarian nation having access to copper, for example. It also means that Galleys won't spawn until the barbarians have researched sailing!
There are a number of conditions, which make spawning of ships very unlikely:
1) There are two different types of unowned plots: Unowned land plots and unowned water plots. The number I've given above is for land plots (Settler=150 to Deity=25). The number of unowned water plots is much higher (Settler=3000 to Deity=1000). So even on Deity, if you have 2000 unowned water plots in one area, the math in the formula will be 2000 / 1000 = 2 water units. However, the 2 units are then divided by 4, and 1 is added. In the end, 2000 unowned water plots will still only support one galley.
2) The unowned number of plots is independent of map size. This may come as a surprise, it certainly did to me. A default Large map in CIV4 is 104 x 64 plots, a total of 6.656 plots. if 60% is water, that's less than 4.000 water plots. If all plots are unowned, AND regarded as one area (which I am unsure of), that's still only enough to support 1 galley (see point 1 above) on Deity.
3) As barbarian units get killed, more get placed. But as time goes by in the game, there are less and less unowned plots, so less and less room to support spawning barbarians. Remember, this is different from units getting built by barbarian cities, although those built units still count against the needed barbarians.
4) The barbarians need the appropriate technology to spawn units. If they never research sailing, a galley will never spawn. And the sooner you and the AI squash the barbarian cities, the less research the barbarians accumulate.
So, what to do? Well, it's possible to just tweak XML files to have this thing work. Yesterday, I tried to give the barbarians sailing as a starting tech, and lowered the number of unowned water plots to 10 on deity. After 10 turns , which is the Deity setting for turns without barbarians units (animals always spawn after 5 turns, regardless of difficulty), I had the oceans absolutely crawling with galleys!!
I haven't put together a modcomp of this yet, because I haven't quite decided on how to fix this. There are quite a few possibilities to fix this, ranging from inelegant XML modding like I did yesterday, to full-blown SDK changes. What I'd like to accomplish is for barbarians to keep spawning in the oceans right up to Privateers. So What I think is needed is some way for the game to grant free techs to the barbarians at appropriate points - like when two or three civs discover a particular tech on a predefined list, that tech is given to the barbarians.
Well, this weekend I finally sat down to figure out why. And I'm pretty I have finally found the answer!
When the game spawns barbarian units, it does so based on a number of things:
First, it considers if there should even be any barbarians (there's the game option to turn them off).
Second, it checks to see if there are any animals in the game. If not, it will create some.
Third, it will see if enough time has passed to create barbarians (this is a setting connected with difficulty settings).
Fourth, it will determine how many barbarians are required for a certain map area. And this is where it gets really interesting! When you select a difficulty level, part of the difficulty deals with how many unowned tiles there should be per barbarian unit. So if it's set to 100, then the game will basically spawn one barbarian unit per 100 unowned tiles. The Settler difficulty is 150, so 150 unowned tiles to create one barbarian. The higher the difficulty, the lower the number. If you've selected Raging Barbarians, this number is divided by 2. When it's figured out how many barbarians are needed, it then subtracts the existing number of barbarians (including animals) on the map. Whatever is left, is placed on random plots - immediately. The type of units selected is restricted by normal build restrictions - that is, technology and resources, so no Axemen without the Barbarian nation having access to copper, for example. It also means that Galleys won't spawn until the barbarians have researched sailing!
There are a number of conditions, which make spawning of ships very unlikely:
1) There are two different types of unowned plots: Unowned land plots and unowned water plots. The number I've given above is for land plots (Settler=150 to Deity=25). The number of unowned water plots is much higher (Settler=3000 to Deity=1000). So even on Deity, if you have 2000 unowned water plots in one area, the math in the formula will be 2000 / 1000 = 2 water units. However, the 2 units are then divided by 4, and 1 is added. In the end, 2000 unowned water plots will still only support one galley.
2) The unowned number of plots is independent of map size. This may come as a surprise, it certainly did to me. A default Large map in CIV4 is 104 x 64 plots, a total of 6.656 plots. if 60% is water, that's less than 4.000 water plots. If all plots are unowned, AND regarded as one area (which I am unsure of), that's still only enough to support 1 galley (see point 1 above) on Deity.
3) As barbarian units get killed, more get placed. But as time goes by in the game, there are less and less unowned plots, so less and less room to support spawning barbarians. Remember, this is different from units getting built by barbarian cities, although those built units still count against the needed barbarians.
4) The barbarians need the appropriate technology to spawn units. If they never research sailing, a galley will never spawn. And the sooner you and the AI squash the barbarian cities, the less research the barbarians accumulate.
So, what to do? Well, it's possible to just tweak XML files to have this thing work. Yesterday, I tried to give the barbarians sailing as a starting tech, and lowered the number of unowned water plots to 10 on deity. After 10 turns , which is the Deity setting for turns without barbarians units (animals always spawn after 5 turns, regardless of difficulty), I had the oceans absolutely crawling with galleys!!
I haven't put together a modcomp of this yet, because I haven't quite decided on how to fix this. There are quite a few possibilities to fix this, ranging from inelegant XML modding like I did yesterday, to full-blown SDK changes. What I'd like to accomplish is for barbarians to keep spawning in the oceans right up to Privateers. So What I think is needed is some way for the game to grant free techs to the barbarians at appropriate points - like when two or three civs discover a particular tech on a predefined list, that tech is given to the barbarians.