Merge Better AI with FFH2 request

prezze

Chieftain
Joined
Feb 27, 2009
Messages
2
Has anyone tried to merge Better AI with FFH2? I know the minor leader mod is trying to do that as we speak but i'm looking for a merge without involving any modmod's, just good old FFH2.

I have no idea how hard it is or how much time it will take but if anyone can make it happen you will be my personal hero until the day i die and that HAS to count for something :mischief:
 
My modmod (when I get the next version released) you can play without any modded effects.

1. If you want just the DLL, you can copy it over. There are no changes in the xml.

2. Or you could play a custom game with no Minor leaders, and it's strictly FFH

Either way. But I need to get a solid release, and am working on that.
 
Very happy, just got the Sea AI to work well. The whole thing is now working. Haven't released it yet, but I'm quite happy.
 
It doesn't work with the main mod for starters without some changes. Core FFH code, it does not function.
 
FFH=/=BtS You need to program different AI. UNless they somehow created a better AI by making it LEARN (that isnt very realistsic...), then you are looking at a totally different mod.
 
That isn't quite true. I have completed the merge from Better AI into FFH. The problems stemmed from Kael's quick fixes because the AI didn't work to make it not as bad more than any FFH to BTS code.

I mean, the AI for FFH is just BTS AI with some additional promotion checks, and some other misc edits.

It takes quite awhile to merge, but it isn't like a different language or anything.
 
I'd suggest playing a custom game of my Minor Leaders mod and not using any Minor leaders for now. I plan on making additional specific AI changes to make the DLL just work.

Particularly, Crews. I couldn't get Crews to work on boats, so I made all boats +1 cargo. I need to fix the crew issue, and have them assign crews based on their unitai
 
There were several issues. I didn't merge most of the Air code. You have to keep all of Kael's edits around, and manually read through them since a lot of them affect boating since the AI doesn't work.

I also merged all of Xienwolf's tweaks that were relevant from Fall Further, so there was that consideration as well.

And then I merged Snarko's Boat AI which helped even further.

All in all, you have to understand what you are doing, how it conflicts, why, etc.

I didn't understand what I was doing when I started, but I do now putting in many hours understanding how the DLL actually functions.
 
Oh, and then you have to run many auto plays. Look at the Unitai as it's built. Watch it closely. Follow it around.

Watch if an AI is planning an attack. How it plans. Why.

A lot of pieces, but I'm quite happy how it came together.
 
Main potential issue would be if there are "we need planes!" type of considerations

Crosspost response: To make crews work by unitAI, modify CvUnitAI::AI_promotionValue

I did. Here are the current changes I have for Crews.

Enable Crews in the XML to be AIable
Verify the unit you are trying it on isn't blocked for that crew type

Then this in the DLL from Snarko's options mod.

Unit.cpp
Code:
            if (GC.getSpellInfo((SpellTypes)iSpell).getRemovePromotionType1() != NO_PROMOTION)
            {
                //Snarko 16-11-2008 MODOPTION_BETTERSEAAI Start
                //Don't count promotions we don't have as being lost. For ship crews.
                //(are these neccessary? Try without them sometime)
                //iValue -= AI_promotionValue((PromotionTypes)GC.getSpellInfo((SpellTypes)iSpell).getRemovePromotionType1());
                if (!GC.getSpellInfo((SpellTypes)iSpell).isBuffCasterOnly() || isHasPromotion((PromotionTypes)GC.getSpellInfo((SpellTypes)iSpell).getRemovePromotionType1()))
                {
                    iValue -= AI_promotionValue((PromotionTypes)GC.getSpellInfo((SpellTypes)iSpell).getRemovePromotionType1());
                }

                //Snarko MODOPTION_BETTERSEAAI End
            }
            if (GC.getSpellInfo((SpellTypes)iSpell).getRemovePromotionType2() != NO_PROMOTION)
            {
                //Snarko 16-11-2008 MODOPTION_BETTERSEAAI Start
                //iValue -= AI_promotionValue((PromotionTypes)GC.getSpellInfo((SpellTypes)iSpell).getRemovePromotionType2());
                if (!GC.getSpellInfo((SpellTypes)iSpell).isBuffCasterOnly() || isHasPromotion((PromotionTypes)GC.getSpellInfo((SpellTypes)iSpell).getRemovePromotionType1()))
                {
                iValue -= AI_promotionValue((PromotionTypes)GC.getSpellInfo((SpellTypes)iSpell).getRemovePromotionType2());
                }
				//Snarko MODOPTION_BETTERSEAAI End
            }
            if (GC.getSpellInfo((SpellTypes)iSpell).getRemovePromotionType3() != NO_PROMOTION)
            {
                //Snarko 16-11-2008 MODOPTION_BETTERSEAAI Start
                //iValue -= AI_promotionValue((PromotionTypes)GC.getSpellInfo((SpellTypes)iSpell).getRemovePromotionType3());
                if (!GC.getSpellInfo((SpellTypes)iSpell).isBuffCasterOnly() || isHasPromotion((PromotionTypes)GC.getSpellInfo((SpellTypes)iSpell).getRemovePromotionType1()))
                {
                    iValue -= AI_promotionValue((PromotionTypes)GC.getSpellInfo((SpellTypes)iSpell).getRemovePromotionType2());
                }
				//Snarko MODOPTION_BETTERSEAAI End
            }

