Thread Tools
Old February 6, 2001, 16:40   #1
WesW
Apolytoners Hall of Fame
 
WesW's Avatar
 
Local Time: 03:59
Local Date: October 31, 2010
Join Date: Mar 2007
Location: Florence, Al., USA
Posts: 1,554
Conversations with Richard Myers (Azmel)
Richard Myers, if you didn't know, wrote the AI routines for Ctp2. He contacted me a couple of weeks ago and offered his help with an AI questions that I had. Needless to say, I was delighted to hear from him, and had many questions to ask. Below I have pasted Richard's answers to my first round of questions, which dealt with issues in the strategies.txt.

My questions were aimed at addressing problems or questions I had regarding the Med mod II, but I think his answers shed light on things that many of us have been wondering about. In his second letter, he covered some things that I am a little fuzzy on, so I would like for some of you who can expound upon these things further to post your comments and help me out. I have marked these areas with "Apolyton question".

In addition to posting Richard's answers, I want us to put our heads together and share notes and ideas of our own regarding AI problems still in the game. I read through the second patch wishlist a couple of days ago, and made notes on the issues that I would like for us here at Apolyton to get together and work on, since they affect gameplay in general. There are also some questions that others here have asked me to ask Richard, and I have posted those below as well so that we can work on them too.

NOTE: I want to restrict this thread to only those topics and questions raised in my initial posts here.

I will make another thread for other questions that any of you might have, and perhaps Richard will answer them when he visits the forums.

[This message has been edited by WesW (edited February 06, 2001).]
WesW is offline  
Old February 6, 2001, 17:18   #2
WesW
Apolytoners Hall of Fame
 
WesW's Avatar
 
Local Time: 03:59
Local Date: October 31, 2010
Join Date: Mar 2007
Location: Florence, Al., USA
Posts: 1,554
Here are the letters:

