.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

Raging Tiger- Save $9.00
winSPMBT: Main Battle Tank- Save $6.00

   







Go Back   .com.unity Forums > Illwinter Game Design > Dominions 2: The Ascension Wars

Reply
 
Thread Tools Display Modes
  #1  
Old November 28th, 2005, 01:05 PM

RedRover RedRover is offline
Corporal
 
Join Date: Feb 2004
Posts: 165
Thanks: 0
Thanked 0 Times in 0 Posts
RedRover is on a distinguished road
Default AI: Castle Building Algorithm

I said a while back I would dig this out. I developed it while testing material from Arralen's thread a while back that played with AI concepts.

These thoughts are not in any sort of code, because coding isn't a big skill of mine. So this material is more of a player-imposed discipline for use when trying to play like the AI.

Ever try to play exactly like the Dom 2 AI?
IT'S REALLY HARD!

It's very easy to mix up steps, forget something, or get a procedure out of order. Those who want to experiment should check out the original thread: Post#305932

The material below may be somewhat dated now, since the devs have revealed that in Dom3 the AI will build forts, but this might also spark a discussion about how we as players choose if and where to build forts.

Revised Fort-Building Algorithm

Create FORTFUND
(this is money saved for the purpose of castle building)

Create FORTVALUE
(this is how likely the algorithm is to build a castle)

FORTVALUE = (Number of Friendly Provinces / DIFF) - Number of Friendly Forts

Impossible DIFF = 2
Difficult DIFF = 3
Normal, DIFF = 5
Easy, DIFF = 8

FORTCOST is the listed gold cost for the fort type.

IF FORTVALUE > 0
AND FORTFUND < FORTCOST
THEN move (Treasury * 0.5) to FORTFUND
where Treasury = (Income in gold - Upkeep)
(no build this turn, not enough money, save)

IF FORTVALUE = 1+,
AND FORTFUND > FORTCOST,
THEN go to BUILDFORT
(now we're cooking!)

BUILDFORT
BUILDCHECK PRIORITY
* Province with Black Candle
* Province adjacent to Black Candle
* <random 50%>
* Lowest to Highest Province number
* Highest to Lowest Province number
(while Dom2 seems to go lowest-to-highest fairly consistently as a tie breaker, reversing this randomly is one way to keep players from tracking the AI pattern easily)

BUILD on 7+ IF no fort in prov
3 provinces from nearest fort (any)** +3
rare magic site (summon, ritual bonus) +2
only 2 land neighbors (IF land prov) +2
only 3 land neighbors (IF land prov) +1
Black Candle in province +1
lab in province +1
temple in province +1
special troop type (amph, flyer, stealthy) +1
special commander type +1
indy troop type res>14 +1
each (15 * scale) resources in prov. +1
each ( 30 * scale) gold at 100% tax in prov. +1
per victory point of prov. +1
less than 20 res -1
closer than 3 provinces to a fort** -1
only 1 neighbor province (IF land prov) -2
1 adjacent fort** -2
each add’l adjacent fort** -1

(apologies for not being able to duplicate column format on this list)

**includes forts under construction, known enemy forts, and revealed fort sites.

notes: The (x * scale) numbers refer to base values unaffected by scale. Otherwise, a very high or low Order or Production scale will throw the algorithm off.

I'm not sure how good this is for underwater nations, my gut feeling is that further refinements in this respect may be desirable.

Anyhow, when roleplaying the AI, you simply pick a DIFF level and check provinces for opportunities when the proper conditions line up.

While it might look like there are a lot of pluses on the BUILD list, responders are encouraged to actually try the algorithm in play before commenting.
Reply With Quote
  #2  
Old November 28th, 2005, 02:42 PM
Endoperez's Avatar

Endoperez Endoperez is offline
National Security Advisor
 
Join Date: Sep 2003
Location: Eastern Finland
Posts: 7,110
Thanks: 145
Thanked 153 Times in 101 Posts
Endoperez is on a distinguished road
Default Re: AI: Castle Building Algorithm

I would use sites' effects instead of their rarity when calculating the costs. So, gem income, recruitable units/commanders, summonable units etc would increase the favorability (of building a fort in that provicne), disease, negative scales, horror attacks etc. would devrease it.

I haven't tested it, but I have a feeling the AI might start building castles into provinces it has no hope of being able to hold... So the province would HAVE to have at least one friendly neighbour, and having 2-3 would be preferred.

Also, what can FORTFUND be used for, and is the remainder in FORTFUND transferred to normal treasury whenever a castle is built?
Reply With Quote
  #3  
Old November 30th, 2005, 03:09 AM

RedRover RedRover is offline
Corporal
 
Join Date: Feb 2004
Posts: 165
Thanks: 0
Thanked 0 Times in 0 Posts
RedRover is on a distinguished road
Default Re: AI: Castle Building Algorithm

Endoperez: FORTFUND is just a sort of virtual holding bin for money saved out for fort building. So, no, this money stays in the bin until it is used, any extra will theoretically be held for the building the next fort. It may be that an operation to return funds in excess of FORTCOST or maybe (2 * FORTCOST) to the general treasury would be an improvement. I suggest the latter for initial testing.

If you are testing this, you should be keeping a side note of the FORTFUND, keep comparing it to your unspent funds, and be very careful not to spend any of it for other purposes--that would blow the test.

I suppose you could cap the fort-building at some number as well. Have it check the number of forts it owns against a limit. Maybe derive the limit from a formula based on number of provinces in the game and number of nations in game.

I do agree that site effects rather than site rarity should affect fort building, but I also think that many site effects are not worth a bonus in this algorithm.

I would consider a 4+ gem site worth a +1; special troop and commander provinces are already covered.

I'm not sure that the AI would be building in places it couldn't hold, any more than a player in the same circumstances would be. It's not as if the player can see the AI building anything and mass against it. (Of course, if the player has a copy of the routine the AI uses, this is a major cheat as it makes the AI far too predictable.)

I look forward to a test report.
Reply With Quote
  #4  
Old November 30th, 2005, 10:03 AM
Endoperez's Avatar

Endoperez Endoperez is offline
National Security Advisor
 
Join Date: Sep 2003
Location: Eastern Finland
Posts: 7,110
Thanks: 145
Thanked 153 Times in 101 Posts
Endoperez is on a distinguished road
Default Re: AI: Castle Building Algorithm

A 4-gem site would be worth a +1, yes, but so would 4 1-gem sites, wouldn't they? It might have to be worded differently, like:

each 4 (5? 6?) gems received from the province: +1

Would this be better?
Reply With Quote
  #5  
Old December 1st, 2005, 01:07 PM

boltcutter boltcutter is offline
Private
 
Join Date: Oct 2005
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
boltcutter is on a distinguished road
Default Re: AI: Castle Building Algorithm

I don't know much about how the AI places troops- would it be possible to put an "extra army" in a place that is being castled?

This is to prevent the AI losing forts before they're completed. . .
Reply With Quote
Reply

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 12:17 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2024, Shrapnel Games, Inc. - All Rights Reserved.