Raging Barbarians in FF

Yeah, Skeletons and other non-temporary summons are tricky for the AI to use as anything other than units with base FfH. A field would have to be added to CvUnit which identifies a unit as having been summoned to let the AI understand that a permanent unit is expendable, but there could be rare cases where a permanent summon is NOT an expendable unit (though none I can think of yet).

As for point 1, the hope is that there will be other targets for the lower level units to smack. The AI right now needs help in nurturing high level units (and a massive re-write in selecting proper promotions). Once we get them to create Uber-Units, then we can start to tweak it to create decently leveled Stacks of Death as well.
 
[to_xp]Gekko;7279044 said:
hey Sarisin, it's good to know that you no longer have CTD issues with FF :goodjob: I'm looking forward to the changes that are gonna be made about raging barbs, I wanna try it out cuz it's gonna make the game more interesting I guess. and it's awesome to see that xienwolf is gonna implement the wiser orcs changes in FF :D

@xienwolf: shouldn't points 2) and 3) in your last post be switched around? I think the AI should be more willing to attack with non-durable summons, otherwise they'd end up being useless, no? I'm curious to hear the logic about that ;)

Yeah, I have to admit I am having a blast now that the CTDs are not a problem. :goodjob:

I am only at Turn 450, but there is so much interesting new stuff it is really a learning experience for me now. Having the animals spawn the whole game is a streak of genius. I already was lucky enough to build the Grand Menagerie early, but it is amazing to see a Gorilla strolling around on Turn 450!

Some of the rituals have me baffled as to what they actually do and I'm not sure I want to invest all the hammers and time in building them.

I'm only second in points, and the Clan has close to 50 cities!

When I finish this game (I'm stockpiling Great Bards for a Cultural Victory), I want to try a Normal speed game with raging barbs to see how that is.
 
Yeah, I have to admit I am having a blast now that the CTDs are not a problem. :goodjob:

Just don't turn the grids on until after the next patch (if Hyborem is in-game) :D

Just out of curiosity - did you use them when you were playing before?

When I finish this game (I'm stockpiling Great Bards for a Cultural Victory), I want to try a Normal speed game with raging barbs to see how that is.

Still tough on Normal - but the AI's seem to survive it better.
 
Just don't turn the grids on until after the next patch (if Hyborem is in-game) :D

Just out of curiosity - did you use them when you were playing before?



Still tough on Normal - but the AI's seem to survive it better.

Uh-oh, I ALWAYS use those grid lines and Hyborem is in the game. He's been around for about 50 turns, though, and no CTDs.

It's been many moons since I played at a quicker speed than Epic, but I am curious as to what turn the main barb force appears. That will have to wait, though, as I am truly enjoying my current game...despite losing, at PRINCE for chrissakes!:cry:
 
Well I was playing on noble, huge map and I was Sheaim. No ragers for that game. When I had established my 3rd city, I looked at the wb to find Acheron. Malakim had wiped out Calabim and had at least 10 cities by then. Is it a wonder I quit after that?
 
Uh-oh, I ALWAYS use those grid lines and Hyborem is in the game. He's been around for about 50 turns, though, and no CTDs.

It's been many moons since I played at a quicker speed than Epic, but I am curious as to what turn the main barb force appears. That will have to wait, though, as I am truly enjoying my current game...despite losing, at PRINCE for chrissakes!:cry:

If his territory reaches Ocean that you can see, it will cause a crash if grid lines are turned on. Best option for the moment is to just turn the grids off, or if you're feeling "moddy"...

  1. Download the attached file
  2. Extract the DDS from the zip
  3. Put the DDS in Assets\Art\Terrain\Textures

...which should solve the problem ahead of the next patch.
 

Attachments

  • BlackWatergrids.zip
    124.1 KB · Views: 110
One thing I am not sure if you have mentioned looking at yet which would be nice is changing the "Combat Risk" logic to do a "Power Protect" type of framework. That meaning:

Good ideas; I'll put a note in for future ideas. I'd have to look at the code to see how feasible this is; I haven't done a lot with unit AI yet.
 
If his territory reaches Ocean that you can see, it will cause a crash if grid lines are turned on. Best option for the moment is to just turn the grids off, or if you're feeling "moddy"...

  1. Download the attached file
  2. Extract the DDS from the zip
  3. Put the DDS in Assets\Art\Terrain\Textures

...which should solve the problem ahead of the next patch.

Fortunately, I play on a huge Fantasy Realm map which is mostly land, and he was wedged in between my civ and Einion Logos - as is often the case with the terrible placement he gets. Even though I was Balseraph Evil OO, he threatened me the first turn after contact and declared war after only a few turns - and left Einion Logos, Good alone.

No problem and a stupid move for the Infernal to declare war immediately as he was very easy to wipe out.

I never had to turn off the grid lines, but thanks for that warning which I will keep in mind for my next game. :)
 
...but there could be rare cases where a permanent summon is NOT an expendable unit (though none I can think of yet).

As the Sheaim, I like to keep a skeleton with my adepts as they hunt for XP in the early game. This is pretty specific, but could the AI be taught to summon permanents after they move?

BTW, cardith bit the big one on turn ~70 last night with raging barbs on, but everyone else seems to be okay.
 
OK, I tried a raging barb game with the same variables EXCEPT at Normal speed, and you know what? More of the same. ;)

