Barb Camp Bug 3.3.4

It sounds like a bug. I thought the clearing radius was intended to be 1; it would only work for camps right next to an AI unit, and only if there were no barbarians within a certain range.

I support the idea of a camp clearing cheat for the AI, because the AI was doing a terrible job in clearing camps, but there is no way it should be clearing camps 8 tiles away.
 
The code is deliberately written so camps are cleared at X radius from every AI city. X being AIRevealRadius which is a constant connected to map size, 8 on standard, 7 on small, 9 on large, etc.

However, there is additional code that kills barbarians themselves if they are next to AI units:
Spoiler :
PHP:
function ClearCampsUnit(unit)
	local player = Players[unit:GetOwner()]
	if player:IsHuman() or player:IsMinorCiv() or not unit:IsCombatUnit() then
		return
	end
	
	local campID = GameInfo.Improvements.IMPROVEMENT_BARBARIAN_CAMP.ID
	for nearPlot in Plot_GetPlotsInCircle(unit:GetPlot(), 1, 1) do
		if nearPlot:GetImprovementType() == campID then
			if nearPlot:IsVisibleToWatchingHuman() then
				log:Info("ClearCampsUnit aborting: visible to human", player:GetName(), unit:GetName())
			else
				log:Debug("ClearCampsUnit %s %s", player:GetName(), unit:GetName())
				ClearCamp(player, nearPlot)
				for i=0, nearPlot:GetNumUnits()-1 do
					local nearUnit = nearPlot:GetUnit(i)
					if Players[nearUnit:GetOwner()]:IsBarbarian() and nearUnit:IsCombatUnit() then
						nearUnit:Kill()
						unit:ChangeExperience(10)
						log:Info("Killed barbarian %s with 10 experience for %s", nearUnit:GetName(), unit:GetName())
						break
					end
				end
			end
		end
	end
end
 
Ah, thanks for explaining. 8 tiles from any city seems like too much. Is it checked for every city for every turn?

I'm not sure if we need a city-radius clearing mechanism, but if we do then maybe it should be ~radius 4.
 
I believe it checks all of the AI player's cities at the end of each of the AI player's turn. So it would check (AI) player 2's cities at the end of player 2's turn, 3's cities at the end of 3's turn, etc.

And I've been testing a radius of 5 and 25 gold and it's been working out better for me.

First 25 turns:
Spoiler :
Code:
[81309.905] MT_Initialize: INFO   Turn 3   Cleared camp for Ramesses II +25 gold
[81309.905] MT_Initialize: INFO   Turn 3   Cleared camp for Ahmad al-Mansur +25 gold
[81309.905] MT_Initialize: INFO   Turn 3   Cleared camp for Wu Zetian +25 gold
[81457.934] MT_Initialize: INFO   Turn 9   Cleared camp for Maria Theresa +25 gold
[81457.950] MT_Initialize: INFO   Turn 9   Cleared camp for Wu Zetian +25 gold
[81537.650] MT_Initialize: INFO   Turn 11  Cleared camp for Ramesses II +25 gold
[81537.650] MT_Initialize: INFO   Turn 11  Cleared camp for Haile Selassie +25 gold
[81557.385] MT_Initialize: INFO   Turn 12  Cleared camp for Ahmad al-Mansur +25 gold
[81606.385] MT_Initialize: INFO   Turn 13  Cleared camp for Haile Selassie +25 gold
[81630.112] MT_Initialize: INFO   Turn 14  Cleared camp for Gandhi +25 gold
[81721.825] MT_Initialize: INFO   Turn 17  Cleared camp for Maria Theresa +25 gold
[81869.511] MT_Initialize: INFO   Turn 18  Cleared camp for Haile Selassie +25 gold
[81908.090] MT_Initialize: INFO   Turn 21  Cleared camp for Gandhi +25 gold
 
This is a rough first version we will refine over time, like many things. :)

Humans prioritize embarkation if we start near water, search for ancient ruins in a certain range around our capital, and send units long distances to kill barbarians. These are some AI strategies I added over the years which Firaxis did not program AIs to do. This AI search radius adjusts for map size. It controls how far AIs search for water, citystates, ancient ruins, barb camps, and other things.

