SWY1985 / CivOne

An open source implementation of Sid Meier's Civilization.
http://www.civone.org/
Creative Commons Zero v1.0 Universal
245 stars 49 forks source link

Implement Barbarian sea units spawning #477

Closed SWY1985 closed 6 years ago

SWY1985 commented 6 years ago

Logic by observation explained by axx here: https://forums.civfanatics.com/threads/barbarians-spawn-logic.630389/#post-15096489


Copy from the forum thread:

For sea (sail/frigate) barbarians:

  • ✔️ they spawn every 8 turns
  • ✔️ they start spawning at 3360 BC (emperor diff), 2720 BC (king), 2080 BC (prince), 1440 BC (warlord), 960 BC (chieftain)
  • ✔️ at one point in the game the naval barbarians stop spawning (unlike the land units). I'm not 100% sure what is the reason, but I'm almost certain it has to do with some advance being researched (by either Civ). In one game naval barbs stopped appearing at 1954 AD, in second game at 1930 AD and in third game at 1770 AD. In the third game I was playing on emperor diff, and it seems Zulus reached a certain advance. But I'm not sure which advance triggers this. I'll have to do more research for this point. Update: I did one more playthrough and barbarian ships stopped appearing after I researched combustion. Makes sense and I hope this is true. Would be good if anyone else could confirm this.
  • ✔️ the moment they spawn, they do the movement, so it's difficult to pinpoint the exact location where they appear.
  • ✔️ It seems they appear at least 1 tile from land (e.g. they appeared in the Mediterranean on one EARTH game). The starting location, it seems, is completely random. I also never noticed them appearing near the poles (at least a couple squares from the N/S poles) or in any of the lakes.
  • ✔️ sails appear until 1500 AD, then frigates. To be more exact, the last sail appears at 1460 AD, the first frigate 8 turns later at 1520 AD (keep in mind that after 1500 AD, 1 turn changes from 10 to 5 years).
  • ✔️ sails carry 1 Legion + leader (diplomat) up until (including) 1120 BC. From 960 BC to 1460 AD sails carry 2 Legions + leader. From 1520 AD frigates carry 3 legions + leader. At one point frigates start carrying 3 knights + leader (this transition from legions--> knights happened at 1882 AD/1834 AD/1640 AD in 3 games I played. I researched cannons & gunpowder a while back, so perhaps this triggers it.)
  • ✔️ When barbarian ship appears, it starts moving (GO-TO order) towards the nearest capital (of any civ) until it reaches land, then it disembarks its units. This go-to function is not always working properly, for example in EARTH map when a barbarian ship appears in the pacific and starts moving towards Europe or Africa, it gets stuck on the edge of America and it stays there indefinitely. This eventually causes stacks of enemy ships standing together on one particular tile. Also ships tend to get stuck somewhere close to the north pole for whatever reason. Once you get near them they start attacking you.
SWY1985 commented 6 years ago

The starting spawn year formula seems strange for Chieftain difficulty. For each difficulty level, the game turn is a multitude of 32. except for Chieftain:

The formula for spawn game turn appears to be (5 - difficulty) * 32, where difficulty 0 = Chieftain. That would make the starting spawn year for Chieftain 800 BC instead of 960 BC.

I've implementen the description from @kazgaroth011 for now... with the odd starting year on Chieftain...

axx0 commented 6 years ago

I've tested this 3 times for chieftain and each time 960 BC was the starting spawn year. BTW chieftain is the only difficulty where you never get 1 legion + leader in a sail but always 2 legions + leader.

SWY1985 commented 6 years ago

In that case, the formula is probably:

Which results in the same as your observation. :+1:

SWY1985 commented 6 years ago

For now, I'm going to assume that if one civilization has research GunPowder, the Legion units get replaced by Knights.

SWY1985 commented 6 years ago

Pirates now spawn at least 2 tiles from the poles, on a random water tile that's completely surrounded by other water tiles.

SWY1985 commented 6 years ago

Now, we only need to figure out when barbarian pirates stop spawning...

axx0 commented 6 years ago

I'll try to find out.

SWY1985 commented 6 years ago

Thanks for the update, @kazgaroth011 (https://forums.civfanatics.com/threads/barbarians-spawn-logic.630389/#post-15098478)

I'm going to make pirates stop spawning after anyone has researched Combustion.