ai modding

I want my 15 rapid-fire quantum torpedo launchers Uber-Defiant now! - Get help from modders. Share your work. Discuss modifications.
1, 2, 3
posted on September 22nd, 2013, 1:46 am
I only changed the particular line in my RTS_CFG.h.
posted on September 22nd, 2013, 4:39 pm
I just had another game last nite against the AI, 4 players, all different races and everything was fine with them building up and attacking me and each other. I'm only using those 4 AIP files and the strategic_AI_config file and that one number change in the RTS_CFG file presumably the same as you are so I'm really stumped as to your results?

Have you made any other changes or is yours FO install stock? When you put your back up files back in place does the game play normally then?
posted on September 24th, 2013, 12:48 am
I think I found the problem. I mistyped the value in the RTS_CFG.h. Thats why they were not doing anything.
Everything works good atm.

Nope, game still crashes but only on large maps (bigger 30000x30000) with the same error. Perhaps you should look into it again.
posted on September 29th, 2013, 7:07 am
Which setting do I change to make the Dominion and Romulans less super spammy on merciless?
posted on September 29th, 2013, 3:07 pm
@ Ressikan: That is strange. I use almost the exact same one and have been for months. I've only been refining some values, but let me go through it again and I'll post again shortly.

@ nathanj: You can't just change one setting to make them less spammy. The Dominion uses supply and gets it free in order the make them AI friendly. It's also the way their build list is written to produce certain ships and in certain numbers that come at you. The only thing to do and be very careful changing values is to alter the AI handicap settings in the RTS_CFG. You'd be looking for the following and would want to change the values for the HARD settings. Try small increments first and see how it plays, but you may alter the game play in ways that mess it up. Be forewarned.


// Damage coefficients for incoming damage for user in single player
float EASY_DAMAGE = 1.0;
float HARD_DAMAGE = 1.0;

// Mining rate cooefficients for user in single player

// AI special weapon fire rate

// Build cost multiplier handicap for hard AI



// Percent chance that AI fleets will cloak for long moves in Instant Action
// and Multiplayer AI (provided they can!)
posted on September 29th, 2013, 9:53 pm
Apologies for the double post.

@ Ressikan: I went back and started over using the same file structure that FO uses for their AI so it's a little different than my first release. This one is specifically for FO. I edited the 4 AIP files and the newdefault file all of which are in the AIPs folder. Instructions are in the readme as well as included stock FO backups. I didn't edit the files as heavily as before deciding to start a little smaller. My next version will have further edits. For now I've basically only edited the max_attack and max_eval values and a couple of other lines. I left the priority values alone for now.

Just to be sure when you restore your backups the game plays fine on all maps correct? You didn't say if it did before. And you didn't make any other changes except pasting my few AI files into FO correct? Are these stock maps that are crashing? Have you edited them in any way?

Try this and let me know how it works.
Regards, rifraf


FO AI.rar
(19.44 KiB) Downloaded 122 times
posted on October 29th, 2013, 4:31 pm
Hi Dominus, I had a couple more questions regarding how FO uses the AI settings. So we know FO is set up for multiplay, but the instant action element is there to play against the AI. I'm curious as to why you have it set up so that ships have the intrinsic value and are considered the preferred targets first, but the stations aren't? Isn't the goal to destroy your stations to deny you the ability to gather resources, build and research and ultimately destroy your base and the ships are just the tools to carry that out? Did you guys do this to prolong game play or is it just how you wanted it for your design of the game?

Then, in regards to the AIP settings for agressive, exploration, defensive, and very_aggressive you use values rather low for the "priorities" for settings like attactk_troops_priority, defend_priority etc.

Where stock may have 100000 for attack_troop_priority you have say 9500. I'm guessing any positive number will work and the higher you go won't really make a difference as it's already a positive number? Would having say 99999 versus 9500 make any real difference in the weight it gives to these priorities from what you've found? A value of 1 would give the same result wouldn't it?
posted on October 29th, 2013, 4:58 pm
Thx I will check it out when I have time :thumbsup:
posted on October 29th, 2013, 7:06 pm
IntrinsicValue stuff was set before we had tested that functionality, so it doesn't follow any strict rules in V3 :). I believe the original reason (before my time as a team member) was to get the AI to attack ships first. However, values that low won't really show any change, and I'm still not sure if the AI even accounts for non starbase craft in intrinsicvalue calculations.

