Once more: FFH and the AI

I probably missed something - but if one of the biggest, current, problems is the fact that the AI likes to research ALL four schools of magic - wouldn't giving the Magic flavor to them just exacerbate the problem for whichever Civs go for the Magic flavor?
You could create 4 flavors (1 for each) to deal with this issue, so that most leaders would prefer only one of these four tech.

Alternatively, you could sink all of them, and rely on the AI to eventually decide to go for the level of tech beyond them (which of course requires one of those tech).
 
The first idea was in at one point but cut because it allowed mages to cast archmage spells, although the second idea had merit, I'm not sure how it'd work, since # mana >> # strength types.

It looks like this could be solved by adding a third prerequisite for spells, or making the prerequisites a list (so you could have any number of pre-requisites), and using Channeling III as a prerequisite for those spells.
 
You could create 4 flavors (1 for each) to deal with this issue, so that most leaders would prefer only one of these four tech.

Alternatively, you could sink all of them, and rely on the AI to eventually decide to go for the level of tech beyond them (which of course requires one of those tech).


I agree with the first solution - but personally feel that the second is the way to go... since the goal is to get them to create and use mages and archmages, and to not purely get a school of magic for the sake of having it.
 
xanaqui, can you see a simple way to adjust the AI weight for an entire UnitClass?
 
I disagree - different game setups really don't change much.

Really ? Well playing FFH2 2 humans v 2 AI without raging barbs is a very bad game setup and changes the challenge substantially from other game setups. Though, like Nikis Knight said, since it's your opinion that game setup is unimportant, keep working on the AI tweaking - that can only bring good things. The bottom line though is that they won't be good enough for such a game setup.
 
onedreamer: I've played a game on emperor 2 humans vs 2 ai with raging barbs and at about year 110, one of the AI civs was destroyed by the barbs.

Can you imagine how much that is not fun at all? We'd already invested about 2-3 hours into the game at that time and then, bam, game over because the stupid AI couldn't even fend off the barbs.

I agree, entirely, that different game setups will affect AI performance, but I don't think that this is a MAJOR factor. I'm saying the AI still ****s up very badly even when game setup is entirely to their favour.

(I'm guessing that--and I'm going on hearsay here, I don't know if the following is true--since me and my ally researched down the melee line so very quickly that meant that the barbs also got axemen very quickly, and the AI being busy research Alteration, Alchemy, and Antarctic Group Dances or whatever useless tech they were sinking their lightbulbs into, couldn't keep up with the constant stream of axemen ownage)
 
I think that the Eternal Flame's extra mana is useful for humans, but not for the AI. I've found that I can sell just about any resource to just about any AI for 20-30g per turn, assuming they have that much income. Trading mana in general is an exploit. Build a death node and gift, sell, or trade it to a "friend." Cancel the deal when you want to promote a unit to Death I and immediately trade it back again for no diplomacy penalty.
 
Trading mana in general is an exploit. Build a death node and gift, sell, or trade it to a "friend." Cancel the deal when you want to promote a unit to Death I and immediately trade it back again for no diplomacy penalty.

Yep thats what i do if i dont want to screw my relations with the good guys, I screw their relations with each other.

Or even better: Sell it to them...
Maybe we should add a check for all good civs so they dont buy death/entropy mana
 
Really ? Well playing FFH2 2 humans v 2 AI without raging barbs is a very bad game setup and changes the challenge substantially from other game setups. Though, like Nikis Knight said, since it's your opinion that game setup is unimportant, keep working on the AI tweaking - that can only bring good things. The bottom line though is that they won't be good enough for such a game setup.

I appologize, I forgot about multiplayer - and yes, multiplayer is much different than Single player... or actually, I imagine it is different - haven't played multiplayer.

As for the Death/Entropy Exploit - too bad the "You use bad mana" check isn't to see whether any of your units actually use bad mana.

And I agree, "good" AI's probably shouldn't accept bad mana.
 