My answers are below, (see RM .
1. Strategies.txt -

1.1. Increasing the percent of workers dedicated to specialists
increases the impact of PopAssignmentElements. If players are
getting ahead of the AI by using specialists then this change
should help, otherwise it might overbalance the AI toward
specialists.

Reply: Actually, I decreased the number of specialists used, since from my observations with my own cities, you are better off not using specialists unless you have to.

1.2. By setting SliderElement Delta's to 0 you have told the AI to not
try and optimize sliders. When a player has mostly small cities
in the early game (or after getting beaten up) the AI can get a
jump start. However, if you have found cases where the automatic
slider settings are causing problems it might be worth creating
specific strategic states when the sliders get optimized.

WW: This change relates to changes I made in the govern.txt. I made
the per-notch penalties for moving the sliders 4 and -6, since the
1-point penalties were not enough to offset the advantages gained by
maxing out the sliders. Now, it should be like Ctp1, where you only
manipulated the sliders in cases of distress.

RM: If you take a look at my post http://apolyton.net/forums/Forum35/HTML/000554.html#6)
on apolyton you'll see a simple example of switching strategies based on a SLIC script. You can use the same basic concept to redefine the SliderElement deltas, but with one caveat. You must use the SetStrategicState (see 'Strategic State' section of ai-customization.shtml on Apolyton for why). You could change the slider settings of the base strategic state under specific conditions (like when a civ has only small cities for example).

2. Goals.txt -

2.1. You set the DistanceToHome bonus of the Seige goal to 250. This
number might have more influence than you want since the actual
bonus is computed by multiplying this value by the straight line
distance to the center of the players empire. The
DistanceToEnemy bonus is also computed this way, but all of the
others are normalized so that no goal receives more than the
specified value. For example, the enemy city most threatened by
foreign units will recieve a bonus of 500, and the enemy city
with half of that threat will recieve a bonus of 250. However,
an enemy city 100 cells away will receive a bonus of 25,000
compared to a city half as far will recieve a bonus of 12,500.
Such an out of scale bonus swamps the other bonuses and generally
leads to abnormal goal choices. Values of less than 10 are
advised here unless it's negative. The Chokepoint goal is an
exception since we really only want to guard chokepoints near
home.

Reply: Thanks for the explanation. Here I was trying to get the AIs to prioritize those enemy units/cities closest to its home, in hopes of encouraging the counter-attack ability I mentioned previously. I see now that I was just not figuring the numbers properly, and so I have changed the number from 250 to -10 for both the seige and attack modes. Thanks for seeing this, as it would have screwed up the game.

2.2. GOAL_BOMBARD should not have TargetTypes of both City and
AttackUnit/SpecialUnit. I can't remember exactly how the code
will handle this in all cases. Better to create a new goal,
perhaps GOAL_BOMBARD_ARMY that is identical to GOAL_BOMBARD, but
replaces TargetType:City with TargetType:Army and SpecialUnit.
You'll also have to add this new goal to all of the goal lists in
strategies.txt. Seems you found an oversite here; good catch.

WW: You can add new goals to the strategies.txt? I didn't think you
could add things that weren't already defined in the exe.

RM: Yes! You can add new goals. You'll create a new Goals.txt record and also add a GoalElement reference to it in each of the base strategies in the strategies.txt file. You could, for example, create two different attack goals with different force matching and priorities. The goals are created dynamically based on the attributes in goals.txt and referenced in strategies.txt by their record name in goals.txt.
2.3. FYI, GOAL_SALLY is not used at all and should have been removed.

WW: How about using this goal for the new Bombard_Army goal?

RM: No need really, just create new goals with appropriate names and hook them up.

3. Diplomacy.txt -
3.1. Your changes look reasonable, but I might also suggest that
creating specific diplomatic states is a good way to get leverage
on this aspect of the game. You trigger diplomatic states in a
similar way to how you trigger new strategic states. I can go
into more detail later if you want.

WW: I, and many others, would want more detail, when you get time.

RM: A good general description is available in the 'Diplomatic State' section of ai-customization.shtml on Apolyton. However, the basic idea is that you can define your own diplomacy states (like DIPLOMACY_PROVOKE_WAR in diplomacy.txt) and trigger them to be loaded from the diplomacy.slc file by defining a handler for the NextDiplomaticState event.

RM: You can also redefine specific diplomatic responses and new proposal triggers. The commented out handler in diplomacy.slc titled 'WantGoldAdvance_NewProposalEvent' is an example of how to make the AI consider sending a new proposal with high (1000) priority requesting a desired gold advance.

RM: If you can phrase a change to how the AI responds to a specific new proposal then I can probably tell you how to add a new handler to diplomacy.slc that will implement that change. For example, if you think the AI should never accept a cease fire within 20 turns of getting into a war or something like that, it's pretty easy to do.

1. WW: In the Force Matching section, does the AI include terrain and city
improvement modifiers in its calculations of the matching values, or
does it simply compare unit stats?

RM: The defense and terrain modifiers for a target army or city are
considered, but the terrain modifiers gained by a particular attacker
are not considered because it's not obvious what those bonuses might
be when the attacker gets close enough to attack.

Reply: Thanks for the insight. I seems like a guessing game as to what to set the matching values to. However, since most attacks are made along roads, and roads usually are made through flat terrain (no defense value), then I think it would be wise to assume that the attacker will not have a bonus most of the time.

2. WW: Next, please take a look at my changes to the unit build lists
categories in the Siege, Attack and Defense strategy modes. What I
have done is to let the AI build by using the standard lists in times
of peace, and then shift to specialty lists in times of war. I did
this in the hopes of tailoring the units the AI chooses to build to
better match the situation at that time. This resulted in tripling the
total amount of unit build lists that are listed in the
unitbuildlist.txt. Do you see any problems with doing this?

That looks fine. Good idea!

WW: Finally, would you mind if I posted these letters on the forums?
I would delete your email address, for obvious reasons, and I will
understand if you would rather not do it, or wait until we can covered
more things. Posting these will inform the other mod-makers, and
probably lead to good questions that I have not thought of.

RM: I have no objection to you posting my comments, but I don't want to raise expectations too high. If you want to triage what questions you think are most important to answer, that would be very helpful too. I'll be happy to do what I can to answer any questions I can.
Best wishes,
-- Richard

SECOND LETTER:

Wes,
The remainder of my answers to your questions are below:

WW: Then come the goals settings. I chose 600K as the critical value for the main goals. Settings above 600K are what I want the AIs to prefer in a given situation, and those below 600K should only be chosen if unable to accomplish the higher priorities. I chose 5K as the standard difference between goals. Do you see any problems with these settings?

RM: I think the 5K skip should be ok. The priorities set in the
strategies.txt file specify a base. All of the bonuses specified in
the Goals.txt file are applied to this base priority to come up with
what we call the goals raw priority. You'll notice that all of the
computations needed to compute the bonuses refer to the goal and not
to which particular army is executing the goal. The raw priority is
used to do a first pass sort of the goals which is used when applying
the MaxEval.

RM: All goals of a particular type are sorted based on the raw priority
and only the top MaxEval are matched to the valid armies for that goal
(ie. Attack goal only matches with armies that contain units that
CanAttack). This is purely an efficiency thing, so you can always
increase the MaxEval if you don't care about performance. Be warned
though that increasing this number can seriously impact turn speed for
goals like attack that are executable by many different armies.

RM: For each army matched to a particular goal, a final utility is
computed by taking the raw priority of the goal and applying the
DistanceModifierFactor (from strategies.txt) multipied by the distance
in number of turns the army is from the target of the goal (as the
crow flies, not path length). The number of turns is an approximation
that takes into account how many cells a given unit type can move each
turn. We call the final value the Matching Value for the goal-army
match pair. All matches for all goals are sorted into a big list and
are executed from highest to lowest. Armies can be matched to
multiple goals, but if they have been executed by a higher matching
goal, they won't be executed for any other lower matches that might
exist.

Apolyton question: I am not sure exactly what Richard means with that last sentence, though his example a little ways below with the 5 armies did clear some things up for me.

RM: The reason I say 5K should be ok is that with such a value, goals
will execute mostly based on the raw priorities, but will still use
armies that are far for the action for other things. The MaxExec
parameter from strategies.txt will also ensure that not all armies are
doing the same thing.

WW: Ideally, I want an AI that will shift from one goal
to another if an opportunity presents itself, or if the strength of
the opponent changes suddenly. What I don't want is an AI that is
indecisive, and ends up moving back and forth but never accomplishing
anything. An example of the ideal would be an AI that would
counter-attack and re-take a fallen city if it had a stack strong
enough to defeat the opponent, who is often weakened by his assault.

RM: The AI should take advantage of opportunities as you describe, but
there are many factors that come into play. The best way to tune for
this situation is to create some small test cases using the scenario
editor. Create a reproducable situation where the human can take an
AI city, but lose enough units that the AI should retake the city. By
tweaking the force matching and goal priorities you should be able to
improve the AI's ability.

Apolyton question: This next comment below is a big one, imo.

RM: Another potential problem that may occur is that when the AI units
are tasked, they retain those orders until interrupted or until
certain specific events occur to clear them. You might consider
writing a new slic event handler triggered by the CaptureCity event
that calls the ClearOrder function all on all nearby armies. That
will make sure that they consider attacking the recently captured city
rather than what they might have been tasked to do last turn. Joe's
documentation on events and on the ClearOrder function should make it
clear how to do a brute force version of this that clears all orders.
The downside to clearing all orders every turn is, again, performance.
I considered on the highest difficulty level always clearing orders
every few turns, but never got a chance to implement this.

Apolyton question: Locutus, I believe, had asked before about clearing orders, and I think the above suggests that this is a good idea. What I would want is a trigger to clear all unit orders say, every 3 turns, and another trigger to clear orders whenever an AI civ loses one of its cities. If this is hard to do, then a trigger which makes the seige goal the highest priority whenever a city is lost may work just as well.

WW: Also, would you give me a brief explanation of what triggers the
goals the AI chooses in the game. I *think* I understand their
individual effects pretty well, but I still don't really know what
determines their choices in the first place. I am sure motivations and
desires enters into this, but how does it decide between attack, siege
and harass, for example.

RM: In your example, say you've got 5 armies and 2 of each goal
(attack, siege and harass). Matches will be made between each army
and goal (5 * 2 * 3 = 30 matches). If the attack goal has the highest
raw priority, then all 5 armies will execute attack goals. However,
if the MaxExec for attack is set to 2, then only the 2 highest attack
goals will get armies (as many as are needed to force match).
Assuming one attack goal needs 1 army, and the other need 2 armies,
then you'll have 3 armies left. Those will match to the next highest
goal, which might be seige. If the highest priority seige goal needs
more attack strength than the 3 armies you have, then the goal
will fail. On the next match cycle (there are 6 total match cycles),
the failed goal won't be considered, so the 3 armies will be assigned
to the next highest priority seige goal. If none of the siege goals
can be satisfied by the 3 armies, then the next highest matches might
be to harass goals which need very little matching strength so all
three armies might go to different harass goals.

Apolyton question: I start getting a little confused by the rest of his answer below. If someone could expound upon this, I would appreciate it.

You might see here
another potential source of problems. If there are many seige goals
that require more units than we have the system could run out of match
cycles before any valid goals are found. This is a trade off, and I
wish I had made the match cycles a parameter that could be changed.
But it can't be, so don't ask me. The best way to avoid this is to
make sure the MaxEval for goals that might often need more units than
you have to be low, like 2 or 3. However, if siege is your highest
priority, and you don't have enough units to do a successful seige,
the best bet is to not do anything until you build up your strength.

Apolyton question: I am a little confused by the recommendation to set things at 2 or 3. In the original strategies.txt, the MaxEval and MaxExec are both 25 for the Attack and Harass goals, and around 4 for seige and bombard. Does this mean that the original settings are way off, or am I mis-interpreting Richard's comments?

WW: On the Start strategies, are they determined by personality as far
as Careful or Aggressive? Also, how many turns into the game do they
stay in effect?

RM: Yes, the start strategies are determined by the parameters in the
personalities.txt file. They stay in effect for the whole game, but
you can write triggers that trump them later in the game.

Apolyton question: I definitely need a trigger to disable the start strategies after about 125 turns or so.

WW: On the Explore strategies, what is the difference between Far and
Wide, and what setting determines which of these is used?

RM: In the personalities.txt file (again) each personality has a
Exploration: setting. If Exploration: Minimal is set, then
STRATEGY_EXPLORE_NEAR is used, Exploration: Medium loads
STRATEGY_EXPLORE_FAR and STRATEGY_EXPLORE_WIDE is loaded by
Exploration: Wide. If the Exploration: Wide or Maximum are set, then
STRATEGY_AGRESSIVE_START is used, otherwise STRATEGY_CAREFUL_START is
loaded, btw.

WW: In the Improvement List Production, I added commerce improvements
to that list, and filled out the improvelist.txt to include all the
individual terrain improvements that I wanted the AI to consider. I
restricted the commerce TIs to terrains which could not support farms
or mines, so reduce possible conflicts. Do you see any problems with
this?

RM: Your changes look fine. My one caveat is that there is some logic
that tries to build goalgold improvements preferentially only on cells
that produce gold and not food or production. The logic looks at the
food rank of a cell, and if it's low, looks at the production rank, if
that is low, then it looks at the gold rank, if that's reasonably
high, it tries to build a gold improvement. In retrospect, the logic
should have done the check for whether a food/production improvement
was even possible before considering food/production improvements.

Apolyton question: We will need to keep track of what the AI does in this area during the beta testing.

WW: In the Goal Defend element, would it be wise to up the maxeval and
max execute numbers from 2 and 1 to 4 and 2, respectively?

RM: For the Goal Defend, it's evaluating 2 defend goals *per city* and
executing one per city. They could actually be MaxEval 1 per city and
MaxExec 1 per city since you never have more than one defend goal per
city anyway. The important thing to note is the PerCity tag at the
end of the line.

WW: I changed the fear and desire motivations for all the AI
types. Looking at the ones for the Scientist, for example, do you see
any problems with them? One thing I wanted to address was the fact
that a militarily stronger AI would often not attack the human,
presumably because the human was strong scientifically or financially.

Apolyton question: This answer is very important, imo.

RM: The motivations are only used for computing which new proposals an
AI should make, so I don't think this gets at what you want. If
you want the AI to ignore economic strength when determing if it
should want to be at way, that's tougher. However, if you force the
AI to declare war and make sure the diplomatic state for the AI (in
diplomacy.txt) will refuse peace that should do what you want. So how
do you foce the AI to declare war? Sigh, I have a function to do
this, but I forgot to expose it via SLIC. However, there is a fun way
you can do this. Create a new goal (maybe called
GOAL_PROVOCATION) that looks a lot like an attack goal, but in which
the TargetOwner: is ColdEnemy rather than HotEnemy. This will cause
the AI to preemptively attack, and once at war it will stay at war as
long as it never makes or accepts a ceasefire. You'll have to add the
goal to everyone, but only set it to have maxeval > 0 for beligerent
AI. You could also swap in a strategy specifically that enables this
goal only when the AI has military superiority.

Apolyton question: I would like a trigger to swap in a strategy that enables this goal when they have military superiority. I will set the MaxEval > 0 for Militaristic and Ecotopian AIs.

WW: In the build list sequences, I have made many changes to the
default settings. Please look these over for the Scientist, for
example, and let me know if you see any mistakes I made.

RM: In general these look fine to me, but Dave White (or lead designer)
might have comments about your choices, I'll cc' him on this too.

WW: Finally, at the bottom of the file, there is a list of Defense
Strategies. What triggers these? I know nothing about when they come
into effect, or how long they last.

RM: At the beginning of each turn, the Maximum Threat for an AI is
computed, and as the threat increases, the minimum garrison in each
city increases. Essentially this is a way to make sure the AI
protects its cities with more units when things get more dangereous
later in the game. If you add a new strategic state that is triggered
every turn (with a priority > 1000 or so) which redefines the garrison
counts, then you can use your own system. I forget the actual threat
levels and don't have the code available right now to check when each
level is invoked.

I hope this helps. I look forward to seeing what new and improved AI
strategies you and others will create!
-- Richard

[This message has been edited by WesW (edited February 08, 2001).]
[This message has been edited by WesW (edited February 10, 2001).]
WesW is offline  
Old February 6, 2001, 17:20   #3
WesW
Apolytoners Hall of Fame
 
WesW's Avatar
 
Local Time: 03:59
Local Date: October 31, 2010
Join Date: Mar 2007
Location: Florence, Al., USA
Posts: 1,554
Here are a couple of questions that Harlan and Locutus have asked before, and that I would like for us to work on.

> > The responses to your questions brought a couple of questions into my mind.
> > First, what is the scale of trust and attitude towards other civs, and second,
how can one check to see exactly where the other civs are on these scales?

But at any given time, there are concrete numbers for
each civ, not just general tendencies. For instance,
Civ2 might have a trust of 153 and attitude of 203 on
turn 5. So my questions are what are the ceilings and
benchmarks for those numbers? For instance, maybe you
can have a max of 1000 attitude, and anything over 800
means the AI wants to have peace with you. But who
can say with the info we've got? We're just groping
around in the dark. And my second question is how to
know exactly where each civ stands at any given time
on all of these. Instead of getting a vague notion
that a civ is "wary" of you, as a scenario maker I'd
want to know what the concrete number was. In the
pre-release, there was a debug version of the game
that had extra tools allowing one to find out stuff
like this, but now they're gone.

Here's a pipedream: maybe he could send us the final
debug version of the game, if he still has it?

Harlan

I have a question for Richard, in case you think feel like asking (it's no
problem of course if you want to edit it so it seems to come from you or
whatever).

I've been studying AI movement behaviour for Harlan's Alexander scenario.
During this testing I noticed that the AI makes movepaths to send units from
one point to another, just like a human player. But unlike human players the
AI doesn't seem to have the option to clear that movepath before the stack
reaches its destination and give the units another order if the situation
asks for it (tell me if I'm wrong about this though). The orders only seem
to be cleared when a stack encounters an enemy stack or something like that,
just as with human stacks.

Do you have any idea of what the effect would be if I used SLIC to clear
every stacks orders every turn? As I see it, this would force the AI to
re-analyze the situation every turn and give all its units new orders every
turn and thus all AI actions would be based on the latest information. I
realize this will probably make the AI slower but if the AI also becomes
smarter then this might be worth it. Would the AI actually become smarter?
Or would it just have less time to think over what actions to take and make
dumber decisions? Or would it have little effect at all? Are there any side
effects I may be overlooking?

Do you have any wise words on this or is your guess as good as any? I'm not
too much of an AI expert so I hope I'm not making a total fool out of myself


Wouter
WesW is offline  
Old February 6, 2001, 17:34   #4
WesW
Apolytoners Hall of Fame
 
WesW's Avatar
 
Local Time: 03:59
Local Date: October 31, 2010
Join Date: Mar 2007
Location: Florence, Al., USA
Posts: 1,554
Here are a couple of additional problems that I would like for us to work on. I gleaned these from the 2nd patch wishlist.

1)The AI does not appear to know how to use Fighters correctly, often letting them run out of fuel and crash. Otoh, I have seen it use Bombers correctly, and return them to base. I need a trigger to make the AIs return their planes to the nearest city, airbase or Carrier when they have used up half their fuel. There is already something in the game which changes the paths color from green to yellow, I believe, when this fuel point is reached, so hopefully a trigger can be made which is tied to this point as well.

2)I have changed several wonders in the game to give improvements in every city. I need a trigger that removes the option to build improvements if a civ has a wonder that grants that improvement to every city. This has been discussed before, but I don't recall the options to disable this "feature".
WesW is offline  
Old February 6, 2001, 19:07   #5
Dale
Emperor
 
