Once more: FFH and the AI

Spoiler :
Gent rulezzzzzzz :rockon: ;)


The next step in my experimenting will be how to persuade the AI NOT to go for anything magic related at all; as long as the AI cannot use mages (as in, cannot actually cast spells), there is no point in researching those techs for them.

That's so defeatist. Even worse than removing the copper requirement so the AI can build weak axemen. :mischief: If the AI cannot use mages properly, then why not make efforts to make the AI use magic better? Of course, certain stuff can only be done by SDK, such as making the AI use targeting spells or let water mages roam the land for Spring. But my impression is the AI also suffers from some even more basic problems which prevents them using magic well.
1) You often see magic users without any magic sphere promotions at all. So increasing the AIweight of those promotions in XML might already help a lot to get magic users to actually do something. Or for a python example, in the latest version of RoM I included an event which gives an adept built by the AI a free level 1 spell sphere promotion (chosen from the mana types available to them) instead of Free Promotion.
2) The AI simply builds too few adepts in my opinion. Here too increasing the AiWeight of the unit might help.
Tweaking with this might already help a lot.

There was a certain feeling that I've intuitively had while playing against the AI, and our current state of research explains it beautifully: I had the feeling of there being a certain distinctive "bump" in the curve of difficulty-over-time in games vs the AI, pretty early in the game. If you managed to get over this bump, you had a sure win. All the higher difficulty settings did nothing but increase this bump. Sure, on deity it was practically impossible to get over it, and in some games the sheer speed of the AI's expanding meant that the bump took not so much the form of an early war being lost as of the AI getting a GENERAL tech advantage on you that you would never be able to catch up with, but the bump was still there: you'd either lose the game early, and decisively, or not at all. And this makes sense now: if they really choose their techs so badly, there simply is a time at which you have an EFFECTIVE tech advantage over them that they will not catch up with.

That's the case in all of civ, not just FfH. It has to do with the AI being bad at managing their economy. So if the human players survives the early game (which is hard because the AI starts with extra units, techs etc) without too many scratches he can easily outbuild the AI. You'll have to wait for Blake's AI being used in FfH to solve this IMO.

the weighing algorithms have certain kinks (introduced, surely, by FFH)

FYI, this would be my working method if I had a go at changing the tech and leader flavour values:

1) Look at each tech individually and assign it a military, religious, cultural, growth, science, production and/or gold value based on the advantages the tech itself gives. I was thinking about using high cultural flavour for the recon branch btw, so that the Ljosalfar and Balseraph follow that branch.
2) Then work backwards from the end of the tech tree to the beginning. Give the prerequisites of a certain tech also a certain portion of the flavour value given to that tech itself. This is to guide the AI towards researching that tech, even if its prerequisites themselves might not have the flavour wanted by the leader.
3) Work from the beginning of the tech tree towards the end. Under the motto "Specialization is good in FfH" give some techs that require a certain tech also a portion of that techs's flavour. Eg if an AI has researched towards Iron Working, it makes sense to go for those tier4 melee unit first as well.

Then of course you have to make the leader flavours right so they follow the tech paths you want them too. The best strategy for a leader to follow is determined by its traits and its civilization, so you could for each civ individually and each trait individually determine what flavours fit with it. Then combine them to make the flavours for each leader.

I guess I'd start with flavour value 10 as a maximum as that's the way vanilla civ4 does, but if that doesn't have any effect as xanagui thinks, gradually increase and tweak them until you get the desired effect.

I guess these would be good flavours for FfH's traits. Haven't looked at the civs yet - probably pointless until we know if some civs have changed, have gotten other mana etc.

