AI never buys resources?

  • Re: Dragon War - Official Thread


    I've played Dragon War for many hours, it's very nicely done game! However, because I want to make my own game, I wanted to see what I could improve in existing games, so..I've chosen Dragon War for the start (and for myself only). I added food consuming and food production as an addition to existing units (for ex.: units produce -1 Food or -1 PUs and Towns are producing some resources).

    Game worked very well for me, but AI wasn't interested in resources at all. So, I returned to the original game and checked it on Hard AI... AI is not interested at all in buying food, metal od wood... Also, AI doesn't bother buying any upgrades (I understand that AI isn't with upgrades yet) or resource producing units... AI NEVER buys any resources and usually after dozens of turns AI gamers ends with thousands of unused PUs.

    Do you have any idea how to force AI to consider (even with some "tricks") buying resources or units/buildings producing resources? I've heard that AI is considering purchases based on att/def stats and places on the map, also "IsInfra" apparently is a thing?

    Any ideas?

    Thank you for the fantastic game and Have a Nice Day!

  • @comr HiComR You could try asking @redrum . He codes the AI. You could also ask @Frostion I think this is his map. I don't quit remember though

  • @beelee Hi,

    Thank you for the tips. I prefer not to PM anyone, but I wrote also on AI thread. I will take a look at source code, maybe I could be useful one day?


  • @comr heh heh always can use a coder The @ thingy will notify them and they'll probably reply sooner or later. Probably sooner : )

  • @beelee Oh, ok, thank you. Stupid me! :)))) Now I understand... šŸ˜‰

  • Admin

    Yes, right now the AI cant/won't buy resources. Hopefully this will be possible in the future.

    A trick I think might work (if you want AI to buy resources now) is to make some resource-generating land units that must be purchased with PUs/Gold and placed by a factory. Example; a land unit called "Wood" that is purchased and placed at a town, and by/before player end turn it generates 10 Wood for the player. After the same player end turn, all of the same player's Wood/Food/Metal land units are removed from the map.

    The technology development in Age of Tribes works like this.

    But we must note that the AI, if it purchases like this is doing it in a mindless manner. It is totally random and it has no intention of buying resources. On the positive side, if the AI has a ton of PUs that it can't use because of a lack of other purchase resources, then I guess any random purchase is better than AI having unspent resources in the bank.

  • @frostion Fantastic! Thank you... I will try the Age of Tribes.

  • Admin

    Yeah, the AI will not currently buy resources as it doesn't understand the value of anything but PUs when purchasing. Only way to make the AI purchase something is have resource generating units that have low PU cost and high attack/defense/movement/hitpoints. You could then consider using triggers to remove the units or remove their combat stats. This is pretty much a hack though and at some point the AI purchase logic will be rewritten to better handle non-PU resources.

  • @redrum Ok, so, I understand that people who originally wrote TripleA source code are not here anymore and we have no idea how to change engine without harming whole work of many others?

    BTW. Thank you for the tip, I will try to use it! And yes, random buy would be better than holding all that money... But... I still have no idea how to force AI to buy random stuff or any - just because AI have too much money...

  • Admin

    @comr Well the original developers have moved on but there are about 4 of us developers that are making changes to the engine. Here is a list of things that have been added/improved recently: You can also view all the changes in the github repo PRs/commits:

    The AI will always try to spend all of its PUs if there are available units to buy. If those units require other resources and it can't afford them then currently there isn't anything it can do. You'd need to provide some unit that it will buy that then generates other resources or is triggered for resources or provide some weaker PU-only units that the AI can spend extra PUs it has on.

  • @redrum Thank you, I saw these, but it's looong list and it's new every few days for now - good, it seem alive! šŸ˜‰ But, I missed a lot in the middle - this is my problem. Regarding AI, I have few simple ideas, I wrote it, but... deleted it all before posting, because I do not know how AI work exactly, so I would like to read source code (or pseudo code - if algorithms are written that way?). I have some simple ideas, but I'm not sure if it would be so simple to implement.

  • Admin

    @comr Best thing is to play some of the new/complex maps and read the POS2 XML to understand what is available today:

    The AI overview and backlog of improvements are here: I wrote all of the Fast/Hard AI so know all of the algorithms/code for it. It was primarily written to play the standard A&A maps (classic, revised, v3, global, etc) so it performs reasonably well on maps that primarily use similar rules. But if you try to have the AI play Total World War or Civil War, it plays very poorly and doesn't understand many of the features used in those games. Suggestions and contributions are always welcome and you can find the AI code here:

Log in to reply