Dale's Avatar
 
Local Time: 19:59
Local Date: October 31, 2010
Join Date: Dec 2000
Posts: 3,944
quote:


WW: I changed the fear and desire motivations for all the AI
types. Looking at the ones for the Scientist, for example, do you see
any problems with them? One thing I wanted to address was the fact
that a militarily stronger AI would often not attack the human,
presumably because the human was strong scientifically or financially.

Apolyton question: This answer is very important, imo.

RM: The motivations are only used for computing which new proposals an
AI should make, so I don't think this gets at what you want. If
you want the AI to ignore economic strength when determing if it
should want to be at way, that's tougher. However, if you force the
AI to declare war and make sure the diplomatic state for the AI (in
diplomacy.txt) will refuse peace that should do what you want. So how
do you foce the AI to declare war? Sigh, I have a function to do
this, but I forgot to expose it via SLIC. However, there is a fun way
you can do this. Create a new goal (maybe called
GOAL_PROVOCATION) that looks a lot like an attack goal, but in which
the TargetOwner: is ColdEnemy rather than HotEnemy. This will cause
the AI to preemptively attack, and once at war it will stay at war as
long as it never makes or accepts a ceasefire. You'll have to add the
goal to everyone, but only set it to have maxeval > 0 for beligerent
AI. You could also swap in a strategy specifically that enables this
goal only when the AI has military superiority.



Wes:
Through working with the diplomacy mod I found that you can totally bypass the motivation priorities in strategies.txt. This may work as a workaround for you. (Reminds me of the comments in tut2_msg.slc) For example: if you want to SLIC your own motivations, you make the priorities in the ConsiderNewProposal statements higher than the ones in the motivation ratings in strategies.txt. I can't remember where I read it, but the AI will only consider the 3 highest priority things.

IE:
I SLIC some ConsiderNewProposal statements that force the following:
DeclareWar priority = 1500
DemandAdvance prio = 1400
DemandGold prio = 1300

Motivations set the following in strategies.txt:
CeaseFire prio = 1100
OfferGold prio = 1000
MakeAgreement prio = 900

The AI will only consider the three highest prios which are DeclareWar, DemandAdvance and DemandGold.

Hope this helps in the proposal priority settings.

------------------
Author of Diplomod. The mod to fix diplomacy.

Rommell to a sub-commander outside Tobruk: "Those Australians are in there somewhere. But where? Let's advance and wait till they shoot, then shoot back."
Dale is offline  
Old February 6, 2001, 21:54   #6
Alpha Wolf
Chieftain
 
Local Time: 09:59
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
quote:

Originally posted by WesW on 02-06-2001 04:34 PM

2)I have changed several wonders in the game to give improvements in every city. I need a trigger that removes the option to build improvements if a civ has a wonder that grants that improvement to every city. This has been discussed before, but I don't recall the options to disable this "feature".


If possible, have the trigger also cause the AI to sell any existing redundant buildings. I know some people have expressed an interest in keeping this feature, so an alternative would be not to remove the possibility of building it but somehow distinquish it as redundant such as a colored font or asterick.

------------------
History is written by the victor.
Alpha Wolf is offline  
Old February 6, 2001, 22:38   #7
Dale
Emperor
 