Maniac, have you experimented with adding flavours yet? The more I think about it, the more I think that civ or leader based flavours may be the way to go, but there's nothing that would make a hybrid system less efficient from where I stand. I think I've reached a pretty good point in my general weighing and I've come to the point where I will really need to start making use of flavours (for instance, Calabim really need to know that Iron Working is not that important for them, where Feudalism is very much)

[edit]Wikification: I've added a page to xanaqui's wiki: FfH New AI. Feel free to add to it!
 
I'm not planning on doing anything before Fire comes out. Though since you asked about it, I just added FLAVOR_MELEE to GlobalTypes.xml as a test, and the game didn't crash on start-up. Why, that's already a very good start I'd say. :D
 
I appologize, I forgot about multiplayer - and yes, multiplayer is much different than Single player... or actually, I imagine it is different - haven't played multiplayer.

yeah, np. I play only MP, with my wife ^^

As for the Death/Entropy Exploit - too bad the "You use bad mana" check isn't to see whether any of your units actually use bad mana.

And I agree, "good" AI's probably shouldn't accept bad mana.

Well I don't know. Surely a check on units would be way better, because death and entropy mana are required for one of the victories (Tower of Mastery).
 
The whole mana thing's a bit outside the scope of what we're trying to do, I think.

As for an update of what I've been doing,

1) Flavors can be added through xml changes alone, no problem. Tested it and it works fine. This is Good News.

2) I've been going through the best tech function with a close reading. Here's what I've got so far:

http://www.civ4wiki.com/wiki/index.php/CvPlayerAI::AI_bestTech
 
Do you like looking at hundreds of pages of debug output? I sure do!

Here's a game with the original FFH2 016 xmls. Watch Faeryl Viconia go for all the wrong techs! (okay, calendar first was smart since she did have incense next to her. Animal Husbandry was useless, and sailing... by the time she only had her capital, which was next to a 1x1 tile lake. Guess that counts as coastal ;))

Note: I'm not 100% that I read all the code right, so some of these debug statements may be a little off, talking about something that didn't happen etc. I'm a fiction writer, I can't help it ;) Also, you'll notice one line saying "VOODOO!" That's because I couldn't figure out what the hell the following code is doing:

Code:
if (GC.getCivicInfo((CivicTypes)iJ).getTechPrereq() == iI)
{
    iValue += 200;
    logTech("  This tech enables a new civic! (+200) Value is now %i", iValue);
    if (AI_civicValue((CivicTypes)iJ) > ((AI_civicValue(getCivics((CivicOptionTypes)(GC.getCivicInfo((CivicTypes)iJ).getCivicOptionType()))) * 4) / 3))
    // say WHAT?
    {
        iValue += 800;
        logTech("  VOODOO! +800 %i", iValue);
    }
}

And here's the textfile: (caution, this is 220k. Maybe you should not open this with your browser, but rather save to disc and open with your text viewer of choice)

Look at this! The AI is selecting techs!

Also, if you'd like to use these debug thingies yourself, here's my CvPlayerAI.cpp. Kael (if you're looking ;)), is Fire going to introduce any changes to bestTech? I'd need the new SDK asap to keep fiddling with this. Or I can keep fiddling with Light and apply the things I've learnt to Fire.

Look! I'm a player and I got an AI! Kinda!

Some early thoughts: the AI is weighing bonuses WAY too heavily, and also sea units. I really think we'll need more global states the AI can be in for all of this to make sense. I'm thinking stuff like bIsInFinancialTrouble, but maybe with more accurate warplans (for instance the AI should only consider the seas truly important if a) there's a LOT of water in the map or b) water is a more convenient way to get to the enemy than land; there should be something like bIsPlanWaterWar for instance). Also, magic use definitely has to be its own tech-plan, so to speak, and different mana types should be weighed heavily. For instance, say the AI is planning to make war on the player using fireball-slinging mages. The AI DOESN'T have fire mana. The AI DOES have raw mana in its territory. In that case, the AI_bonusval for fire mana should go through the roof, causing the AI to beeline to elementalism.

I realize that's a crazy amount of work.
 
Note: I'm not 100% that I read all the code right, so some of these debug statements may be a little off, talking about something that didn't happen etc. I'm a fiction writer, I can't help it ;) Also, you'll notice one line saying "VOODOO!" That's because I couldn't figure out what the hell the following code is doing:

