UnofficialCrusaderPatch / UnofficialCrusaderPatch2

Unofficial balancing patch installer for Stronghold Crusader 1
MIT License
430 stars 59 forks source link

An even stronger AI #513

Open Lolasik011 opened 4 years ago

Lolasik011 commented 4 years ago

@Sh0wdown @ByBurton @J-T-de @LordHansCapon @GRhin @Monsterfisch @Admiral-Gumpert @Krarilotus @Starshine575 @Russianstory @Truetobi91

Is there any way to strengthen AI and improve its behavior?

Starshine575 commented 4 years ago

@Lolasik011 as you probably know that you can change the parameter/castles/etc. Are you referring to the generell behaviour (e.g. troop movement) 🤔

J-T-de commented 4 years ago

Well, as Starshine575 said, you obviously have AIV and AIC edits. It would be possible to change the starting troops and the lords power, but these are not the droids you are looking for.

You could overwrite some AI routines (improve its behavior), but this is a really hard task. Alone to create the automatic marketplace was kinda hard, and here we don't have any resource prioritization (not checking what is important, but just buy/sell one resource after another). The AI is clever there and has lots of checks how to prioritize, therefore I only see small improvements there (You could allow to sell more goods per gametick, but this really feels awkward. You could also let the AI cheat, like infinite money, but well, I guess this is something no one wants for obvious reasons).

What could work if there are some bottlenecks in the behavior, which makes the AI significantly worse, for example the no sleep fix or the no demolish fix. But I don't know, are there any things like this left?

TL;DR: Only small things are feasible. And this needs player input.

Krarilotus commented 4 years ago

What i could see for a future update, would be to expose the behaviour parameters in an APi kinda style, where you then can plug in new behaviour via logic gates using those parameters. But thats definitly not easy, as you would need some kind of translater for a normal and easy to programm language into assembler and then a way to plug that into the game.

I would love for the AI starting troops and Lords power to be available for modding for the next release, as that would make the next AI-Contest, where i am planning an AI turnament, more balanced and easier to do. Right now i have the problem of figuring out, what to do if 2 people send in the same AI's and then they need to fight each other. As simply plugging the aic and castle of one AI into another ones place, doesnt solve the issue with the starting troops.

Admiral-Gumpert commented 4 years ago

@Sh0wdown @ByBurton @J-T-de @LordHansCapon @GRhin @Monsterfisch @Admiral-Gumpert @Krarilotus @Starshine575 @Russianstory @Truetobi91

Is there any way to strengthen AI and improve its behavior?

AIs use complex matrix of tasks , and the AIC file does identify a great number of what the AI does , but we need to identify them all to understand the AI better , But for now we have reached such a great level of editing and modifying them btw , And in my opinion if someone wants the AI to reach a huge level of efficiency and overall attack and defense he will start to design his castle first then he will change the AIC pramaters to fit its needs , Also fear factor affects the AI hugely , as he will produce nearly everything at double the amount and the speed , But if maps are still as 400x400 (which are small if you want a huge improvement to the AIs) the overall improvement of the AIs will be slow as you will end up with an AI who will always build a wrong castle with closed spaces and a small efficiency due to a small size of the terrain.

Krarilotus commented 4 years ago

Yes you can identify more values, like when does the AI switch its power state between weak, default, strong and make those editable. Make the amount of ox tethers per quarry editable, make the switch flipt for how the AI recognizes enemys in front of their castle available for modding, when is an AI scared, when will it demolish its buildings, and why does it do that instead of sleeping them, when it still has plenty of gold?

Give the AI a better evaluation of what the player does and give it ways to react to it. The ultimate deal here would be, to make the AI adapt to the enemy by countering their strategy. Give the AI the option to repair towers, to buy wood and other ressources before recruiting sortieunits. Give the AI the possibility to micro its ranged units when there are melee troops approaching and let it kite with horsearchers. Give the AI the possibility not to move out with its units, unless it has a decent chance to kill enemies harassing forces. Give the AI the possibility to properly setup attacks and rally points, not moving in on a percentage and doing usefull stuff with the troops while rallying. If the rally point wasnt under an enemy tower it would be not loosing all its troops for free. Just basically make the AI less STUPID. And another really big thing in my oppinion: give the AI proper detection of buildable spots for siege engines. And use also shields on towers. Then it should also group them up with its army, use control groups and attack with many catapults at once.

Then you need an option for the AI to properly setup castles, not only scripted ones that are always the same. Give it more options where it can build stuff and give it a logic behind it, which makes sense. Like trying to wall off the area around it with proper map edge and unpathable terrain detection.

Lolasik011 commented 4 years ago

@Sh0wdown @ByBurton @J-T-de @LordHansCapon @GRhin @Monsterfisch @Admiral-Gumpert @Krarilotus @Starshine575 @Russianstory @Truetobi91

Since we're all interested Stronghold Crusader again. I think we can work something out together. And get to work on the next patch together.

JuGGerNaunT commented 4 years ago

@Admiral-Gumpert 400x400 map is unchangeable. Half of the game functions indirectly dependents on that value. @Krarilotus HowTo That is obviously not that stage when it has sense to discuss such drastic improvements.