Dale's Avatar
 
Local Time: 19:59
Local Date: October 31, 2010
Join Date: Dec 2000
Posts: 3,944
AW:
Maybe not so much as 'sell' these improvs as don't build anymore. It'll be a timewaste for the AI to sell these improvs and then find someone conquers the city with the wonder, or when the wonder becomes redundant. The AI will just have to rebuild them all. Just a suggestion.

------------------
Author of Diplomod. The mod to fix diplomacy.

Rommell to a sub-commander outside Tobruk: "Those Australians are in there somewhere. But where? Let's advance and wait till they shoot, then shoot back."
Dale is offline  
Old February 8, 2001, 14:35   #8
Locutus
Apolytoners Hall of FameCiv4 SP Democracy GameCiv4 InterSite DG: Apolyton TeamBtS Tri-LeagueC4BtSDG TemplarsC4WDG Team ApolytonCivilization IV CreatorsCTP2 Source Code ProjectPolyCast Team
Deity
 
Locutus's Avatar
 
Local Time: 11:59
Local Date: October 31, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
I've been studying the AI files and the all available info on AI on Apolyton (including Richard's emails) and I think I'm beginning to understand how the AI works. In this post I'll try to parafrase Richard's explanation since putting things on paper like this made things a lot more comprehensible for me and hopefully it will help others in undertanding this part of the AI as well. There's probably at least a few things I misunderstood or overlooked or whatever (some things I even had to guess about), so it's quite possible some of this is incorrect. If anyone (esp. Richard himself) can correct me where I'm wrong, that would be very helpful.

I'll explain this with an example. Let's assume this is the situation in the game at some point: there are 10 armies capable of attack (A1 to A10), only 3 goal types are defined (attack, siege, harass) and 3 goals of each type are present (a1, a2, a3, s1, s2, s3, h1, h2, h3). These goals represent specific actions, like Attack army near London (this might be a1) or Siege Liverpool (this might be s3). The various values I'm using are all based on strategies.txt and goals.txt as they were in the original game. I'm not saying these exact numbers can actually occur in a real game, most of them were chosen pretty much at random (without completely loosing track of what would be realistic though), but something similar to this might actually occur in a real game.

In original game priorities are following:

Attack: 405k (MaxEval 25, MaxExec 25)
Siege: 405k (MaxEval 20, MaxExec 4)
Harass: 500 (MaxEval 3, MaxExec 1)

For all goals in the game raw priorities are determined, meaning that the values of goals.txt are added to the base values in strategies.txt in the correct proportions. The formula looks something like this:

RawPriority(goal) = BasePriority(goal) + SUM(Priority(bonus, goal) * Mul) for all bonuses, with Mul >= 0 and Mul <= 1
(sometimes Mul is just 1 or 0, sometimes something in between, depending on what type of bonus it is - flat or scaled)

This results in a big list that is sorted on raw priority. It might look something like this:

Goal Raw Priority
s1 405199
a1 405187
a2 405134
s2 405084
a3 405078
s3 405058
h1 820
h2 712
h3 634

Since s1, a Siege goal, is the highest goal, all Siege goals will be evaluated first. Then all Attack goals will follow (since after Siege it is the highest goal-type on the list) and if needed the Harass goals will follow as last. So even though a1 has a higher raw priority than s2, s2 will be evaluated before a1. This seems like a rather odd thing to me, but that's what I understand from reading Richard's explanations (I read them over and over and over again but I can't make anything else of it).

Now the MaxEval number is applied to a sorted list of all Siege goals. Since MaxEval is 20 only the 20 goals with the highest priority will be kept and the rest of the list will simply be thrown away and not looked at anymore for this particular turn. In this case there are only 3 Siege goals so the list looks like this:

goal raw priority
s1 405199
s2 405084
s3 405058

Now all these goals need to be matched with all valid armies, all 10 armies in this case:

(s1, A1)
(s1, A2)
(s1, A3)
.
.
.
(s1, A10)
(s2, A1)
(s2, A2)
.
.
.
(s2, A10)
(s3, A1)
.
.
.
(s3, A10)


So 10 armies * 3 goals = 30 matches.

Now the Matching Value for all these armies needs to be determined. So for all these 30 matches, do the following calculation (and once that's done sort the list again, on Matching Value this time):

MatchingValue(goal, army) = RawPriority(goal) + DistanceModifierFactor * NumberOfTurnsFromTarget(army, goal.location)

RawPriority has been calculated and DistanceModifierFactor is -50 in strategies.txt and the game will use some (to us unknown) algorithm to find the NumberOfTurnsFromTarger, so the Matching Value can be calculated.

Let's say army A1 is 10 turns away from goal s1. In that case the formula looks like this:

MatchingValue(s1, A1) = 405199 + (-50 * 10) = 404699

The entire list might now look like this:

goal/army Matching Value
(s1, A3) 405049
(s2, A1) 404984
(s1, A7) 404949
(s3, A1) 404908
(s3, A5) 404858
.
.
.
(s1, A1) 404699
.
.
.
(s1, A9) 403799

Now all Siege goals are executed by the armies with the highest Matching Value. The only catch is that sometimes the Force Matching numbers of this army aren't sufficient. In that case other armies need to attack that same goal as well. The number of armies that will attack is the number of armies needed to match the Force Matching numbers. So if some goal requires 40 ranged attack points to Force Match and A1 and A2 are the armies with the highest priorities for this goal and A1 has a 23 ranged attack points and A2 has 18 points, then both A1 and A2 will attack these goals since only one of the armies doesn't have the required amount of ranged attack points and thus doesn't Force Match (this is presuming all other values match as well).

Since s1 is the highest goal on the list, as many armies from the list will be selected to Siege that particular goal as needed to match the Force Matching numbers (hereby the armies with the highest Matching Values are always picked). Let's say that in this case 2 armies will be enough. In that case A3 and A7 will Siege s1 (since those are the two armies with the highest Matching Values for goal s1). The next goal might need only 1 army, so A1 will Siege s2. Let's say s3 needs one army as well. Normally A1 would be the army to Siege it, but since it already Sieges s2, it cannot Siege s3 as well and will be skipped. The army with the next highest Matching Value for Sieging s3 is A5, so that army will do the job. No more than MaxExec goals can be executed but since there are only 3 goals this doesn't cause a problem in our case. The armies that aren't sieging (A2, A4, A6, A8, A9 and A10), will be available to Attack and if necessary to Harass (for both of which the whole process starting with making a list of all goals of those types of goals starts all over again). Let's say A2 and A6 Attack a1 and A4 and A9 Attack a2.

This leaves only A8 and A10 to attack a3. Let's assume however that they don't Force Match. Let's say 25 attack points are required to attack but A8 only has 10 attack points and A10 only 12. In this case a3 will be fail. Now all the goals need to be evaluated a second time to give all armies a goal. In this second pass s1, s2, s3, a1 and a2 already have enough armies assigned to them and a3 has been disabled, so the game will try to use A8 and A10 to Attack a4, should it have existed. If that would have failed as well a5 would have been evaluated, etc. This process can repeat itself 6 times, so if there are more than 6 Attack goals in a row which can't match the Force Matching numbers, no (additional) army will Attack, even if goal number 7 Force Matches easily. If this happens, the units not yet assigned to a goal won't get any goal assigned to them and do nothing for at least one turn (maybe they'll fortify). Another option might be that they'll still be available for other goals, like Harassing, but if that is the case I don't quite see why Richard presents this as a problem (it's not ideal but not really a problem either, if you ask me).
Locutus is offline  
Old February 8, 2001, 14:37   #9
Locutus
Apolytoners Hall of FameCiv4 SP Democracy GameCiv4 InterSite DG: Apolyton TeamBtS Tri-LeagueC4BtSDG TemplarsC4WDG Team ApolytonCivilization IV CreatorsCTP2 Source Code ProjectPolyCast Team
Deity
 
Locutus's Avatar
 
Local Time: 11:59
Local Date: October 31, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
quote:


Apolyton question: I am not sure exactly what Richard means with that last sentence, though his example a little ways below with the 5 armies did clear some things up for me.



What he means is that armies are assigned to all goals for which they are valid, but once it has been determined they will execute a certain goal, they won't be assigned to execute any other goal anymore. One army can never execute more than one goal: the goal for which they have the highest Matching Value and for which no other armies with a higher Matching Value are available (unless those armies don't Force Match the goal of course).

quote:


Apolyton question: Locutus, I believe, had asked before about clearing orders, and I think the above suggests that this is a good idea. What I would want is a trigger to clear all unit orders say, every 3 turns, and another trigger to clear orders whenever an AI civ loses one of its cities. If this is hard to do, then a trigger which makes the seige goal the highest priority whenever a city is lost may work just as well.



Will look into that, shouldn't be too hard to code.

quote:


Apolyton question: I start getting a little confused by the rest of his answer below. If someone could expound upon this, I would appreciate it.
(...)
Apolyton question: I am a little confused by the recommendation to set things at 2 or 3. In the original strategies.txt, the MaxEval and MaxExec are both 25 for the Attack and Harass goals, and around 4 for seige and bombard. Does this mean that the original settings are way off, or am I mis-interpreting Richard's comments?



As I explained above, if there are too many goals with high Force Match numbers and the available armies don't match to any of these goals, not all units will be assigned to goals and not all goals will get armies assigned to them, even though they may have very low Force Matching numbers.

Richard advises to keep MaxEval low for those goals that require high Force Matching numbers and for which little units will be available (in other words, goals that have low priority). This situation will generally only occur when you have a fairly small army and the units in your army are fighting an enemy that is stacking very well or that is far ahead of them in tech. On top of that, Siege and Bombard have fairly high priorities. I suspect that under normal circumstances it will be fairly unlikely that the AI will run out of matchin cycles for goals like Siege and Bombard and that low MaxEval numbers aren't needed. With other goals, you might have to be more careful (though I wouldn't know off the top of my head which ones) and assign lower MaxEval numbers.