All of the AIP values were set before I was a member of the team - I am not sure how extensively Optec tested them and I don't know what background went into testing them. Some of the values in the AIP values are prone to generate out of syncs in multiplayer supposedly, so some values are not changed from stock A2 in order to avoid that. :)

I'm not at all confident when it comes to testing the AI, just because I haven't invested enough time to create a real testing environment and because I like to stay away from things that have the potential to generate out of sync in multiplayer :blush: .
posted on October 30th, 2013, 3:37 am
Thanks D_N. Can you say if the AI in v4 is noticably different or markedly improved over v3 or has it really been worked on much? Perhaps Optec can weigh in as to there being parts of the AI that are still not fully known? I certainly don't want to duplicate anyones work and I enjoy testing it, but if you guys already know about the stuff that I'm testing perhaps you can throw me some scraps of info? :)

I see what you're saying about changing values in the AIP's, but can you let me know which ones in particular you've heard can cause problems? I see in some of the lines the developers put "do not change" for the values, but frankly their values make no sense. Like the relaxation bleedover. Why on earth only transfer 50% of the threat in a grid to the next grid and so on? A few grids out and the threat is barely visible and yet the range of a ships weapons extend far beyond that "threat projection."

In my test mod only stations have intrinsic value and only ships/bases with weapons have attack power values. Now the AI builds up it's forces and attacks the bases with intrinsic value and mostly ignores enemy ships. However, I'm guessing a threat is a threat because there are times where the AI would amass a fleet at a distance from the enemy base (the perimeter?) and the other AI's would send their fleet to attack the enemy fleet as opposed to their base so there must be more at play than what appears on the surface?

Also, I'm starting to think that in regards to the strategic-ai-cfg file in the AI folder, the developers in using 800 as the value for all the map resolutions (stock A2) may have chosen that value as a sweet spot. What I mean is most ships have around a 600ish weapon range and starbases have 1000 so they chose something in the middle. Ships have a threat range greater than their weapons can reach, but bases can reach further than their threat range. I guess that is a compromise and it would have been great if they could have given ships and stations their own strategic values, but alas.
posted on October 30th, 2013, 3:56 am
The AI in V4 is essentially untouched. We haven't yet worked on implementing its V3 to V4 parameter replacement in development - we've built in better support for attack and intrinsic value components, but for the former, that's to improve multiplayer. Not yet sure how it affects AIs. No actual coding changes have occurred (only externally modifiable parameters have been altered).

Many of these values were changed years ago (around 6 years I think) and then left untouched, and they weren't documented - so I'm not sure how much can be said about the original reasons. I don't know which values cause problems; nobody remembers in the team, other than the pain and suffering from testing those :lol: .

I don't know that Davis himself wrote all AI components, or whether some was done on gut feel by other members - there's certainly a lot of A2 content that does not match what the original code was intended to achieve. Not sure why that would be the case in the AI department, as Davis wrote that originally, but time constraints and who knows what else may have conspired.

I assume that the value of 800 was chosen, because the default line of sight for craft is 800 :) .

In general, I'm sorry to say that we have little interest in doing the legwork on A2 AI, just because of how ill suited it appears to be for FO and how difficult it is to document. I certainly can't bring myself to experiment, beyond what I've documented in the past. We'll replace the AI with our own design at some point in the future, as then we can understand exactly what we've built. In general, it's the one area of Armada I don't touch with a 10 foot pole. It's poorly optimized for network usage, badly implemented for strategy, can't adapt well, etc etc etc. Just like most of the AIs around that time and before.
posted on May 23rd, 2018, 7:01 pm
I got this bit of code from Civ 3 I believe and wanted to know if anyone here knows how to read it? Is this LUA? What does the -> between words mean like ai->m_planner->the_AIP.max_misc_bid_bonus? Is it just saying reference the ai file and inside that is the m_planner file and inside that is.....?