Code:
if (GC.getCivicInfo((CivicTypes)iJ).getTechPrereq() == iI)
{
    iValue += 200;
    logTech("  This tech enables a new civic! (+200) Value is now %i", iValue);
    if (AI_civicValue((CivicTypes)iJ) > ((AI_civicValue(getCivics((CivicOptionTypes)(GC.getCivicInfo((CivicTypes)iJ).getCivicOptionType()))) * 4) / 3))
    // say WHAT?
    {
        iValue += 800;
        logTech("  VOODOO! +800 %i", iValue);
    }
}

If this new civic is over 4/3 the value of the current civic for the same civic type, then increase the value by 800.
 
Are you certain that this is the file you wanted to show? I would have though that this would be an output file from a run with your new weights.

Hm? When I click that link, I get the CPP file I meant to link. It's CvPlayerAI.cpp with lots of debug messages in it. Doesn't the link go to bringa dot ubermutant dot net slash CvPlayerAI dot cpp for you?

[edit] And if you meant the other link, it's most definitely output of the old xmls. Just scroll down to Archery and see that its AIWeight is 10. I had it at 7000 or so.

10! Seriously! This is at a stage where the iValues are typically between 7000 and 12,000. Adding 10 to that is nonsensical!

I'm currently working on flavor and more weighing. This is the flavor system I've come up with:


Keep original flavors: mil, rel, prod, gold, science, culture, growth
Add new flavors for certain military lines: melee, archery, scout, horse
Add new flavors for helping certain civs: calabim (for vamps), luchuirp (for wood golems), Grigori (against religion techs)
Instead of using AIWeight, add a new flavor: flavor_weight. This can be scaled directly in the leaderheads file. Like this if the weight doesn't impact gameplay enough, we just crank it up in the leaderheads file for all leaders. Instant multiplication! Teh win!


LEADERS: 1 - 100
TECHS: 1 - 100