I often see AIs get stuck with few cities after their settlers get captured. Cities are spaced 6-8 tiles apart on standard maps, so camps in that range must be clear for AIs to successfully expand. They also need to clear camps at a rate similar to humans. Human players send units to clear camps at a relatively large range. AIs have a 100% combat bonus against barbarians, but this does not help if they don't send units to fight the barbarians. I'm open to suggestions if you can think of another way to solve these problems.

I'll make the bonus less noticeable. I will limit it to camps that are invisible for a longer time, check for nearby human units and cities in a larger range, and some other things. The vanilla game's normal check for "visible to humans" usually works for things like this, but is apparently not enough for this particular task. The check occurs once at the end of the human player's turn. If we delete the barb unit, the AI doesn't have the opportunity to get experience or other bonuses from it. It's more efficient to let barbs venture towards the AI more naturally, where the AI's vs-barb bonus makes short work of them.

I usually avoid extra checks like this for most AI tasks because they add to the between-turn processing time, and will take several hours to code and test. It looks like the extra work is necessary for this, because the Honor opener makes the effects more visible than most AI tasks.
 
The AI searches for tasks to about 10% of map width:

Map Size|Duel|Tiny|Small|Standard|Large|Huge
Width|40|56|66|80|104|128
AISearchRange|4|6|7|8|9|10
 
A clear radius of zero would be my vote, if we can get the excellent AI from GEM back into CEP.

In GEM the AI was pretty efficient about organizing raids on camps and clearing them out. Is it feasible to just copy that behavior over to CEP?
 
A clear radius of zero would be my vote, if we can get the excellent AI from GEM back into CEP.

In GEM the AI was pretty efficient about organizing raids on camps and clearing them out. Is it feasible to just copy that behavior over to CEP?

I may be wrong, but my impression is that this was the G&K combat AI, and that part of the changes to the combat AI in the vanilla patch prior to BNW release ended up somehow crippling the AI's ability to clear camps. This is just much more of a problem in vanilla BNW that it was in vanilla G&K.

@Thal
My preference would be for a system where the AI would send out units to fight barbarians, and that a camp-clearing mechanism could be added for units if it wasn't effective enough in doing so.
Camp clearing directly from AI cities starts feeling to the human like a gamey cheat. It also means that there are many fewer barbs for the human to fight - it is very common that a barb city will be <8 tiles from an AI city, but actually closer to the human and more likely to attack the human.

I'd probably go with ~1 radius clearing on land units, 2 on ships, and nothing from cities. If cities must clear camps, they should probably only have a moderate radius, and maybe should only do so for cities on their same continent.

Also: city state cities shouldn't count for camp clearing.

If Honor policies could increase gold from camp clearing, then it might be interesting to have camps give 25 gold by themselves and 75 gold with Honor opener. The Honor opener could identify camps and give the bonus gold, rather than a combat bonus. So it increases the rewards from fighting barbarians, rather than increasing your ability to do so.

But thanks for innovating on this issue, it's great to try some mechanics out and see what works and feels right.
 
Is there a way to disable this until Thal has time to make some changes?
Could I just use an underscore in front of the Barbarians folder?
 
Nope. In the \Documents\My Games\Sid Meier's Civilization 5\MODS\Communitas Expansion Pack - Basic (v 3)\Gameplay\AI\ folder find the CEAI_Events.lua file.

To disable the barb clearing mechanic, you want to comment out the following at line 1114:
PHP:
LuaEvents.ActivePlayerTurnEnd_City.Add(function(city, player) return SafeCall(ClearCampsCity, city, player) end)
to:
PHP:
--LuaEvents.ActivePlayerTurnEnd_City.Add(function(city, player) return SafeCall(ClearCampsCity, city, player) end)
 
Nope. In the \Documents\My Games\Sid Meier's Civilization 5\MODS\Communitas Expansion Pack - Basic (v 3)\Gameplay\AI\ folder find the CEAI_Events.lua file.