Organized: gold, mil, gro
Spiritual: rel
Industrious: prod
Creative: cul
Financial: gold
Philosophical: gro, (sci)
Raiders: mil
Arcane: sci or rel (depends on civ)
Expansive: gro
Aggressive: mil, prod
Summoner: sci
Magic Resistant: sci (at least in RoM: I think I'll give their mages the Dispel Magic spell for free - currently that trait is useless for a human player IMO, though of course that might change if the AI would use magic better)
Defender: archers (python)
Ingenious
Sprawling
Hidden
Agnostic
Barbarian
Scorched Earth
Insane

You can also give flavours to units btw. So acrobats and harlequins could be given a high cultural flavour, melee units a high production flavour etc.


Edit: oh btw, here's an oversight from the current leader flavours:

Sabathiel: 5 mil, 2 rel, Organized, Magic Resistant
Capria: 5 mil, 2 cul, Spiritual, Industrious
Varn Gosam: 10 rel, Creative, Financial
Ethne: 5 cul, 2 gro, Defender, Spiritual, Creative
Einion Logos: 5 cul, 2 sci, Defender, Spiritual, Philosophical
Basium: 5 rel, 2 mil, Aggressive, Ingenious, Raiders
Garrim Gyr: 5 pro, 2 sci, Arcane, Financial
Beeri Brawl: 5 growth, 2 sci, Organized, Spiritual
Cardith Lorda: 5 growth, 2 pro, Expansive, Philosophical, Sprawling
Amelanchier: 5 mil, 2 cul, Defender, Raiders
Arendel Phaedra: 5 rel, 2 cul, Spiritual, Creative
Thessa: 5 sci, 2 cul, Arcane, Expansive
Arturus Thorne: 5 pro, 2 mil, Industrious, Organized, Ingenious
Kandros Fir: 5 mil, 2 pro, Aggressive, Financial, Ingenious
Morgoth: 5 sci, 2 pro, Hidden, Industrious
Falamar: 5 mil, 2 gold, Creative, Expansive
Hannah: 5 mil, 2 sci, Financial, Raiders
Cassiel: 5 mil, 2 gro, -5 rel, Industrious, Philosophical, Agnostic
Tasunke: 5 gold, 2 mil, Aggressive, Raiders
Rhoanna: 5 gold, 2 sci, Expansive, Financial
Valledia: 5 gro, 2 sci, Arcane, Organized
Dain: 5 pro, 2 sci, Philosophical, Magic Resistant
Charadon: 5 mil, 2 gro, Aggressive, Barbarian
Mahala: 5 mil, 2 pro, Industrious, Raiders
Keelyn: 5 sci, 2 cul, Creative, Summoner
Perpentach: 5 cul, 2 gold, Insane
Jonas: 5 mil, 2 rel, Spritual, Expansive, Barbarian, Scorched Earth
Sheelba: 5 mil, 2 gold, Aggressive, Magic Resistant, Barbarian, Scorched Earth
Faeryl: 5 sci, 2 cul, Arcane, Hidden
Alexis: 5 mil, 2 pro, Aggressive, Philosophical
Flauros: 5 gold, 2 rel, Expansive, Organized
Tebryn: 10 sci, Arcane, Summoner
Os-Gabella: 5 sci, 2 mil, Spiritual, Summoner
Hyborem: 5 mil, 2 sci, Summoner, Barbarian, Scorched Earth
Auric Ulvin: 5 gro, 2 gold, Philosophical, Magic Resistant, Agnostic
 
We also removed the Sumon Tiger spell in "Fire" because the AI overused it and would just spam endless streams of tigers at opponents.

In RoM I solved that by simply making summoned tigers not have hidden nationality. So if that was the only reason to remove the spell... :)
 
In RoM I solved that by simply making summoned tigers not have hidden nationality. So if that was the only reason to remove the spell... :)

Nah, I like the spell that replaces it better.
 
[edit] oops writing this post took so long it lost context; Kael asked me if I'd never seen AI units run around with various magic buffs

Well, no, I haven't, but my games against the AI tend to be short, as I've outlined a few posts above. I either lose after about 40-50 turns, or I dominate them so badly that after about 100 turns I stop playing because it's becoming pointless.

Okay, so I'll grant that they can use buffs (hence the UNITAI MAGE_BUFF, right?) and maybe they can deal with permanent summons to some degree; my argument (which I'm going to explain in detail in the next paragraph) is that their understanding of magic is still so bad that they handicap themselves building mages, and surely handicap themselves the to point of disqualifying themselves if they go for magic before anything else.

Basically it boils down to the ai not understanding how to use timed summons; most painfully, fireballs. I just did the following experiment: I created a clean map, just placed a single city for me and the enemy on islands, then made two different islands (separated by just one tile of coast) and on ONE of them placed about 10 axemen for myself and on the other I placed exactly 7 mages for the AI and gave them all the fire I and II promotions and the UNITAI_MAGE_OFFENSIVE script. What happened? Every four to five rounds I'd be hit by a single fireball. Out of the seven mages that could cast fireball, only an average of 2 would cast it per round (that is, sometimes it was 1 or none, sometimes it was 4). Out of those fireballs, I would estimate that only 5&#37; were actually used against me. What did they do with the others? Why, move around erratically! They would move them one tile over the coast and back over the tile with the mages, or somewhere else over the sea. At first I thought okay maybe they're scouting... but at some point they knew all tiles around them and still they went on moving their fireballs without purpose. I thought, hey, maybe the axemen were too strong! Maybe they saw the low combat odds and thought, naah, not going to lose our fireballs (if that had been the case, that would have been bad enough already; fireballs are almost always used ad <50 odds. This is their FUNCTION: soften up the enemy). So I gave myself warriors instead. And nope, no change: still they'd attack me very very rarely and rather move those few fireballs they created at all.

I will say it again: at this stage, the AI is much better off avoiding magic altogether.