Monsterfisch commented 4 years ago

@Admiral-Gumpert 400x400 map is unchangeable. Half of the game functions indirectly dependents on that value.

(joking btw pls don't kill me ;] )

ai strength doesn't necessarily have to be based on micromanagement if ai was able to be economically stable and use their resources more effectively that would go a very long way already aka small changes can go a long way and I think the changes done to the ai is already made it come quite a distance

like buying raw resources to produce weapons instead of buying the weapons directly all the time or make religion give a bigger bonus, so its actually a viable method of boosting the popularity maybe even have 2 priests for the church and 3 for the cathedral making both buildings better at blessing the population but limit the amount of them that can be built.

@Krarilotus it might be a good idea to set up a document or maybe even a Trello board were improvements like you proposed could be written down and sorted based on the complexity of implementation that way these suggestions would be more organized and in one place unlike now where they are spread all over the issue tracker. in that document, people with knowledge of how to implement such features could then rate them based on their knowledge giving us a better idea of what we can expect to be addressed in a reasonable amount of time/effort.

Admiral-Gumpert commented 4 years ago

@Admiral-Gumpert 400x400 map is unchangeable. Half of the game functions indirectly dependents on that value.

I already know that it's very unlikely or maybe completely impossible to be able to change maps to something bigger than 400x400 , Thats why I told him I made a whole new AIVs and AICs to be as good as possible on 400x400 maps

Krarilotus commented 4 years ago

@Admiral-Gumpert i have my efficient AI castle overhault in the prototyping stage right now. My new AIC will be constantly updated, and right now i got a version v1.2 for it (aggressive aic). But castles, to be perfectionized, will take a while to be made. i have put the newest aic here in this post: Krarilotus-aggressiveAI-v1.2.zip

@Monsterfisch quote: like buying raw resources to produce weapons instead of buying the weapons directly all the time

Things like that are already kinda doable with what we have in the aic right now. There you just set the weapons to be bought at once to a higher number, set the RecruitGoldThreshold lower, to be matching the amount of gold needed for one buy of raw materials, and you will end up with an AI that will prefer buying raw materials. The problem tho is, that Sortieunits, as of right now, are really breaking the other AI features. As they are not regulated at any point that i can see. So maybe we are missing a value here, or they are just straight up always bought first without restrictions. To prevent the sortie unit bleed (spam) you can therefor set them to a unit, that the AI can not recruit (likely to be monk or tunneler...). Which i also would like would be more threshhold parameters to be added to the AIC to switch between the current states. They are definitly somewhere in the exe, i just dont know how to work with cheat engine to find those.

I will make an updated Design for AI tutorial, including all the latest tricks that i know of, before it comes to my next AI Contest. If you want to learn more, you can watch that. But yeah, for the AI contest to be good, i really need someone to fix the BUGS that the patcher has right now. I would really love someone to just take care of that config settings bug, with the comma and dot, and the bug, where you can not save the AIC checkbox inside the patcher acordingly, when transfered to another PC. Even if the file names are the same. These should be easy? @LordHansCapon

And also i would very much appriciate getting the control over setting startunits for all the AI lords, for each gold setting in the game.

a format that would work for me would be this:

{   //one example of a start parameter configuration
    normalGame {
        Gold = [integer]
        Wood = [integer]
        Stone = [integer]
        Iron= [integer]
        Pitch = [integer]
        Hop = [integer]
        Wheat = [integer]
        Flour = [integer]
        Beer = [integer]
        Bread = [integer]
        Apples = [integer]
        Cheese = [integer]
        Meat = [integer]
        Spears = [integer]
        Bows = [integer]
        Pikes = [integer]
        Crossbows = [integer]
        Swords = [integer]
        Maces = [integer]
        LeatherArmour = [integer]
        IronArmour = [integer]
        Popularity = [integer]
    }
    crusaderGame {   //same array as in normalGame but with new values
    }
    deathmatch {   //same array as in normalGame but with new values
    }
}

{ //troop percentages from the values below, to balance for the different slider options:
    percentEnemyBigAdvantag =
    percentEnemySmallAdvantag =
    percentNoAdvantage =
    percentSelfSmallAdvantag =
    percentSelfBigAdvantag =
}

{   //one example of an AI array
    AIName = [string]
    ID = [integer from 0 to 15]
    AILordHealth = [integer for hp (or how ever that works]
    normalGame {
        unit1 = [enum for each available Unittype to be used aswell as None]
        unit1Amount = [integer
        unit2 =
        unit2Amount =
        unit3 =
        unit3Amount =
        unit4 =
        unit4Amount =
    }
    crusaderGame {   //same array as in normalGame with new values
    }
    deathmatch {   //same array as in normalGame with new values
    }
}
Monsterfisch commented 4 years ago

@Krarilotus i am most certainly interested as I would love to make my aic work better in those regards maybe you are even interested in talking about aic and aiv creation outside of the GitHub I can send you my discord id if you are interested

Krarilotus commented 4 years ago

@Monsterfisch sure any time. Maybe we can even collaborate on some future projects. The castles you made are impressive in regards of beauty and design.

my Discord is Krarilotus#6749. Dont worry if i dont reply right away...