AI Fun

Dragonessa

Chieftain
Joined
Jul 21, 2009
Messages
7
OK, I've actually had this happen in FFH2, and FallFurther but I now happen to be playing Orbis so the post goes here. :queen: (Incidentally out of all 3 I'm preferring Orbis' vision of things. Great work! :D :D)

Now then, is it me or is the AI insane and declare war right when they are the most friendly to you? I just recently played a game with the most stark example of this.

I started off playing a game as the evil dark elves. My primary goal I gave myself was to cozy up the Elves (Arendel) and then go about jointly killing off all those other pesky races. ;) So of course I have to turn good first, so I deal with that. So far so good, Arendel is still cautious but isn't openly hostile. Then I get moving over to her favorite religion. The relation plus points start adding up. Then a war hits Arendel pretty hard. I'm off on my own and not as affected so I send in an army to help out. By the time my army gets there Arendel has lost about half her cities. So I start reclaiming her cities each time turning them over to her. I finally reclaim all of her cities for her, her relation is upwards of +50. I've already sent two other armies on their way so we can begin an offensive at last. Then it happens. Right when my first army is ready to assault the first enemy city, Arendel declares war on ME. It was rather humorous really. Her relation to me was "friendly" yet here she was now at war with me. Naturally she didn't want to elaborate on WHY she declared war. :lol:

As I said, this has actually happened before in both FFH2 and FF. This was my 3rd Orbis game and yes, you guessed it, each time Arendel was friendly and declared war out of the blue. I wasn't always playing the Svartalfar either. Arendel wasn't the only AI to go crazy occasionally like this but it seems to be a habit with her. So does Arendel's AI have some predisposition to insanity or is this just my freakish luck -every- game? :D
 
That war was most likely scripted. Ljosalfar and Svalaftar declares war on each other when AC reaches 20 ((percent or raw - not sure)) and declaring civ is the stronger one.

Code:
if CyGame().getGlobalCounter() > 20:
	if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SVARTALFAR'):
		if (pPlayer2.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR') and CyGame().getPlayerRank(iPlayer) > CyGame().getPlayerRank(iPlayer2)):
			self.startWar(iPlayer, iPlayer2, WarPlanTypes.WARPLAN_TOTAL)
	if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
		if (pPlayer2.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SVARTALFAR') and CyGame().getPlayerRank(iPlayer) > CyGame().getPlayerRank(iPlayer2)):
			self.startWar(iPlayer, iPlayer2, WarPlanTypes.WARPLAN_TOTAL)
 
I was wondering if it was something on that order. I may just accidentally comment out some code to avoid this in the future.... :scan:

:thanx:
 
yeah, but forcing the human player to declare war isn't nice as it limits what you can do in the game. I think the code should atleast check if the civ that declares war isn't a human player.
 
I'm pretty sure it does. However, that just means that if the other civ is in-game and has contacted you, they will declare war.
 
I'm pretty sure it does. However, that just means that if the other civ is in-game and has contacted you, they will declare war.
Did you read the code posted by arcticnightwolf?
 
It never forced me (the human player presumably :bounce:) to declare war. Just the AI Arendel. I can appreciate the reasons for it from a FFH background perspective (though I've never played any scenarios), but I'd rather not have friendly nations suddenly going bonkers on me unless it's a good vs evil thing.

Commenting out the offending lines appears to fix the wonkiness however. I'm on my 4th game now (yep, svartalfar again) and Arendel hasn't gone insane. :D
 
So are there any other predestined conflicts we should look out for?
 
Well ... these wars are scripted:
Code:
if self.warScriptAllow(iPlayer, iPlayer2):
	if pPlayer2.getBuildingClassMaking(gc.getInfoTypeForString('BUILDINGCLASS_TOWER_OF_MASTERY')) > 0:
		if eTeam.getAtWarCount(True) == 0:
			self.startWar(iPlayer, iPlayer2, WarPlanTypes.WARPLAN_TOTAL)
	if (pPlayer2.getNumBuilding(gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_DIVINE')) > 0 or pPlayer2.getNumBuilding(gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_EXALTED')) > 0):
		if pPlayer.getAlignment() == gc.getInfoTypeForString('ALIGNMENT_EVIL'):
			if eTeam.getAtWarCount(True) == 0:
				self.startWar(iPlayer, iPlayer2, WarPlanTypes.WARPLAN_TOTAL)
	if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_MERCURIANS'):
		if pPlayer2.getStateReligion() == gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL'):
			self.startWar(iPlayer, iPlayer2, WarPlanTypes.WARPLAN_TOTAL)
	if CyGame().getGlobalCounter() > 20:
		if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SVARTALFAR'):
			if (pPlayer2.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR') and CyGame().getPlayerRank(iPlayer) > CyGame().getPlayerRank(iPlayer2)):
				self.startWar(iPlayer, iPlayer2, WarPlanTypes.WARPLAN_TOTAL)
		if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
			if (pPlayer2.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SVARTALFAR') and CyGame().getPlayerRank(iPlayer) > CyGame().getPlayerRank(iPlayer2)):
				self.startWar(iPlayer, iPlayer2, WarPlanTypes.WARPLAN_TOTAL)
	if (CyGame().getGlobalCounter() > 40 or pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_INFERNAL') or pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_DOVIELLO')):
		if pPlayer.getAlignment() == gc.getInfoTypeForString('ALIGNMENT_EVIL'):
			if (eTeam.getAtWarCount(True) == 0 and CyGame().getPlayerRank(iPlayer2) > CyGame().getPlayerRank(iPlayer)):
				if (iEnemy == -1 or CyGame().getPlayerRank(iPlayer2) > CyGame().getPlayerRank(iEnemy)):
					iEnemy = iPlayer2

(( and that is warScriptAllow function == if this function returns false, war won't trigger))
Code:
def warScriptAllow(self, iPlayer, iPlayer2):
	pPlayer = gc.getPlayer(iPlayer)
	pPlayer2 = gc.getPlayer(iPlayer2)
	iTeam = gc.getPlayer(iPlayer).getTeam()
	iTeam2 = gc.getPlayer(iPlayer2).getTeam()
	eTeam = gc.getTeam(iTeam)
	if pPlayer.isBarbarian() or pPlayer2.isBarbarian():
		return False
	if eTeam.isHasMet(iTeam2) == False:
		return False
	if eTeam.AI_getAtPeaceCounter(iTeam2) < 20:
		return False
#	if pPlayer.AI_getAttitude(iPlayer2) <= gc.getLeaderHeadInfo(pPlayer.getLeaderType()).getDeclareWarRefuseAttitudeThreshold():
#		return False
	if eTeam.isAtWar(iTeam2):
		return False
	if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_INFERNAL'):
		if pPlayer2.getStateReligion() == gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL'):
			return False
	return True


(( these codes are located in customFunctions.py, around line 2200 ))
 
Back
Top Bottom