quote:


Apolyton question: I definitely need a trigger to disable the start strategies after about 125 turns or so.



Sure, if you write strategies to replace them, it's a piece of cake to write the SLIC code for this.

quote:


Apolyton question: I would like a trigger to swap in a strategy that enables this goal when they have military superiority. I will set the MaxEval > 0 for Militaristic and Ecotopian AIs.



Define military superiority... More units? How many more? Better technology? How much better? Any other properties to take into acount? Once I know exactly what you want, it should be fairly simple to code.

quote:


1)The AI does not appear to know how to use Fighters correctly, often letting them run out of fuel and crash. Otoh, I have seen it use Bombers correctly, and return them to base. I need a trigger to make the AIs return their planes to the nearest city, airbase or Carrier when they have used up half their fuel. There is already something in the game which changes the paths color from green to yellow, I believe, when this fuel point is reached, so hopefully a trigger can be made which is tied to this point as well.



I think I can do this. There's no pre-made code to detect when a unit is half-way, but by playing around with values from Units.txt, this probably won't be necessary either.

quote:


2)I have changed several wonders in the game to give improvements in every city. I need a trigger that removes the option to build improvements if a civ has a wonder that grants that improvement to every city. This has been discussed before, but I don't recall the options to disable this "feature".



Come to think of it, this should actually be fairly simple.

Wouter
Locutus is offline  
Old February 8, 2001, 18:25   #10
WesW
Apolytoners Hall of Fame
 
WesW's Avatar
 
Local Time: 03:59
Local Date: October 31, 2010
Join Date: Mar 2007
Location: Florence, Al., USA
Posts: 1,554
FIrst of all, I want to congratulate Wouter for figuring out the AI routines, if he indeed was correct. I got cross-eyed about 75% of the way through just from trying to read the explanation. And the explanation was as simple as it could be made. Anyway, responding to Wouter's remarks...

Apolyton question: Locutus, I believe, had asked before about clearing orders, and I think the above suggests that this is a good idea. What I would want is a trigger to clear all unit orders say, every 3 turns, and another trigger to clear orders whenever an AI civ loses one of its cities. If this is hard to do, then a trigger which makes the seige goal the highest priority whenever a city is lost may work just as well.

Will look into that, shouldn't be too hard to code.

WesW: Ok, good.

Apolyton question: I definitely need a trigger to disable the start strategies after about 125 turns or so.

Sure, if you write strategies to replace them, it's a piece of cake to write the SLIC code for this.

WesW: I just want the AI to use it's default personality strategy when at peace, and the three war strategies when in that state.
You see, I have added some things to the Start strategies that should help the AIs at the start of the game, but these settings will interfere with the other strategies if they are in play for the entire game.

Apolyton question: I would like a trigger to swap in a strategy that enables this goal when they have military superiority. I will set the MaxEval > 0 for Militaristic and Ecotopian AIs.

Define military superiority... More units? How many more? Better technology? How much better? Any other properties to take into acount? Once I know exactly what you want, it should be fairly simple to code.

WesW: I thought that there were settings in the game already to determine relative military strengths. Doesn't the AI use these in deciding whether to declare war, or what war strategy to use?

1)The AI does not appear to know how to use Fighters correctly, often letting them run out of fuel and crash. Otoh, I have seen it use Bombers correctly, and return them to base. I need a trigger to make the AIs return their planes to the nearest city, airbase or Carrier when they have used up half their fuel. There is already something in the game which changes the paths color from green to yellow, I believe, when this fuel point is reached, so hopefully a trigger can be made which is tied to this point as well.

I think I can do this. There's no pre-made code to detect when a unit is half-way, but by playing around with values from Units.txt, this probably won't be necessary either.

WesW: Fixing this bug will be a significant improvement to the game.

2)I have changed several wonders in the game to give improvements in every city. I need a trigger that removes the option to build improvements if a civ has a wonder that grants that improvement to every city. This has been discussed before, but I don't recall the options to disable this "feature".

Come to think of it, this should actually be fairly simple.

WesW: As usual, I was thinking of the AI when suggesting this trigger, to answer some of the thoughts posed by AW prior to Wouter's posts.
As far as I know, the AIs will use their normal building queues whether or not they have a wonder which grants said building's effect. Since some of the Wonders grant expensive buildings like Forcefields, they need to be kept from wasting resources on unneeded buildings.

Btw, I can't wait until we get into the Unit-Wonders.

Wes
WesW is offline  
Old February 9, 2001, 00:35   #11
WesW
Apolytoners Hall of Fame
 
WesW's Avatar
 
Local Time: 03:59
Local Date: October 31, 2010
Join Date: Mar 2007
Location: Florence, Al., USA
Posts: 1,554
I have edited the first letter from Richard to include some important things that I had deleted in my reply to him. Those of you interested should scan that letter again and take note of these new sections.
WesW is offline  
Old February 9, 2001, 04:52   #12
Alpha Wolf
Chieftain
 
Local Time: 09:59
Local Date: October 31, 2010
Join Date: Feb 2001
Location: Prince of the Barbarians
Posts: 0
So it should also be possible to force the barbarians to use the barbarian strategy every turn even if they want to become civilized?

I'm with Wes about the the fuzzy eyes. I thought I understood how changing the maxeval and maxexec affects game play even tho I didnt know the exact details behind it. But the defend example has thrown me. Say the AI has a city that due to whatever reason is lightly defended. I'm moving towards it with say 5 units. Between me and the city are 3 stacks (4,2,5 units). Is Richard saying that only one of those stacks will move to defend the city?

------------------
History is written by the victor.
Alpha Wolf is offline  
Old February 9, 2001, 08:06   #13
Locutus
Apolytoners Hall of FameCiv4 SP Democracy GameCiv4 InterSite DG: Apolyton TeamBtS Tri-LeagueC4BtSDG TemplarsC4WDG Team ApolytonCivilization IV CreatorsCTP2 Source Code ProjectPolyCast Team
Deity
 
Locutus's Avatar
 
Local Time: 11:59
Local Date: October 31, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
Glad I could be of help...

No AW, MaxEval and MaxExec 1 means that 1 goal per city will be defended, it doesn't mean 1 army per city will be used to Defend, armies and goals are completely unrelated. In this particular case, goals represent the cities to be defended. Since the only valid goals for Defend are your own cities, Defend will be evaluated and executed for all your cities: for every city you have, 1 goal will be evaluated&executed, i.o.w. for every city you have, 1 city will be defended, hence all your cities are defended. If the defense of this city only requires 1 additional army to Force Match, 1 army will go back to the city to defend. If it requires all 3 armies to Force Match, all three armies will Defend the city. As many armies are sent in as is necessary to Force Match.
[This message has been edited by Locutus (edited February 09, 2001).]
Locutus is offline  
Old February 9, 2001, 11:06   #14
Locutus
Apolytoners Hall of FameCiv4 SP Democracy GameCiv4 InterSite DG: Apolyton TeamBtS Tri-LeagueC4BtSDG TemplarsC4WDG Team ApolytonCivilization IV CreatorsCTP2 Source Code ProjectPolyCast Team
Deity
 