This time I was Luchiurp (randomly assigned) and played with 11 AI civs on a huge fantasy realm map. Still down at Prince, but might go up a level or two next to see what happens.

Anyway, the main barb force appeared on Turn 35. This was only a few turns earlier than in Epic speed in which they came between turns 40 and 50.

The build time for a Warrior at Epic is 37 turns and 25 at Normal. Yes, this can go down as the city grows, resources come on line, you push production, etc. but the point is generally more turns in Epic to build a unit/defender.

Anyway, I used a strategy to get my second city you should try if you haven't already. If you play with Barbarian Lands turned on, you will normally have at least one barb city settled close to your civ. If the orcs are in the game, you can bet they will use their World Spell For the Horde immediately. This leaves barb cities without a defender for a few turns until they can build one. Beeline for the closest barb city and you can take it without a fight. Or, if you don't want it, raze it and get the gold. As an added bonus you can prevent Acheron from setting up shop near your civ by taking out the barb cities close to you.

I had a Scout nearby and took the city with no barb defenders. A quick way to get a city - no need to build a Settler (very helpful in the slower speed games, which this was not). Of course, now you have to defend two cities.

As soon as I saw Warriors and Goblins move about I knew the main barb force had arrived and it was time to recall all my units back to the two cities and to build more units.

Just as in Epic speed, the AI civs went down one by one in short order. Before turn 100 eight had been wiped out (especially surprised in the case of Cassiel who popped two Adventurers). One lizard civ last until about turn 140 and that left 2 civs beside mine:

Charadon and Jonas Endain.

Two civs with the Barbarian trait who the barbs would not attack. This meant ALL the barbs on the map were headed my way. It was OK though as I had built the Pact of Nilhorn and had the Stooges to defend. I killed Orthus (he committed suicide really going up against my city) and had his axe. I had 7-8 defenders in each city, about 12 with 100XP. Even though the barbs came in waves, they were not denting my defenses - bolstered by Palisades and Walls. There was no way I could build and defend any improvements.

So, there I was just hitting Enter and Defending - not very interesting.

I thought about letting Jonas and Charadon pass me in points so the barbs would declare war on them. I reduced my Research to 10%, but still founded two religions and other techs as I stayed ahead of them on points.

Charadon declared war on me and sprung his World Spell that brought bunches of wolves, but he could not dent my defenses with his barb cronies.

I'll probably just give up on this game to start another. I see there is a 'break save' patch out anyway.

Conclusions:

1. The mod just doesn't work with raging barbs. I suppose I could try Quick speed, but expect more of the same. The AI is just unable to cope with the raging barbs and is wiped out too fast.

2. The barbs come just too early in raging barbs. This needs to be scaled back based on game speed. I would recommend turn 200 for Epic and, I guess turn 100-125 for Normal. This would, hopefully, give the AI a chance to build some defenders so they can survive longer. However, I'm guessing they will still expand like crazy and keep one defender per city giving them the same result of being wiped out early.

3. The early game of exploration is completely missing in raging barb games. I was able to pop 3 goody huts, 1 lair (2 more were available, but already had Skeleton guards), and 1 graveyard before I had to head back to my cities. No chance to even get Animal Husbandry and capture animals. I really miss that fun in my raging barb games in FF.

4. I'm wondering if upping the difficulty would make a difference? Would the AI be smarter in building more defenders? Would the bonus against barbs help them? Or would they still expand, expand, expand and have their one-defender cities overrun one by one by the raging barbs. Maybe I will try that next.

For now, I have to still say the modmod is unplayable with the raging barb option selected unless you just want a quick, unsatisfying Conquest Victory. I'm anxious to hear if anyone thinks differently, maybe by using different game variables than I have chosen.
 