(those were my original planning notes; in case they don't make sense: instead of using AIWeight, I'm using a new flavor called FLAVOR_ALL, which all leaders have at 50. This way, if I find that my general weighing is too strong or too weak, I can just quickly adjust that value in leaderheadinfos.xml. I would probably want ALLTECH, ALLBUILDING, ALLUNIT. The Luchuirp, Grigori, and Calabim flavors are used for very few things only: Luchuirp favors Construction, Calabim Feudalism, and Grigori takes an additional negative weight on all religion-related things. It's working pretty well so far, with only the techs in.

I've also started messing around with bestTech. I've removed the random value in the beginning, toned down the mage weighing (again, this will be undone once magic works), made normal attack units more important, and a few other small things. Oh yeah, flavors now get <entry in leaderheads> * <entry in tech/building/unit/whatever> * 10 (instead of * 20 as before).

Just to clarify this: I'm still in the "messing around and collecting ideas" stage. I don't consider any of my changes anywhere near final, meaning I really don't care that fire will come out in a few days and I'll have to start over from scratch. I keep starting over from scratch! I'm learning what works and what doesn't.
 
Hm? When I click that link, I get the CPP file I meant to link. It's CvPlayerAI.cpp with lots of debug messages in it. Doesn't the link go to bringa dot ubermutant dot net slash CvPlayerAI dot cpp for you?
Yes; I guess I mis-understood the intended context.

[edit] And if you meant the other link, it's most definitely output of the old xmls. Just scroll down to Archery and see that its AIWeight is 10. I had it at 7000 or so.

10! Seriously! This is at a stage where the iValues are typically between 7000 and 12,000. Adding 10 to that is nonsensical!

I'm currently working on flavor and more weighing. This is the flavor system I've come up with:


Keep original flavors: mil, rel, prod, gold, science, culture, growth
Add new flavors for certain military lines: melee, archery, scout, horse
Add new flavors for helping certain civs: calabim (for vamps), luchuirp (for wood golems), Grigori (against religion techs)
Instead of using AIWeight, add a new flavor: flavor_weight. This can be scaled directly in the leaderheads file. Like this if the weight doesn't impact gameplay enough, we just crank it up in the leaderheads file for all leaders. Instant multiplication! Teh win!


LEADERS: 1 - 100
TECHS: 1 - 100

(those were my original planning notes; in case they don't make sense: instead of using AIWeight, I'm using a new flavor called FLAVOR_ALL, which all leaders have at 50. This way, if I find that my general weighing is too strong or too weak, I can just quickly adjust that value in leaderheadinfos.xml. I would probably want ALLTECH, ALLBUILDING, ALLUNIT. The Luchuirp, Grigori, and Calabim flavors are used for very few things only: Luchuirp favors Construction, Calabim Feudalism, and Grigori takes an additional negative weight on all religion-related things. It's working pretty well so far, with only the techs in.

I've also started messing around with bestTech. I've removed the random value in the beginning, toned down the mage weighing (again, this will be undone once magic works), made normal attack units more important, and a few other small things. Oh yeah, flavors now get <entry in leaderheads> * <entry in tech/building/unit/whatever> * 10 (instead of * 20 as before).

Just to clarify this: I'm still in the "messing around and collecting ideas" stage. I don't consider any of my changes anywhere near final, meaning I really don't care that fire will come out in a few days and I'll have to start over from scratch. I keep starting over from scratch! I'm learning what works and what doesn't.
Sounds pretty good. Personally, I'd be tempted to make the initial random value dependent on difficulty level (so it would be large at low levels, and small at high levels). I don't think that's essential, though; at worst, we penalize the AI further at the lower levels.
 
That log was an interesting read, Bringa. I found one obvious (but perhaps not too important?) flaw in the AI-logic

[996793.625] Found a unit that is enabled by this tech. (+200). Now looking at its military value. Before that (and after the flat 200), iValue is 3164
[996793.625] This is a ATTACK_SEA unit. +300 to military if we have a warplan, +200 if not. military and value are now 200 and 3164
[996793.625] Our capital is alone. Multiply the military value of the unit by 2/3. It is now 133
[996793.625] MilitaryValue added to Value. Value is now 3297
[996793.625] This was the first unit with this unit AI type for the AI. Added 200 to value, which is now 3497
[996793.625] Found a unit that is enabled by this tech. (+200). Now looking at its military value. Before that (and after the flat 200), iValue is 3697
[996793.625] This is a ATTACK_SEA unit. +300 to military if we have a warplan, +200 if not. military and value are now 200 and 3697
[996793.625] Our capital is alone. Multiply the military value of the unit by 2/3. It is now 133
[996793.625] MilitaryValue added to Value. Value is now 3830
[996793.625] This was the first unit with this unit AI type for the AI. Added 200 to value, which is now 4030
[996793.625] Found a unit that is enabled by this tech. (+200). Now looking at its military value. Before that (and after the flat 200), iValue is 4230
[996793.625] This is a ATTACK_SEA unit. +300 to military if we have a warplan, +200 if not. military and value are now 200 and 4230
[996793.625] Our capital is alone. Multiply the military value of the unit by 2/3. It is now 133
[996793.625] MilitaryValue added to Value. Value is now 4363
[996793.625] This was the first unit with this unit AI type for the AI. Added 200 to value, which is now 4563

You can see, that it always adds 200 for getting a first unit with ATTACK_SEA also it should just do it for the first one.
 
Back
Top Bottom