Locutus's Avatar
 
Local Time: 11:59
Local Date: October 31, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
quote:

Originally posted by WesW on 02-08-2001 05:25 PM
WesW: I just want the AI to use it's default personality strategy when at peace, and the three war strategies when in that state.
You see, I have added some things to the Start strategies that should help the AIs at the start of the game, but these settings will interfere with the other strategies if they are in play for the entire game.


Oh, wait a minute. I misunderstood what you meant by Start strategies, but now I get it. I think reloading the standard personality strategy (with SetStrategicState) after 125 turns or whenever you want will undo the changes of the Start strategies. I think this can be done.

quote:


WesW: I thought that there were settings in the game already to determine relative military strengths. Doesn't the AI use these in deciding whether to declare war, or what war strategy to use?



You're right. MilitaryRank can be used for this. I didn't think of this yet, it's hardly ever useful for anything but it's perfect now. Should be fairly simple then.

quote:


Btw, I can't wait until we get into the Unit-Wonders.



If you mean that you're waiting for me to send you the code for it, I did that weeks ago. If you meant anything else, ignore this paragraph
Locutus is offline  
Old February 9, 2001, 15:02   #15
WesW
Apolytoners Hall of Fame
 
WesW's Avatar
 
Local Time: 03:59
Local Date: October 31, 2010
Join Date: Mar 2007
Location: Florence, Al., USA
Posts: 1,554
That sounds great, Wouter. Maybe we can be rid of the most annoying AI inadequacies right from the start of the beta if you can get all these in to me in the next few days.

As to the unit-wonders, I have a much more detailed plan for them than what I out-lined a few weeks ago. Once we get everything else working in the mod, I will start a thread about these. I think everyone is going to love this feature once they get the details laid out before them.
WesW is offline  
Old February 18, 2001, 15:45   #16
Azmel2
Settler
 
Local Time: 09:59
Local Date: October 31, 2010
Join Date: Aug 2000
Location: Santa Monica, CA USA
Posts: 9
quote:

Originally posted by WesW on 02-06-2001 04:20 PM
Here are a couple of questions that Harlan and Locutus have asked before, and that I would like for us to work on.

> > The responses to your questions brought a couple of questions into my mind.
> > First, what is the scale of trust and attitude towards other civs, and second,
how can one check to see exactly where the other civs are on these scales?


But at any given time, there are concrete numbers for
each civ, not just general tendencies. For instance,
Civ2 might have a trust of 153 and attitude of 203 on
turn 5. So my questions are what are the ceilings and
benchmarks for those numbers? For instance, maybe you
can have a max of 1000 attitude, and anything over 800
means the AI wants to have peace with you. But who
can say with the info we've got? We're just groping
around in the dark. And my second question is how to
know exactly where each civ stands at any given time
on all of these. Instead of getting a vague notion
that a civ is "wary" of you, as a scenario maker I'd
want to know what the concrete number was. In the
pre-release, there was a debug version of the game
that had extra tools allowing one to find out stuff
like this, but now they're gone.

Wouter


Both attitude and trust are on a scale from 0 to 1000.
The break down is as follows:

0 - 100, hot war (Goals with TargetOwner: HotEnemy)
101-300, cold war (Goals with TargetOwner: ColdEnemy)
301-700, neutral (Goals with TargetOwner: Neutral)
701-900, friend
900-1000, allied

The first three also say which goals will be pursued against foreign nations that you have a particular attitude toward. For example, you'll only do HotEnemy goals against foreigners you have a regard of 100 or less with. Going to war will also induce an automatic hotwar regard.

Trust is on the same scale. An AI will not sign certain treaties or agreements unless trust or regard is above a certain point. That can be redefined using your own diplomatic response logic.

A scenario writer can use the slic functions to get teh absolute number using:

GetPublicRegard
GetEffectiveRegard (adjusted for being at war)
GetTrust

quote:

Originally posted by WesW on 02-06-2001 04:20 PM

Here's a pipedream: maybe he could send us the final
debug version of the game, if he still has it?

Wouter


Of course I have this code on our servers at work, but sending it to you would certainly violate all sorts of non-disclosure documents I signed. Infact, I have no doubt that armed marshals would be at my door in no time to serve me papers it this got out.

Personally though, I think it would be good for CTP as a brand and Activision as a company to make this code available in some way. Perhaps you could start a grass roots effort to open source game code after some number of years of release. The folks at Loki arranged a "hack-a-thon" at LinuxWorld (?) for CTP1 inwhich a group of people off the street could sit in a specially network-isolated room to look and modify the code. Maybe somone can talk Activision into doing that again. I wouldn't hold my breath, but who knows.

quote:

Originally posted by WesW on 02-06-2001 04:20 PM

Do you have any idea of what the effect would be if I used SLIC to clear
every stacks orders every turn? As I see it, this would force the AI to
re-analyze the situation every turn and give all its units new orders every
turn and thus all AI actions would be based on the latest information. I
realize this will probably make the AI slower but if the AI also becomes
smarter then this might be worth it. Would the AI actually become smarter?

Wouter


This might make the AI smarter in some situations, but would certainly make it slower. You might see some oscilation behavior too, so I'd at most clear the orders every few turns, maybe every 3 or 5; not every turn. Maybe clear every third stack every third turn to spread out the time hit. It's a very good question though and selectively clearing the orders for AI units under situations other than running into an enemy would be a very good idea. Adding more logic to this part of the AI was always part of the plan, but not fully implemented due to time contraints.

-- Richard
Azmel2 is offline  
Old February 18, 2001, 15:56   #17
Azmel2
Settler
 
Local Time: 09:59
Local Date: October 31, 2010
Join Date: Aug 2000
Location: Santa Monica, CA USA
Posts: 9
quote:

Originally posted by Alpha Wolf on 02-09-2001 03:52 AM
So it should also be possible to force the barbarians to use the barbarian strategy every turn even if they want to become civilized?

I'm with Wes about the the fuzzy eyes. I thought I understood how changing the maxeval and maxexec affects game play even tho I didnt know the exact details behind it. But the defend example has thrown me. Say the AI has a city that due to whatever reason is lightly defended. I'm moving towards it with say 5 units. Between me and the city are 3 stacks (4,2,5 units). Is Richard saying that only one of those stacks will move to defend the city?




No. There's some confusion here. It will match with all three stacks (4,2,5) and assign units from each to defend the city until the level of force matching has been reached. If it only needed the first two armies, then the third one can be assigned to some other goal.

-- Richard

Azmel2 is offline  
Old February 18, 2001, 16:18   #18
Azmel2
Settler
 
Local Time: 09:59
Local Date: October 31, 2010
Join Date: Aug 2000
Location: Santa Monica, CA USA
Posts: 9
quote:

Originally posted by Locutus on 02-08-2001 01:35 PM
possible some of this is incorrect. If anyone (esp. Richard himself) can correct me where I'm wrong, that would be very helpful.




From my reading, I'd say you've got it right. Thanks for putting in the time to sus it out. If I had more more time I'd make up a spread sheet that shows how this works, but your description goes a long way to making things clearer.

quote:

Originally posted by Locutus on 02-08-2001 01:35 PM
.
.
.
least one turn (maybe they'll fortify). Another option might be that they'll still be available for other goals, like Harassing, but if that is the case I don't quite see why Richard presents this as a problem (it's not ideal but not really a problem either, if you ask me).


In your example, if in fact all six attack goals had higher matching values for your armies than any other goals and could not be fulfilled, the armies matched against those goals would just fortify that turn. Though not ideal, it rarely happens with the default settings.

In a degenerate scenerio they wouldn't be available for harass goals unless some of the armies matched a harass goal before an unfulfillable attack goal. I'd like to reiterate that having six attack goals that can not be fulfilled is rare; that the match values for those attack goals should be higher for every army than any other goal is rarer still. Something to keep in mind though as you make changes to the strategies.txt file.

-- Richard