To disable the barb clearing mechanic, you want to comment out the following at line 1114:
PHP:
LuaEvents.ActivePlayerTurnEnd_City.Add(function(city, player) return SafeCall(ClearCampsCity, city, player) end)
to:
PHP:
--LuaEvents.ActivePlayerTurnEnd_City.Add(function(city, player) return SafeCall(ClearCampsCity, city, player) end)

Thx for the info. I do have another question though.
I like playing with Raging Barbarians turned on. Ever since this latest release though camps are spawning very slowly.
I made a change in the barbarians folder: <Update>
<Where Name="BARBARIAN_CAMP_ODDS_OF_NEW_CAMP_SPAWNING" />
<Set Value="50" />
<!-- 50 -->
I forgot what the value was before but it was a lower number and I changed it to 50.
Is there something else I can do in order to get Raging Barbarians back??
 
Depending on your map size, just disabling the auto clearing might raise spawn rates on its own. Give it a shot and let us know.
 
Depending on your map size, just disabling the auto clearing might raise spawn rates on its own. Give it a shot and let us know.
Ok - thx for the help and quick replies. Do I need to clear cache and moduserdata after making this change in order for this to work correctly?
 
I've noticed City-States are doing a relatively good job of going to barbarian camps, killing the barbarians and clearing the camps because many times they're beating me to the quest of clearing the camp for them and they'll even be there when I'm at the camp and steal it away from me if I don't send enough units. If the City-States are able to do this why does the AI need extra help with auto clearing? At the moment I'm noticing multiple Civ's with well over a thousand gold in the early parts of the game where gold is limited and it just doesn't seem right regardless if they're spending that gold to purchase buildings and units or not. Doesn't the AI use gold to conduct Research Agreements and trade for Luxuries with the other AI's? If nothing else it allows them to build anything they want without any worry about running out of gold.
 
Been trying some vanilla games for contrast... somehow, I'm finding that the vanilla BNW AI seems to be doing notably better than the CEM AI at keeping camps cleared; time and again, I've been getting to the camps to find the AI already fighting there, or find a freshly-cleared camp in their wake. Of course, I have often found myself near fellow Honor-picking warmongers, so that 'they know where the camps are' thing might be a factor. Even so, if the AI can make use of info that 'there are barbarians here' to actually get rid of barbarians, that'd be a step up from ignoring them and getting ambushed lots.
 
Been trying some vanilla games for contrast... somehow, I'm finding that the vanilla BNW AI seems to be doing notably better than the CEM AI at keeping camps cleared; time and again, I've been getting to the camps to find the AI already fighting there, or find a freshly-cleared camp in their wake. Of course, I have often found myself near fellow Honor-picking warmongers, so that 'they know where the camps are' thing might be a factor. Even so, if the AI can make use of info that 'there are barbarians here' to actually get rid of barbarians, that'd be a step up from ignoring them and getting ambushed lots.

I actually noticed this behavior from Alexander in my last CEP game. We were neighbors and competing for barbarian camps the first half of the game. He also picked up honor and did not expand past his capital.
 
Re: vanilla honor civs attacking and clearing camps, I've seen this too.

Maybe the solution is to give all AI civs the ability to always see every barb camp within 10 tiles of their cities.

I would prefer this over the camp auto-clear system, which I dislike so much I've switched back to Vanilla BNW for now. Hopefully it'll get axed in 3.4 :)
 
Re: vanilla honor civs attacking and clearing camps, I've seen this too.

Maybe the solution is to give all AI civs the ability to always see every barb camp within 10 tiles of their cities.

I would prefer this over the camp auto-clear system, which I dislike so much I've switched back to Vanilla BNW for now. Hopefully it'll get axed in 3.4 :)

Same here, I would much rather see something done to improve the AI's ability to see camps further away and go out to them rather than just put a band aide on the issue and auto clear all camps in their remote vicinity giving them loads of free gold and taking away much of the opportunities from the human player of being to go out and find camps either for gold, CIV UA's, or to improve relation with nearby City-States. The auto-clearing system just feels too much like a cheat rather than a fix and makes having barbarians at all in the game just annoying since you're constantly having to protect your tile improvements from barbs but once you kill those barbs you can't find their camp to get a reward for it since the camp has usually already been cleared.
 
Top Bottom