I actually dug into the code this weekend and found that it already IS scaled by gamespeed. BarbPercent is multiplied by BarbarianUnitAppearTurn (or nearly those variable names). In each case except Marathon that is the same as the standard scaling, for Marathon though it is 400 instead of the normal 300. So they should show up VERY late in Marathon games.
 
I actually dug into the code this weekend and found that it already IS scaled by gamespeed. BarbPercent is multiplied by BarbarianUnitAppearTurn (or nearly those variable names). In each case except Marathon that is the same as the standard scaling, for Marathon though it is 400 instead of the normal 300. So they should show up VERY late in Marathon games.

What did you find for Epic speed?

Again, I played three Epic speed games with raging barbs selected and all three ended up as Conquest victories before Turn 160.

Also, in those three games the bulk of the barb force (not the odd Warrior, Goblin, Skeleton, or Lizardman) showed up between turns 40 and 50.

For the only Normal speed game they came on turn 35.

I guess I will try Marathon next, but I hate to play at that setting as the game really bogs down from mid-game on.
 
I actually dug into the code this weekend and found that it already IS scaled by gamespeed. BarbPercent is multiplied by BarbarianUnitAppearTurn (or nearly those variable names). In each case except Marathon that is the same as the standard scaling, for Marathon though it is 400 instead of the normal 300. So they should show up VERY late in Marathon games.

If you check my post earlier in the thread - I tied that value into the per turn spawns as well. It is currently just the "arrival turn" that is slowed by game speed.

Currently they just delay when the barbs arrive, but when they do, they arrive with the same frequency as they do on Normal speed, which is effectively at least twice as fast on Marathon (as units there take twice as long to create). Basically means that any defending losses against barbarians are twice as hard to recover from.
 
Breakdown of how Barbarians spawn now ("maintenance code" removed so we can discuss what actually does something):

Code:
void CvGame::createBarbarianUnits()
{
	if (isOption(GAMEOPTION_NO_BARBARIANS))
	{
		return;
	}

	lResult = 0;
	gDLL->getPythonIFace()->callFunction(PYGameModule, "createBarbarianUnits", NULL, &lResult);
	if (lResult == 1)
	{
		return;
	}

Ok, if you have Barbarians turned off, none of this happens. And the python call isn't used at all in FfH, looking up the function it is just "return false"

Code:
    createAnimals();

	if (getElapsedGameTurns() > ((GC.getHandicapInfo(getHandicapType()).getBarbarianCreationTurnsElapsed() * GC.getGameSpeedInfo(getGameSpeedType()).getBarbPercent()) / 100))

This is the important bit where the Barbarians are told to wait for a while to spawn. Well, first line calls a function to spawn animals before checking if it is allowed to spawn Orcs. In the Animal spawn function things run PRETTY MUCH the same way, except it is hardcoded that animals won't spawn for the first 5 turns (I just now made this weighted by gamespeed's BarbPercent as well), or if there are fewer cities settled than there are living players in the game (ie - everyone had a chance to settle their first city. Except on Deity where the AI starts with a spare settler, you better not wait too long to settle your own city or there WILL be animals)

Turns Elapsed is set by your difficulty selection:
  • Settler: 50
  • Chieftan: 45
  • Warlord: 40
  • Noble: 35
  • Prince: 30
  • Monarch: 25
  • Emperor: 20
  • Immortal: 15
  • Deity: 10

Barb Percent is set by your gamespeed:
  • Marathon: 400
  • Epic: 150
  • Normal: 100
  • Quick: 67

So an Epic game on Noble Difficulty will get Barbarians spawning at about turn 48, Animals spawning at turn 8. Marathon game on Prince will see Animals spawning at turn 20, and Barbarians spawning at turn 120 (about 20 turns after Orthus has spawned if I remember that chunk of python right)

The numbers in the gamespeed look like they could go for a bit of a balancing now that it is the ONLY limitation on when the Barbarians come calling. They are overall a tad bit low.