PS> As a side note, this AI system is essentially the same as that used in CTP1, Dark Reign 1 and parts of StarTrek: Armada. We can thank Dr. Ian Davis for the original algorithm; I don't know where he got it from originally though. Ian has his own company now called maddoc software.
Azmel2 is offline  
Old February 19, 2001, 03:51   #19
WesW
Apolytoners Hall of Fame
 
WesW's Avatar
 
Local Time: 03:59
Local Date: October 31, 2010
Join Date: Mar 2007
Location: Florence, Al., USA
Posts: 1,554
Thanks for your answers, Richard. They should be very helpful to us in our mod efforts.
Richard also sent me replies to my last two letters to him, which I have pasted below.

As for my text questions, one that comes to mind is from the Goals.txt.
What does the "PowerBonus" flag do? What does it read and what effect does it have on the AIs decisions? This is the one thing from that file that I still can't figure out.

Richard: the PowerBonus would be the opposite of the ThreatBonus. You if the goal is in the cell with the largest amount of "allied" power (not enemy) then it gets the full powerbonus. As with most of the other bonuses, it's a normalized value so cells with less than the highest allied power get less bonus.


Also, in the explanation of the Personalities.txt in the modification section, there is this explanation of the conquest flag:

Conquest -
Sets the desire to resolve disputes through war or diplomacy. Valid
values: Passive, Neutral & Lawful.

Should the Lawful setting actually be Agressive?

Richard> Yes, that would be a typo. My own description for that trait is:
"This describes the liklihood that the AI will attack. This can also be considered the disposition of the personality."


That's all I have for right now, though there are a number of things that I posed in the forum thread, and I have not really gotten into the diplomacy aspect of the game yet.
Thanks for your help. I know it must have been hard reading all the negative things said about the AI in the forums, but with any luck we can change all that in the coming weeks.

Richard: Thanks for the questions Wes! Some of that negative stuff on the boards does sting, but in general I take it all with a grain of salt. I know that people wouldn't be so upset if 1) they didn't like the game to some degree, otherwise they wouldn't care and 2) there wasn't some grain of truth to their complaint.

-- Richard

Hi Richard.
Have you had a chance to scan the AI forum recently?
Anyway, I was looking through the goals.txt and Orders.txt and found some more questions for you.

1)What is the difference between the Attack and Harass goals? Also between Harass City and Siege? They seem like the same thing to me.

Richard: Notice that the Attack and Siege goes have different force matching than the harass goals. Harass goals have lower priority and are used to throw units at an enemy to keep them on their toes until a large enough force to attack or seige has been created.

2a)In the Orders.txt, I think the TargetPretest for Injoin and Sue are mixed up. The Target for Injoin is Enemy Trade Unit, and the Target for Sue is Enemy City.

Richard: Yikes! That could cause problems all right. I tried it out switched and I noticed that my lawyers did not injoin cities unless I swapped those values. I assume the same is true for sue'ing enemy trade units.

Apolyton note: I have corrected this for the beta.

2b)Also, for Sue Franchise, the Unit Pretest is "CanSueFranchise". Could this not be changed to "CanSue", just to simplify things? I didn't come across the "CanSueFranchise" flag in the units text.

Richard: The difference is that you sue francises to get rid of them from cities, which is different from sue'ing to destroy a trade unit. My guess is that CanSue will work too though.


2c)I have made most all unconventional warfare units able to be sued, as a way of destroying them without going to war. Is there anything wrong with changing the Sue order's Target Pretest to "Enemy Special Unit"?

Richard: No, that should be fine. This should also enable this option for players on their pulldown menu.

2d)Were you the person supplying Mark with the Data File Definitions? If so, we could really use one for Units.txt, and perhaps one for Orders.txt as well.

Richard: I'm not the expert on Units.txt, or Orders.txt except for the pretests. Sorry. I can probably answer specific questions about both though.


3)Is there something wrong with the Paradrop order? Among other things, the Target Pretest for it is Enemy City, which would seem to indicate that the AIs would only Paradrop into unoccupied enemy cities.

Richard: The paradrop command should let the AI unload paratroopers from planes directly into occupied enemy cities. I don't remember off hand how well this goal was working.


4)Many people have complained that the AIs will load troops onto Cargo Helicopters, and fly into enemy territory, but they will never unload their units. Is there anything in the Orders.txt, or some other text file, which might be able to rectify this?

Richard: I'm sorry, but this is a difficult issue to fix. There might be some way in SLIC to force helicopters to unload, but when to do it is tricky.


5)Finally, I looked at the Data File Definitions for the Personality text, and many of the Valid Values listed do not match the game values. Could you look this over, and perhaps give Mark the correct info?

The values should be:

// This describes the extent to which an AI will send out units to explore
Exploration: Wide, Medium, Minimal

// This describes the magnitude of an AI's empire and the speed to
// which it will expand
Expansion: Maximum, Average, Minimum

// This describes the degree to which the AI will focus on
// scientific discovery and the area or branch of specialization.
// As well as the primary motivation for diplomatic interactions.
Discovery: Scientist, Military, Economic, Ecotopian, Diplomatic

// This describes the liklihood that the AI will attack. This can
// also be considered the disposition of the personality.
Conquest: Agressive, Neutral, Passive

// This describes how likely the AI will be to violate agreements
// and follow through on threats. It also specifies how the
// regard of an AI will be changed by the dishonest actions of
// others.
Trustworthiness : Chaotic, Neutral, Lawful

// This describes in general terms the methodology used by an AI
// to accomplish its goals and whether or not the AI cares if its
// actions cost the regard of other empires. Evil actions might
// include killing settlers, the use of slavery and the first
// strike launch of nuclear weapons. The regard consequences of
// an evil act will be less for an evil empire than a neutral or
// good one.
Alignment : Evil, Neutral, Good

// Send this greeting if stronger militarily
StrongGreeting: a stringID

// Send this greeting if weaker militarily
WeakGreeting: a stringID

// Follow through percent
ThreatFollowThrough: a number

// Description show in Intelligence Details
Description: a stringId
WesW is offline  
Old February 20, 2001, 16:25   #20
Locutus
Apolytoners Hall of FameCiv4 SP Democracy GameCiv4 InterSite DG: Apolyton TeamBtS Tri-LeagueC4BtSDG TemplarsC4WDG Team ApolytonCivilization IV CreatorsCTP2 Source Code ProjectPolyCast Team
Deity
 
Locutus's Avatar
 