and

UnitAi.cpp
Code:
    //Snarko 17-11-2008 MODOPTION_BETTERSEAAI Start
    iTemp = GC.getPromotionInfo(ePromotion).getCargoChange();
    if ((AI_getUnitAIType() == UNITAI_SETTLER_SEA) ||
		(AI_getUnitAIType() == UNITAI_MISSIONARY_SEA) ||
        (AI_getUnitAIType() == UNITAI_SPY_SEA) ||
        (AI_getUnitAIType() == UNITAI_CARRIER_SEA) ||
        (AI_getUnitAIType() == UNITAI_MISSILE_CARRIER_SEA) ||
        (AI_getUnitAIType() == UNITAI_CARRIER_AIR))
    {
        iValue += (iTemp * std::max(10, (50 - cargoSpace() * 10)));
    }
    else if (AI_getUnitAIType() == UNITAI_ASSAULT_SEA)
    {
        iValue += (iTemp * 50);
    }
    else
    {
		iValue += iTemp;
    }

I'm going to give it another try and see. It just wasn't working for me.

Still not working. I also have the promotion's at aiweight 100 and the spell at aiweight 100
 
One is working. I think the weight for attack is much higher than the weight for cargo, which makes the choice of skel not happen. I'll mess around with it.

Other issues are, if the AI Svalt casts Veil of Night, they are screwed on island maps because they can't be cargo as HN.

I need to implement a removal of HN for them so I can have them remove HN if they plan on being Cargo.

There are other issues around. I need bug testers to help get the kinks out. It's significantly better, but every play of it I find something else to fix. Usually 3 or 4 things.
 
I've only played about 150 turns quickspeed so far, but I'm amazed. I've been playing at NOBLE ( piece of cake ) without no AI building reqs or no AI min lvls , and the AI is actually able to keep up with me ( faeryl, and I'm having a very successful game ) . I'm first but not by unreasonable margin. and we all know how bad the AI used to suck at noble, right? :lol:

brilliant job notque, thank you :) . if there's something I can do to help findind issues or whatever, feel free to ask. ;)
 
I'll keep an eye out for your worker issue, but I feel like other issues are more important right now. Things that actually breaks the AI's logic.

I'm not satisfied with quite a few things. Yes, it's tons better, but the AI can be improved a lot.
 
Though this dooms you to start finding 30 or 40 things to modify each play through, I'll point you toward "chipotle" and making modifications to your DLL to enhance the displays available through CheatMode. Expose the right values in the right places and you open up a whole new level of snooping in the AIs brain. If you grabbed my tweaks you probably already have quite a few new toys available, but one thing you could add (I just haven't decided WHERE to add it myself yet) is a display of the AI_Weight for each promotion (best place is probably in the standard promotionHelp display, and make it base the weight value off of the current HeadSelectedUnit (so no display if no selected unit).
 
I have chipotle, and I have a lot of displays through CheatMode. An AI_Weight for each promotion would be excellent.

The other one I need to add soon is the display for the AI's actions. When they are planning a war. What the likelyhood is, etc.

That's my goal for tonight.
 
Wow, I just read through how the XML's for leaderheads work concerning wars, and how all of that works. Wow.

Power isn't a concern for war reasoning. 1 of the XML tags doesn't even have code assigned to it.

What a lot to take in.
 
Back
Top Bottom