Code:
	{
		for(pLoopArea = GC.getMapINLINE().firstArea(&iLoop); pLoopArea != NULL; pLoopArea = GC.getMapINLINE().nextArea(&iLoop))
		{
			if (pLoopArea->isWater())
			{
				eBarbUnitAI = UNITAI_ATTACK_SEA;
				iDivisor = GC.getHandicapInfo(getHandicapType()).getUnownedWaterTilesPerBarbarianUnit();
			}
			else
			{
				eBarbUnitAI = UNITAI_ATTACK;
				iDivisor = GC.getHandicapInfo(getHandicapType()).getUnownedTilesPerBarbarianUnit();
			}

			if (isOption(GAMEOPTION_RAGING_BARBARIANS))
			{
				iDivisor = std::max(1, (iDivisor / 2));
			}

The map is split up by the game into disctinct "areas" based on various reasoning. One of those reasonings is that water and land are always seperate, so an area is either one or the other, never both. This just makes sure we don't beach the Sailor's Dirge or drown Orthus.

The Divisor is fairly self explanatory: How many unowned tiles need to exist for me to be allowed to spawn a Barbarian? And if Raging Barbs is set, let's get double the number of Barbarians!

Code:
			if (iDivisor > 0)
			{

				iNeededBarbs = ((pLoopArea->getNumUnownedTiles() / iDivisor) - (pLoopArea->getUnitsPerPlayer(BARBARIAN_PLAYER) - pLoopArea->getAnimalsPerPlayer(BARBARIAN_PLAYER)));

Modified by Kael so that the number of animals the Barbarians have in play won't count against the number of normal units they are allowed to spawn. This just counts how many tiles are unowned to find out how many Barbarians are allowed in the area, then it checks how many units the barbarians have in the area to determine how many will need to be spawned.


Note: Since these checks are done on a per area basis, there isn't any limit World-Wide on how many Barbarians are allowed to exist. If the Barbarians are all wandering out of one area, but are not being killed in another area, then their numbers can build forever.

Code:
				if (iNeededBarbs > 0)
				{
					iNeededBarbs = ((iNeededBarbs / (4 * GC.getGameSpeedInfo(getGameSpeedType()).getBarbPercent()) / 100)) + 1);

Just modified this bit to use what Vehem mentioned earlier in the thread. Now on Marathon the Barbarians will trickle into existence, while on Quick they will flood in.

Code:
					for (iI = 0; iI < iNeededBarbs; iI++)
					{
						pPlot = GC.getMapINLINE().syncRandPlot((RANDPLOT_NOT_VISIBLE_TO_CIV | RANDPLOT_ADJACENT_LAND | RANDPLOT_PASSIBLE), pLoopArea->getID(), GC.getDefineINT("MIN_BARBARIAN_STARTING_DISTANCE"));

						if (pPlot != NULL)
						{
							eBestUnit = NO_UNIT;
							iBestValue = 0;

							for (iJ = 0; iJ < GC.getNumUnitClassInfos(); iJ++)
							{
								bool bValid = false;
								eLoopUnit = ((UnitTypes)(GC.getCivilizationInfo(GET_PLAYER(BARBARIAN_PLAYER).getCivilizationType()).getCivilizationUnits(iJ)));

								if (eLoopUnit != NO_UNIT)
								{
									CvUnitInfo& kUnit = GC.getUnitInfo(eLoopUnit);

									bValid = (kUnit.getCombat() > 0 && !kUnit.isOnlyDefensive());

//FfH: Added by Kael 08/14/2007
                                    if (GC.getUnitClassInfo((UnitClassTypes)iJ).getMaxGlobalInstances() == 1)
                                    {
                                        bValid = false;
                                    }
//FfH: End Add

									if (bValid)
									{
										if (pLoopArea->isWater() && kUnit.getDomainType() != DOMAIN_SEA)
										{
											bValid = false;
										}
										else if (!pLoopArea->isWater() && kUnit.getDomainType() != DOMAIN_LAND)
										{
											bValid = false;
										}
									}

									if (bValid)
									{
										if (!GET_PLAYER(BARBARIAN_PLAYER).canTrain(eLoopUnit))
										{
											bValid = false;
										}
									}

									if (bValid)
									{
										if (NO_BONUS != kUnit.getPrereqAndBonus())
										{
											if (!GET_TEAM(BARBARIAN_TEAM).isHasTech((TechTypes)GC.getBonusInfo((BonusTypes)kUnit.getPrereqAndBonus()).getTechCityTrade()))
											{
												bValid = false;
											}
										}
									}

									if (bValid)
									{
										bool bFound = false;
										bool bRequires = false;
										for (int i = 0; i < GC.getNUM_UNIT_PREREQ_OR_BONUSES(); ++i)
										{
											if (NO_BONUS != kUnit.getPrereqOrBonuses(i))
											{
												TechTypes eTech = (TechTypes)GC.getBonusInfo((BonusTypes)kUnit.getPrereqOrBonuses(i)).getTechCityTrade();
												if (NO_TECH != eTech)
												{
													bRequires = true;

													if (GET_TEAM(BARBARIAN_TEAM).isHasTech(eTech))
													{
														bFound = true;
														break;
													}
												}
											}
										}

										if (bRequires && !bFound)
										{
											bValid = false;
										}
									}

									if (bValid)
									{
										iValue = (1 + getSorenRandNum(1000, "Barb Unit Selection"));

										if (kUnit.getUnitAIType(eBarbUnitAI))
										{
											iValue += 200;
										}

										if (iValue > iBestValue)
										{
											eBestUnit = eLoopUnit;
											iBestValue = iValue;
										}
									}
								}
							}

							if (eBestUnit != NO_UNIT)
							{
								GET_PLAYER(BARBARIAN_PLAYER).initUnit(eBestUnit, pPlot->getX_INLINE(), pPlot->getY_INLINE(), eBarbUnitAI);
							}
						}
					}
				}
			}
		}
	}
}