Local Time: 11:59
Local Date: October 31, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
Richard,
Thanks a ton for taking the time to read my explanation and reply to it. Good to know I interpreted your explanations correctly (Good to know that my usefulness to the CtP(2)-community isn't limited to being a SLIC-guru alone ). One question though:

quote:

In a degenerate scenario they wouldn't be available for harass goals unless some of the armies matched a harass goal before an unfulfillable attack goal.


The way I had thought it worked is that if even one attack goal has a higher priority than the highest harass goal, all attack goals would be force matched before any harass goals would be. In this sentence you seem to suggest however, that goals are executed by priority, regardless of their type. Example:

Attack Goal 1 (A1): Matching Value 410,000
Attack Goal 2 (A2): Matching Value 390,000
Harass Goal 1 (H1): Matching Value 405,000
Harass Goal 2 (H2): Matching Value 400,000

I originally thought that the order in which these goals would be executed should be A1, A2, H1, H2. Now you seem to suggest the order should be A1, H1, H2, A2. Which is the case? The latter seems the more logical situation to me but that's not how I originally understood it.

Thanks again,

Wouter
[This message has been edited by Locutus (edited February 20, 2001).]
Locutus is offline  
Old February 20, 2001, 18:24   #21
Pintello
Warlord
 
Pintello's Avatar
 
Local Time: 09:59
Local Date: October 31, 2010
Join Date: Dec 1969
Location: Deltona, Florida
Posts: 284
Hi Richard,

I noticed that you have the Activision Title again. Does that mean that you are working for them again, or is it just a snaffu in the forums? Also, if you are working for them again, does that mean that Activision has reconsidered their support for CTP2?

Regards,

Timothy Pintello
Pintello is offline  
Old February 21, 2001, 12:53   #22
herwin
Settler
 
Local Time: 09:59
Local Date: October 31, 2010
Join Date: Jan 2001
Location: Sunderland, UK
Posts: 9
What would it take to replicate the CTP AI in CTP2, given that the same engine is used?



------------------
herwin is offline  
Old February 22, 2001, 21:14   #23
Galatea
Settler
 
Local Time: 09:59
Local Date: October 31, 2010
Join Date: Feb 2001
Location: San Francisco, CA
Posts: 0
Hey Wes,

I can't seem to find your original questions to Richard. Would you please direct me to their location?

Thanks!
Galatea is offline  
Old February 24, 2001, 00:57   #24
WesW
Apolytoners Hall of Fame
 
WesW's Avatar
 
Local Time: 03:59
Local Date: October 31, 2010
Join Date: Mar 2007
Location: Florence, Al., USA
Posts: 1,554
When Richard initially offered his help, I sent him the AI files like the strategies.txt that I had altered, and asked him to look those changes over. I then asked him a few specific questions.
Richard replied with selected comments on my text changes. Those are the first few comments you see above. The letter I sent replying to his reply is what I pasted in above.
My initial questions to him are included in the paste, but since his opening remarks are comments on my text changes, there are no initial questions for them.
WesW is offline  
Old March 15, 2001, 16:08   #25
Azmel2
Settler
 
Local Time: 09:59
Local Date: October 31, 2010
Join Date: Aug 2000
Location: Santa Monica, CA USA
Posts: 9
quote:

Originally posted by Locutus on 02-20-2001 03:25 PM
Richard,
Thanks a ton for taking the time to read my explanation and reply to it. Good to know I interpreted your explanations correctly (Good to know that my usefulness to the CtP(2)-community isn't limited to being a SLIC-guru alone ). One question though:

The way I had thought it worked is that if even one attack goal has a higher priority than the highest harass goal, all attack goals would be force matched before any harass goals would be. In this sentence you seem to suggest however, that goals are executed by priority, regardless of their type. Example:

Attack Goal 1 (A1): Matching Value 410,000
Attack Goal 2 (A2): Matching Value 390,000
Harass Goal 1 (H1): Matching Value 405,000
Harass Goal 2 (H2): Matching Value 400,000

I originally thought that the order in which these goals would be executed should be A1, A2, H1, H2. Now you seem to suggest the order should be A1, H1, H2, A2. Which is the case? The latter seems the more logical situation to me but that's not how I originally understood it.

[This message has been edited by Locutus (edited February 20, 2001).]


Wouter, the latter ordering is indeed correct (A1, H1, H2, A2). Remember that each match between a particular army and goal generates a match value. As the matches are executed, the army in the match is assigned to the goal. When a goal has sufficient armies assigned, then the goal is 'executed' and the armies assigned actually begin moving toward the goal.

Goals can be interleaved because the matches are sorted based on their match utility, but goals (like defense) that have very high base priorities
will probably all sort to the top of the list together.

Hope this helps,

-- Richard

PS> Sorry for not being around for awhile, I was out of town and had a cold that knocked me out for awhile.
Azmel2 is offline  
Old March 16, 2001, 06:19   #26
Locutus
Apolytoners Hall of FameCiv4 SP Democracy GameCiv4 InterSite DG: Apolyton TeamBtS Tri-LeagueC4BtSDG TemplarsC4WDG Team ApolytonCivilization IV CreatorsCTP2 Source Code ProjectPolyCast Team
Deity
 
Locutus's Avatar
 
Local Time: 11:59
Local Date: October 31, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
Yes, this helps a lot, thanks again.
Locutus is offline  
Old March 28, 2001, 17:57   #27
Peter Triggs
CTP2 Source Code ProjectCivilization IV Creators
King
 
Local Time: 09:59
Local Date: October 31, 2010
Join Date: Jan 2000
Location: Gone Fishin, Canada
Posts: 1,059
Richard

Welcome back and thanks for your help in answering our questions; it's greatly appreciated. So I've got some more for you.

The first one is of largely theoretical interest. This AI is so neat (that's a comment you don't hear very often, eh) that I've become obsessed with trying to understand how it works.

1) In his discussion of how the AI matches units with goals, Wouter gave as possible goals "Seige Liverpool" or "Attack army near London". Is it really this specific, i.e., does the AI evaluate targets on a cell by cell basis? (I didn't think my computer was that good.) In CTP1 there were some map grids in strategic_AI_config.txt, with cryptic comments by the Mad Dr I. suggesting that they were used by the AI to evaluate threats. There's no similar file in CTP2 but I guess the same thing is going on. Is it?


2) Several times above you've mentioned adding in new strategies. Not a lot of people have tried this yet so could you elaborate a bit on the discussion in AI Customization of the various strategic state events and functions. There's an incredible ammount of information crammed into a very small space there and I, for one, don't think I've grasped it.


2.1) We can use the INIT_STRATEGIC_STATE event and the SET_STRATEGIC_STATE function to give a player either a different existing Discovery strategy or a completely new Discovery strategy of our own. Is it possible to use this combination of event and function to give him, say, both a new Discovery strategy and a new Start strategy? (I couldn't get it to work.)


2.2) The CONSIDER_STRATEGIC_STATE function has the form:

CONSIDER_STRATEGIC_STATE(player, priority, StrategyDB(index),-1,-1,-1),

where the three -1's are from an example of how this is used in one of the scenarios. What are they for? More importantly, the examples of priorities I've seen range from 500 to 9999 and you mentioned above to Wes that he should use 1000. What's the total range and is there a recommended usage for different types of strategy?


3) I've been experimenting with these functions and just to see if I understood how the strategies, and buildlists they contain, were working, I tried to introduce a new default discovery strategy that completely focused on building buildings. It had limited success up to turn 80 (co-incidently ?, the end of ancient or opening gambit time in CTP1). At this point the AI insisted on turning out tons of military units, in spite of the fact that I thought I had totally incapacitated it's ability to do this. The details are tedious, but could you give us some hints on what we have to do if we want to add new BuildListSequenceElements? In theory, I guess, this is just like adding a new goal but the results should be more easily observable. And like I say, when I tried it I didn't get the results I expected.

3.1) In particular, are the priorities assigned in the BuildListSequenceElements just a straightforward linear ordering or does this involve complications of the goal matching magnitude that we saw above?

3.2) I assigned the BuildListSequence that I wanted to emphasize to the Top 1.0 ProductionCities and the others to 0% of whatever they had previously been assigned to. But this doesn't seem to work and I can't see why not. Incidently, when I put BuildListElement { Infrastructure } at the top of some BuildListSequences, I end up with empty build queues. Surely this can't be working correctly.


4) Finally, I have a vivid recollection of seeing a post from St. Swithin where she mentioned some codeword that you could type into the chat screen and get the AI to take over for 100 turns. But I forgot to record it and now can't find it anywhere. Does such a thing exist?

Thanks,

Peter

[This message has been edited by Peter Triggs (edited March 29, 2001).]
Peter Triggs is offline  
Old April 16, 2001, 23:15   #28
Steve5304
 
Local Time: 09:59
Local Date: October 31, 2010
Join Date: Jan 2001
Location: Racine ,WI USA
Posts: 483
All i gotta say is......

Excellent! Considering the AI is hoplessly incapable of doing anything right

-------------------------------------------------
'Return CTP2 and then on to more important matters like Civ3'
Steve5304 is offline  
Old April 18, 2001, 06:37   #29
Immortal Wombat
Apolytoners Hall of Fame
Prince
 
Immortal Wombat's Avatar
 
Local Time: 10:59
Local Date: October 31, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
We know thats all you've got to say, and you've said it in a hundred different ways in a hundred different posts - Point Made!. If we don't know how it works, it can't be fixed.

Immortal Wombat is offline  
Old April 19, 2001, 13:04   #30
Steve5304
 
Local Time: 09:59
Local Date: October 31, 2010
Join Date: Jan 2001
Location: Racine ,WI USA
Posts: 483
quote:

Originally posted by Immortal Wombat on 04-18-2001 06:37 AM
We know thats all you've got to say, and you've said it in a hundred different ways in a hundred different posts - Point Made!. If we don't know how it works, it can't be fixed.





Your probably the only 'Ignoramoose' here who actually enjoys playing them.

Many of us are still mad at them

I complain when I want and where I want so mind your own business you twit

Steve5304 is offline  
 

Bookmarks

Thread Tools

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 05:59.


Design by Vjacheslav Trushkin, color scheme by ColorizeIt!.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Apolyton Civilization Site | Copyright © The Apolyton Team