I think this little subproject is very very far from giving the team recommendations. I hope that, by that time, and with xanaqui's help, we will have taught the AI to use magic properly. Until that time, and more or less as a proof of concept for me, to prove to myself that this tech problem is indeed the AI's greatest handicap, I will discourage the AI from using any magic techs.

Actually it's still way too early for any real attention from the team ;) But thank you for taking a look at giving us feedback :)

[edit] Just to clarify: of course we'd never approach the team with the recommendation to take away magic from the AI. That'd be nonsense. The final goal must be to teach the AI magic. I'm just saying that right now for my own testing I will take magic away from the AI and see how they do. If they do a lot better (as I expect them to), I'm onto something.
 
Alright, I've messed around a little more, and this is more-than-preliminary, but I've done the most obvious things (weighted the melee and the archery line heavier, gave huge penalties to the magic techs, weighted axemen and their UU brothers, macemen and their UU brothers, and longbowmen and their UU brothers heavier) and we've played one test game which generally gives me some hope.

If you want to mess around with this and have a look how the AI would play if it didn't waste the first 100 years of research on stuff it's not using (well), I've rared the xml dir and put it up here: (it's on my own server now, just because I didn't want to figure out civfanatics file upload thingie yet)

xmlai001.rar

Go to your FFH assets dir, make a backup copy of the xml dir (or just rename it), put this rar into your assets dir and unrar it there. It will create a new xml directory. I was too lazy to single out the files I've changed, but hey, 600k! This is the era of 12MB DSL lines ;)

Try this out with the difficulty you normally use for your games against the AI.

And to say it again: this is more than preliminary. I've probably only invested 20 minutes into tweaking the XML, and it's all very heavyhanded and clumsy; I don't think I'm ready to ask for feedback yet, but I'd love to hear how it felt for you (why did that sound naughty in my mind?)

Most of all, I look at the effects those very simple changes had and I'm imagining what it would be like to play FFH with an AI that really understands the game.

(damnit. Okay, I just reread my post and it sounds to me like I'm attacking the team! This is surely paranoia, but just to point this out: FFH2 is the bestest thing since sliced bread. I do not play any other games on my PC anymore. I don't mean "I don't play other civ4 mods", I mean, no other games. FFH occupies my thinking so much of the time that it's ridiculous. I love this mod to pieces and I'm incredibly thankful to the wonderful people who volunteer their time to make this mod for me! There. Paranoia silenced. Srsly.)
 
Oooookaaay....

Sounds to me like a big improvement to AI spellcasting could come from creating a new AI for the fireballs - - currently they use what appears to be the same AI that a regular combat unit uses: UNITAI_ATTACK. If someone points me to which file affects this and what program I need to edit it - I'll fiddle with it. (else I'll end up figuring out the file and program myself)
 
Oooookaaay....

Sounds to me like a big improvement to AI spellcasting could come from creating a new AI for the fireballs - - currently they use what appears to be the same AI that a regular combat unit uses: UNITAI_ATTACK. If someone points me to which file affects this and what program I need to edit it - I'll fiddle with it. (else I'll end up figuring out the file and program myself)

CvUnitAI.cpp is where you would want to start.
 
cool, I can edit that, no problem.

:)
 
Yes, they definitely need to know that they want to suicide fireballs. But on top of that it also seems like casting fireball or not is currently randomly decided. That's not good. Unless there's somewhere else the caster should be or something else he should be doing, if there's an enemy within range, a caster should ALWAYS cast fireball (or other timed summons). Range gets a little tricky, of course...

Yoshi, tell me if you're getting any good results! It's awesome that so many people who know how to fiddle with the sdk have joined us already :)
 
Err... I'm not quite on the same page as you.

I am comfortable with C++. I am comfortable diving into files to learn how they work. When I saw the CPP extension - I was like "great!".... but doing a search on my computer yielded nothing.. I've got a few guesses as to what is going on: either I need to break apart the DLL to get the code - or I need to get the code from another source. I haven't yet figured out which, if either, of these is the case.

But, once I have this mysterious file - and I spend a day or so looking at it, I can assure you I'll have something to say.
 
Err... I'm not quite on the same page as you.

I am comfortable with C++. I am comfortable diving into files to learn how they work. When I saw the CPP extension - I was like "great!".... but doing a search on my computer yielded nothing.. I've got a few guesses as to what is going on: either I need to break apart the DLL to get the code - or I need to get the code from another source. I haven't yet figured out which, if either, of these is the case.

But, once I have this mysterious file - and I spend a day or so looking at it, I can assure you I'll have something to say.

http://forums.civfanatics.com/showthread.php?t=166933
 
Oh yeah, of course, you'll need to download the SDK. I've done so and I've had a look around, but I'm reading C++ very slowly, and I've not yet bothered to set up a compile environment here. I don't think it would be a real problem for me once I actually set aside an hour to do so, but for now I'm getting nice results with the XML already.