All this stuff just finds a valid plot (minimum distance from any city based on difficulty level, and a tile which is not visible to anyone and stuff), then finds the best unit which the Barbarians are allowed to have and pops out as many as it is allowed to.
 
Thanks for your work on this xienwolf.

I want to emphasize that the human player should be OK with the raging barb situation that is in effect now. However, it is the AI that just cannot cope with the amount of barbs, but more importantly how soon they come. There probably has to be some fundamental change in FF (and FFH2) to somehow make them focus on defending vs. expanding. I think there was something done to ensure a city had two defenders, but that is hardly enough when you get an early stack of Skeletons, Lizardmen, Warriors and Goblins.

The result is as stated - AI civs mowed down one by one with the human player who turtles up assured a Conquest Victory - or a 'dead' game like I just had because there were two AI civs with the Barbarian trait.

The other thing to consider that I have mentioned several times and I'm not sure if your adjustments will fix or not is that selecting the raging barbarian variable ensures you will not have much of an early game exploration phase. In each of my games the time was very limited to go for goody huts, graveyards, and lairs/dungeons. There was ZERO time to think about capturing animals.

IMO FFH2 has it right when it gives you about 200 turns (Epic) to enjoy the exploration of your map and do the things listed above. In FF what should be a very fun part of the game is just eliminated if you want raging barbs.

Again, thanks for working on this, but for now, I think I will skip the raging barb games. If there is something you would like me to test for you, it would be my pleasure. :)
 
We're having a play around with things - will see if we can tweak it to work a little better.
 
Revised the code some more.


Now Barbarians will spawn when the above discussed timer is done AND you satisfy one of the following:

Game Option: Barbarian World is set
OR
Game Option: No Settlers is set
OR
There are 1.5 Cities per player in the world.


So you should not see Barbarians spawning earlier than you do in base FfH now, unless you select Barbarian World.
 
xienwolf, I'm not sure if you applied your tweaks to patch 'o.' If you did, unfortunately, they are not working.

I started a game with exactly the same variables listed in original post (only playing Tasunke selected by the random generator).

The main barb force came on Turn 44 of the Epic speed game. I opened the world builder and each of the 12 civs, including mine, had one city - what you might expect on Turn 44.

I am now at Turn 200 and 9 of the 11 AI civs have been wiped out. Two others, Khazad and Calabim, are left with me and strangely the barbs are pretty much leaving them alone and pounding my only city. I am unable to get out and settle a second city and the XP on my guys is out of sight!

I was hoping to get my Stooges out with a couple of units to take out the remaining 2 civs, but, so far am unable to.

The point is, it looks the same as the games I mentioned early in this thread and will likely end in a very early Conquest Victory...mainly due to the barbs appearing too early IMO.

For now, FF is still unplayable on a huge map at Epic (and likely Marathon) speed with raging barbs selected.

If anyone else has seen otherwise, I'd love to hear from you. ;)
 
Yes, those tweaks should be in with Patch O. Raging Barbarians ought to mean no standard Barbarian spawn until there are 1.5 cities per player. But having Barbarian World or No Settlers will remove that limit.

I'll take another look at the code and set up some debug messages to see precisely how it is reacting. On the upside, while looking for what might be causing this to happen, I found that the AI already desires an extra 2 "floating defenders" when Raging Barbarians is set. So I can easily tweak that number up to see if it helps out.

Amusingly, a lot of the AI strategy is based on the current Era, which is meaningless in FfH, so I'll have to search that one and pluck it out of all corners of the code. One horrific location where it considers the current Era is in the number of defenders desired. So it turns out some religions are naturally more defensive than others in the AI's hands. How silly ;)
 
Back
Top Bottom