double high_movement_weight = .75;
double low_defense_weight = .25;
double bonuses = 0.0;
sint32 best_defense;
sint32 my_defense = army_agent->GetBestDefense(ai);
if (ai->m_science_agent->GetBestLandDefense(best_defense))
bonuses += (1.0 - (my_defense / best_defense))
* ai->m_planner->the_AIP.max_misc_bid_bonus
* low_defense_weight;
sint32 best_move;
double my_move = army_agent->GetBestMove(ai);
if (ai->m_science_agent->GetBestLandMove(best_move))
bonuses += (my_move / best_move)
* ai->m_planner->the_AIP.max_misc_bid_bonus
* high_movement_weight;
double time_term;
MapPointData dest_pos;
army_agent->GetPos(ai, dest_pos);
double tile_count = ai->m_map->WrappedDistance(*m_pos, dest_pos);
time_term = ( rounds * rounds
* ai->m_planner->the_AIP.distance_from_unit_priority_modifier )
- tile_count;
return bonuses + time_term + Compute_Raw_Priority(ai);
posted on May 24th, 2018, 6:24 pm
Looks like a shortening syntax for "part of" or "included in" that particular file. I'm just guessing, I'm not at all familiar with Civ3 modding.
posted on May 31st, 2018, 6:40 pm
I wanted to report a very promising finding that I feel may be the key to a better AI. I've had two really good games with one ending in three AI's rushing me at once and killing me. In the RTS_cfg file in the root directory of A2 there is this line "AI-Grid-Size=400" I knew it was tied to the strategic parameters, but didn't get around to changing it yet.

The scheduling program as posted in the AI file of Star Trek Armada:

Parameter Interactions

