![]() |
SUGGESTION: AI castle building algorithm
This is a part of the troop building suggestion
------------------------------------------------ Build castle IF money=1.2*(castle cost) OR desirabilty>7 CHOOSE prov with highest "desirability points" a) has indie troop with (ress. cost)>14 2pts b) will give (combinedress)>66 [BASE w/o scales] AND isn't next to another castle 1 pt OR (combinedress)>99 2 pts c) has site with allows special troops 1pt has site with allows special commanders 2pts d) has 4 land neighbours, of which 2 are not owned AND not neighbouring owned provinces 1pt f) would have 2 castle neighbours -2 pts ------------------------------------------------ I'm not shure if a-d wouldn't need a nation-specific weighting, but I tried to get along without anything such. This would keep the code compatible not only with any nation/themes but any thinkable mod, too. (At least most of them, admittedly) [ April 16, 2004, 06:52: Message edited by: Arralen ] |
Re: SUGGESTION: AI castle building algorithm
Your castle building policy may also be dictated by your castle choice: If you bought something like a Wizard tower, or just kept the default watch tower, as I often do, the castle building decision quickly becomes simpler:
IF PROVINCE DOES NOT HAVE CASTLE BUILD CASTLE Combined with a solid defense plan, it will render the life of any invader into a living hell of urban warfare. |
Re: SUGGESTION: AI castle building algorithm
Wow, I dont understand a damn thing about programming and whatnot, but you definately are the man.
(Um hoping you are male, here.) Um: wow, thanks. That sounds great. Imagine, real AI enemies! yum.... |
Re: SUGGESTION: AI castle building algorithm
Quote:
Build castle IF money=1.2*(castle cost) will take care of this very well, but only testing in a "real life" will show. Any takers? Can't do much testing myself, as time is limited and there's so much to do ... http://forum.shrapnelgames.com/images/icons/icon12.gif |
Re: SUGGESTION: AI castle building algorithm
Quote:
|
Re: SUGGESTION: AI castle building algorithm
I can't do a thing about how the AI fights, but I did put in a "moneysaving turn" now and than so the AI will have the money available from time to time to build a castle. Check out.
|
Re: SUGGESTION: AI castle building algorithm
Sounds good. I like the logic so far. Seems to take into account everyones favorite tactics (except chokepoints but the logic on that would be difficult)
I wonder how much "thinking" this would take. I usually comment that it doesnt matter how long it takes a turn to process because its a "pass turn file to host" type game. But AI improvements mostly affect solo players and improving the AI would do any good if it changes the game to something too slow to hold their attention. |
Re: SUGGESTION: AI castle building algorithm
"thinking costs":
I'm concerned about the needed cpu time to re-calculate the "desirability" for each province each turn. Maybe I can come up with a simple solution that generalizes most cases when you can barely build a castle but prefer to do so over building troops. choke points d) has 4 land neighbours, of which 2 are not owned AND not neighbouring owned provinces .. doesn't this qualify? [ April 16, 2004, 14:35: Message edited by: Arralen ] |
Re: SUGGESTION: AI castle building algorithm
Quote:
1) Limit amount of gold spent on non-castle provinces (relative value, maybe 30% or even less). That way if AI has enough gold income and too few castles he will generate surplus in gold and wont spent it all on weak easy-to-lose units (Militia, LI). That will allow him to build as much national units as he can and still be able to generate some surplus to build new castles. If AI spends all money on national troops and can’t afford new castle, then he doesn't build new one anyway at least with his current income. I believe Jasper proposed something like this in LI thread and I like this idea better simply because it will maximize production of national troops without going too deep into unit production scripting. 2) When AI has enough gold to build castle he should decide where to do it. Your proposal is quite good, so I would add only 1 thing there. When deciding for where to build castle AI should take into account ALL neighbors, not only the ones he controls. That way he will be building forts on bordering provinces if they are good, without need for special algorithms. As for slowdowns, I don't think they should be significant since AI revalue his provinces only when he has enough gold to build castle, not every turn. [ April 16, 2004, 15:23: Message edited by: Daynarr ] |
Re: SUGGESTION: AI castle building algorithm
Quote:
- For a, are you counting commander units? *Many* standard indy commanders have a res cost > 14. Even aside from that, 2 pts seems to place a lot of desirability on having high-resource indep troops. I think this should probably be more nation-dependent. Ie: An indy province that produces heavy cav may not be much of a benefit for a nation that already has some good heavy cav units. - I think that b above has a potential hole where it could build new castles that share provinces with one or more other castles, thereby reducing *those* castles resources to unfortunate levels even though the new castle meets the criteria. Perhaps a check that all bordering provinces of the prospective castle site should have <= 100% admin after factoring in the new castle, or -2 pt desirability rating - I tend to emphasize putting castles at/near stable enemy borders. In d, I'm not sure what you mean by "... AND not neighboring owned provinces" ... neighboring what - enemies? I don't know if I'm missing the point, but I think I'd scratch that part so it could put castles on its borders. - Is there no point e on your list? http://forum.shrapnelgames.com/images/icons/icon10.gif - It might also be worth somehow factoring in some desirability for building castles at/near "where the action is". IE: The AI is probably better off building a castle near where its current main army is engaged than at some place on the other side of its empire. - Another thing to consider is that if the AI does start building castles anywhere near its enemies is that it should make sure it is capable of defending the province while the castle is under construction (to protect its investment), and will be able to defend the castle after it's built. It would be a bad thing if the AI starts building undefended or marginally defended castles that opponents could easily take and use for themselves to support their advance. - It might be worth setting some castle-to-province ratios, at which castle building becomes greater and greater priorities. Say: </font><blockquote><font size="1" face="sans-serif, arial, verdana">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">if (ctp-ratio < 0.1) // if less than 1 castle per 10 provinces save_income_percentage_for_castle(0.2) // save 20% of income towards castle else if (ctp-ratio < 0.05) // 1 castle per 20 provinces save_income_percentage_for_castle(0.5) // save half of income towards castle etc.</pre><hr /></blockquote><font size="2" face="sans-serif, arial, verdana">The numbers above are arbitrary, but you get the idea. This could allow a gradually increasing priority for castles as the AI expands, and also would allow the AI to save up for castles rather than just building them when it happens to have enough money or relying on occasional money-saving turns. |
All times are GMT -4. The time now is 12:04 PM. |
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2025, Shrapnel Games, Inc. - All Rights Reserved.