Also, what I will be able to do with C++ in three days others might be able to do in 3 hours. I'm much more comfortable testing things and pointing those wonderful coding monkeys in all sorts of directions ;)
 
Ok thanks, gives me something to look at. I'm guessing that this SDK that I'm looking at is the generic one and that the one compiles for FFH has undergone a number of modifications? (I believe I remember reading somewhere that the team will release the SDK as somepoint in the future?)
 
Yeah. The FFH SDK is somewhere in this forum. I don't think they've changed that much when it comes to these functions, but you should definitely get it and read it. Mostly I guess Kael linked you to that post should you need help setting up a compile environment (obviously you need to compile those cpp into a dll so that they do anything). I can't find the FFH SDK right now; maybe Kael took it down in anticipation of fire? Fire will hit soon, and then within a week or two we should have the new sdk. Maybe it's best you wait until then?
 
Ok check it out - I've been looking over the generic one .. and it seems to me that all of the code is right there... Find AI_AttackMove() Make an exact copy of this function.. call it AI_FireballAttackMove() <<or whatever>> and remove the checks for healing, defending, pillaging, etc. Then above that there is a switch (AI_getUnitAIType()) .. add a case for the AI_FireballAttackMove() that we created: call the new case "UNITAI_Fireball" or whatever. Then in the XML file just change the AIType for the Fireball unit to this new AI. :) I make it sound so easy - but there may be more things to do. The effect should be that the fireballs -- once cast, should be much more likely to seek out an enemy to attack.

I'd be happy to compile this change and fire it up - but I don't have the FFH SDK and I'm not certain that I have all of the libraries installed.

Oh, BTW - change the odds attack to 0 in the new Fireball function.. otherwise they won't attack unless they can win.

EDIT -- here, I'll create the new function and paste it in here -- that way someone can test it on the 2 island scenario and let us know if the fireballs are any more aggressive.
 
I made a search for SDK and it didn't show up, so I went through the forum pages to find this same thread manually, but on the way there got lost in a lot of unrelated threads. This forum is damn big, do you realize that? ;P
 
I made a search for SDK and it didn't show up, so I went through the forum pages to find this same thread manually, but on the way there got lost in a lot of unrelated threads. This forum is damn big, do you realize that? ;P

There are more posts about FfH (this forum, plus the main FfH1 and FfH2 threads) on civfanatics then all other mods put together.
 
Ok, here is the function that I wrote up (copy/pasted) real quick

Spoiler :
Code:
void CvUnitAI::AI_FireballAttackMove()
{
	PROFILE_FUNC();

	if (AI_anyAttack(2, 50))
	{
		return;
	}

	else if (AI_anyAttack(2, 0))
	{
		return;
	}

	else if (AI_anyAttack(3, 50))
	{
		return;
	}

	else if (AI_anyAttack(3, 0))
	{
		return;
	}

	else if (AI_anyAttack(4, 50))
	{
		return;
	}

	else if (AI_anyAttack(4, 0))
	{
		return;
	}

	else if (AI_cityAttack(2, 0))
	{
		return;
	}

	else if (AI_cityAttack(3, 0))
	{
		return;
	}

	else if (AI_cityAttack(4, 0))
	{
		return;
	}

	else if (AI_patrol())
	{
		return;
	}

	getGroup()->pushMission(MISSION_SKIP);
	return;
}

The reason that I am calling the same functions so many times is to allow for various ranges and circumstances for the fireballs - I'm guesing the computer would want to kill the closest units first, then soften up further units, an finally - nail cities (closest first and further secondly, if there is a choice). Plus a fireball may have different ranges depending on what advances.. all that jazz that everyone already knows.

I haven't looked up the Mission_skip thing yet, but I imagine that it is exactly what it sounds like - sit on your butt and do nothing. I also haven't looked up the Patrol function yet, I'm hoping that it is a fall back telling the unit that if they have none of the other options available - that it will go exploring.


EDIT -- As I had mentioned above, just paste this in with the other AIAttackMove Functions, call it from a new Case, and use that case as a new AI type for the fireball unit. If anyone wants to try this but doesn't know where all these things are -- lemme know and I'll be more explicit. Like I said also, I'm not setup to try it myself.. maybe tomorrow I will be.. but hopefully someone else tries it out real quick and we could have some idea of whether this function helps or not, sooner.

EDIT EDIT -- maybe the Attack functions 2,0 and 3,0 could be dropped.. infact, they almost certainly should be - but for testing purposes, they should make no difference.
 
Ok, got the FFH code. I'll see if I can't get it to compile as-is tonight before I apply my changes and test a few things.
 
Back
Top Bottom