In one of the rare occasions of thorough commenting, Dr. Ian (who developed Armada II's AI) provided an in depth explanation of how the parameters interact and are used by the AI scheduler to assign Craft to goals.

The steps in a scheduling phase are first described followed by details of how the computations at selected steps are made.

Scheduler 12 step program:
1.A strategic map is created by dividing the map into grid squares
2.Each grid square has one of each goal type associated with it.
3.Compute the raw priority of each goal at each grid square.
4.Compute the match utility between every squad and goal.
5.Sort matches highest to lowest.
6.Examine highest match that contains a squad with uncommitted units.
7.Commit units from squad in match to associated goal.
8.If the goal has enough unit strength committed to it, command those committed units to move to the grid cell of the goal.
9.When all units on the team have been committed to goals, go to step 11.
10.Otherwise examine next match and go to step 7.
11.Rollback committed units from goals that still do not have enough troop strength and mark those units invalid for the goal.
12.Go to step 6.
Step 1: The Strategic Map
Parameters are specified in the strategic_AI_config.txt file.
Parameters that are important to the strategic AI are:
// number of map units per grid cell (i.e. 400x400 units per AI strategic grid cell)
#define goal_map_resolution 400
// Fraction of bleedover during threat relax
double relaxation_coefficient = 0.8;
// Number of threat relax cycles. This becomes how far away a threat is felt.
int relaxation_cycles = 2;

*****Full stragetic_AI_cfg.txt file (For Reference)*****
The strategic_ai_cfg.txt file in the AI folder contains all the strategic parameters as follows:
// How many tiles per threat mapgrid?
#define threat_map_resolution 800

// How many tiles per death mapgrid?
#define death_map_resolution 800

// How many tiles per our empire mapgrid?
#define empire_map_resolution 800

// How many tiles per enemy empire mapgrid?
#define enemy_empire_map_resolution 800

// How many tiles per exploration cell?
#define exploration_map_resolution 800

// How many tiles per goal cell?
#define goal_map_resolution 800

// Iteration for relaxing grid borders
int relaxation_cycles = 1;

// Relaxation bleedover
double relaxation_coefficient = 0.5;
Step 2: goals are assigned to grid squares
Escort goals are the exception to this rule. One escort goal is created for every unit on your team that is of the Freighter Class. The four goals that are created for each map grid cell are the: Attack Base Goal, Attack Goal, Defend Goal and Explore Goal.
Step 3: compute the raw priority of each goal
The raw priority is computed for each goal type in this way:
Attack Goal:
If the grid cell has enemy stations or contains no enemy threat, the goal is invalid. Otherwise, the value is the SUM of these factors:
1.Distance To Our Empire◦* AIP->distance_from_home_priority_modifier

2.Distance To Enemy Empire◦* AIP->distance_from_enemy_priority_modifier

3.Threat in Map Cell◦* AIP->attack_troops_priority

4.AIP->perimeter_priority (if a Perimeter Map Cell)
Defend Goal:
If the grid cell contains no friendly stations, the goal is invalid. Otherwise, the value is the SUM of these factors:
1.Distance To Our Empire◦* AIP->distance_from_home_priority_modifier

2.Distance To Enemy Empire◦* AIP->distance_from_enemy_priority_modifier

3.Threat in Map Cell◦* AIP->attack_troops_priority

4.AIP->perimeter_priority (if a Perimeter Map Cell)
5.Number of Our Stations in Cell◦* AIP->defend_buildings_priority

Attack Base Goal:
If the grid cell contains no enemy stations, the goal is invalid. Otherwise, the value is the SUM of these factors:
1.Distance To Our Empire◦* AIP->distance_from_home_priority_modifier

2.Distance To Enemy Empire◦* AIP->distance_from_enemy_priority_modifier

3.Threat in Map Cell◦* AIP->attack_troops_priority

4.AIP->perimeter_priority (if a Perimeter Map Cell)
5.Number of Enemy Stations in Cell◦* AIP->attack_enemy_base_priority

Explore Goal:
If the grid cell as already been explored, the goal is invalid. Otherwise, the value is the SUM of these factors:
1.Distance To Our Empire◦* AIP->distance_from_home_priority_modifier

2.Distance To Enemy Empire◦* AIP->distance_from_enemy_priority_modifier

3.AIP->perimeter_priority (if a Perimeter Map Cell)
Escort Goal:
If the craft this escort goal is attached to is destroyed, the goal is invalid. Otherwise, the value is the SUM of these factors:
1.Distance To Our Empire◦* AIP->distance_from_home_priority_modifier

2.Distance To Enemy Empire◦* AIP->distance_from_enemy_priority_modifier

3.AIP->perimeter_priority (if a Perimeter Map Cell)
Step 4: compute the match utility between a squad and goal
The squad match value is computed from the average matching value for the units in a squad. The match utility of a unit equals the SUM of these factors:
1.Distance from unit to goal◦* AIP->distance_from_goal_match_modifier

2.Raw Priority of goal.
Step 7: commit units from squad in match to associated goal
Units in a squad are committed based on their match utility; i.e. closest units are committed before further ones.

Step 8: check if the goal has enough unit strength committed to it
The Attack Goal, Defend Goal and Attack Base Goals, currently only require that the total shield strength of enemy units at the target is less than the total shields of the committed units.
Note: Force matching values are not currently used.

The Escort Goal is satisfied when units with shields that exceed 1000 * the Build Time of the ship have been committed. This obviously needs a more logical measure.

The Explore Goal is satisfied when at least one ship has been committed to it.

So, the map gets divided into grid squares for the strategic map. The value in A2 was set at 400 which is what was used in the first Armada game and all the "_map_resulution" values in the strategic_AI_cfg.txt file were 400 in the first Armada, but changed to 800 in A2.

I feel that changing the AI_grid_size to 800 or even more (needs testing) helps the AI better plan strategically because it's taking more area of the map into account. It can't plan properly if it's only taking 400 or a 4x4 grid into account. If it accounts for more of the map strategically it then gets a better picture of what's around a starbase, etc. A starbase itself takes up a 2x2 or 3x3 grid in some cases.

So far I'm seeing (repeatable behavior) like enemy AI that doesn't go into it's defensive AIP that often any more if it looses 1 or 2 stations. It just rebuilds and moves on. It truly has to be beaten back into it's starting area (most if not all stations destroyed) to go into it's defensive AIP. I'm seeing enemy ships seemingly avoid danger better. There was a group of about 12 Galaxies and a couple Akiras sitting in an area and a cube flew directly to them, but instead turned around. I saw this behavior in several other cases as well.

Don't misunderstand, I'm not saying the AI has been figured out as I still need a lot more play testing, but I'm seeing repeatable behavior so far that appears to me more logical and not just a dumb AI. In some instances a couple ships steer clear of the starbase and attack nearby research stations and yards, but sometimes the AI still flies ships right to the base and sits there getting shot to pieces so some things still need figured out.

So in recap I think the AI_grid_size in the RTS_cfg file needs increased in value to give the AI a better strategic view of the map. If you try it out let us know your findings. It might even make the original Armada game play better by increasing the value in its file.
1, 2, 3

Who is online

Users browsing this forum: No registered users and 4 guests