 |
|  |
 |
|
calvitix
|
|
Strasbourg (North-Est France)
Jun 2003 time: 05:34
|
|
Hi,
As I don't have any network skills, I began to work on AI understanding, specially the unit movement.
There's some playtest commands (ie with a DEBUG executable) that are very useful to understand the units' movement.
(to activate them, use the 'Command enter alternate (playtest)' Bind and then write the code)
armytext : to see the unit's Goal on the screen. I enhanced the command to see the target's coords (X,Y)
(see thread altered sources)
god : to take on or off the 'fog of war'. useful to see what the other Civs are doing. Problem, when the fog of war is Off, the AI is able to 'see' all the map too and its behavior changes. So I usually toogle it Off at the end of each turn to see what's going on, and then toogle it On before pressing Enter.
celltext : to see a value of each mappoint (used by the Settlers to find a city place).
Here's a list of my observations :
- Chokepoint : On map with islands, a lot of units are affected to Goal Chokepoint (to protect a particular point on the map, with strategic interest). The problem is that some 'chokepoints' are bad chosen
- Squad problem : the AI don't seems to group the units that have the same goal: Each unit is considered as a single squad. the only case where the group seemes to work is when a settler needs protection. I'm working on an additional algorithm to group the unit with the same goal.
- Sea transport : the algorithm seems good : when a unit has to go on another continent, it get the nearest available transport and a rally point is automatically defined. sea assault with only one or two units is the consequence of the squad problem.
It would be good to implement an escort algorithm for the sea transport units (as it exists for settlers).
- threat calculation : problem with threat calculation : too many units are affected to the goal_defend, due to a very high threat value. that's why AI sometime has got a lot of units around its city (all are affected to the city defense).
I'll make a try with a 12-units limitation for one goal. For the moment, I didn't find the origin of the problem.
I don't know if anyone else is looking for the same improvements, any experience or help w'd be appreciated...
(for people that don't have the possibility to compile the source code and want to use the playtest commands,
it is possible to give them the compiled CivCTP_dbg.exe)
Attachment: armytext.jpg
This has been downloaded 333 time(s).
|
|
|  |
 |
|
Martin Gühmann
|
 |
Berlin, Germany
Mar 2001 time: 06:34
|
|
quote: Originally posted by calvitix
- Squad problem : the AI don't seems to group the units that have the same goal: Each unit is considered as a single squad. the only case where the group seemes to work is when a settler needs protection. I'm working on an additional algorithm to group the unit with the same goal. |
I think this is the most important problem, a part of my BetterAi slic code is about grouping units. I saw an improvement afterwards I grouped them with slic. Looks like if I add the NeedsEscord flag to the attack goal I would make the AI to group the units for attack. And removing this flag would keep the AI from binding troops to settlers. However I think there should be a different algorithm for attack grouping, maybe it could be bind to the RalleyFirst flag. However grouping units for defence in cities might be a problem, because if you have 12 units there and the city is building a new unit you don't have space. So one unit should leave the city before the build event, or if the city is full the unit should be created outside of the city, but with less move points.
quote: Originally posted by calvitix - Sea transport : the algorithm seems good : when a unit has to go on another continent, it get the nearest available transport and a rally point is automatically defined. sea assault with only one or two units is the consequence of the squad problem.
It would be good to implement an escort algorithm for the sea transport units (as it exists for settlers). |
Maybe there is also an problem if the squads are to huge for the transport. Afterwards I grouped my units via slic I didn'd saw full transports, and even loading these transports by slic was tricky. If there is enough room on the transport for the stack no problem, but the stack is too big then I had to ungroup the units myself and give every unit the transport order and I think there was another problem.
quote: Originally posted by calvitix
- threat calculation : problem with threat calculation : too many units are affected to the goal_defend, due to a very high threat value. that's why AI sometime has got a lot of units around its city (all are affected to the city defense).
I'll make a try with a 12-units limitation for one goal. For the moment, I didn't find the origin of the problem. |
So setting all this to zero should help, but then I fear I break something else:
code:
// priority for fear motivations
FearInvasion 1000
FearCityDefense 1100
FearPiracy 900
FearScienceRank 800
FearMilitaryRank 800
FearTradeRank 800
FearPollution 900
Actual I don't like the 12 units limitation, well you can experiment with it, but I would feel better if the problem is solved at the root.
quote: Originally posted by calvitix
I don't know if anyone else is looking for the same improvements, any experience or help w'd be appreciated... |
Well I assumed that Peter was looking into this, he talked about that he looked at the transport thing and about modification on the startegies.txt, but he never posted anything about it. Therefore I decided to give up on hesitating and exposed the startegies to personalities.txt. And I thing you shouldn't hesitate either.
-Martin
|
|
|  |
 |
|
calvitix
|
|
Strasbourg (North-Est France)
Jun 2003 time: 05:34
|
|
quote: Originally posted by E
One question on chokepoint. Is it feasible for the computer to identify a tile with a GOOD and defend it because it has a good? This would be needed for implementing strategic resources... |
It wouldn't be a problem, it is possible to add tiles with good as chokepoint.
|
|
|  |
 |
|
Peter Triggs
|
|
Gone Fishin, Canada
Jan 2000 time: 05:34
|
|
Hi, guys
I'm essentially computerless (posting from wherever I can at the moment) but have just bought a new one and hope to get back into things early in September.
Peter
|
|
|  |
 |
|
calvitix
|
|
Strasbourg (North-Est France)
Jun 2003 time: 05:34
|
|
Hi,
it's time to report and release a first version of my work on Army movement and grouping.
(source code is in thread 'altered source')
the changes I made are quite heavy, and some unwanted effects on AI movement can appear.
That's why I release now that version as beta, I alone can't test if all the unwanted consequences of my modifications.
(I do test it for 2 weeks now, and it seems to work well for the moment).
I'll soon post an executable that can be used with latest playtest package for people that don't compile the sources...
Here's a list of observation and changes :
1. original AI grouping worked good for settler escort, the princip has to work for armies too...
So why isn't it working ?
1.1 There is not enough units to affect to goals (too many are defending or for garrison)
AI cities are always filled with units. 3 reasons :
- Garrison : as described in strategies.txt, a minimum of units are affected to garrison.
- Defend : units with goal Defend. not the same units as those for garrison.
- Retreat/no Goal : when a unit isn't affected to a goal, it will be affected to goal RETREAT,
so the unit goes back to the nearest city.
first problem : too many units defending : units for garrison aren't included in goal matches but are blocked in the city (and they aren't affected by the deleteobsoleteunits action, that's why we can find phalanx or catapult in AI cities during all the game).
in addition to those garrison units, some armies are affected to goal DEFENSE (depends of threat). So I give only the minimum values for garrison in 'strategies.txt'.
second problem : the RETREAT goal don't works as expected (it should retreat units from ennemy territory).
I desactivated it for the moment, until a real non trespassing action is developped (I'll working on it after cargo problem...).
1.2 The army affectation to goals (the matches) doesn't promote grouping
the matches (a link goal <-> unit) are sorted by a value that depends on goal priority, distance to goal destination...
Problem : an Army will be affected to a low priority goal that is near (with high match value) rather than a high priority goal that is far (such as SEIGE or ATTACK). So a High priority goal but that needs a lot of units will never be satisfied, because all the available units would be all affected to single low priority goals (such as Pillage, pirate, chokepoint,...)
Changes : now the matches are sorted by goal priority, and the by matches.
Unwanted effects : if a Goal uses the NeverSatisfied && UseIncrementally options, it 'll get all the available units. those options are not used for the moment (I remove it from goal RETREAT)
1.3 The condition to declare a goals satisfied (ie with enough armies) isn't optimal
Each goal has a needed_strength. a goal is satisfied if the affected army is higher than the needed strength.
Problem : that needed_strength is satisfied if the army's attack OR defense is higher.
Changes : now the sum of all parameters as to be satisfied (not only attack or defense).
1.4 The force matching in 'strategies.txt' doesn't promote grouping
The force matching values are usually about 0.6. it means for example that in order to attack an unit with 200 in defense, an attack_strength of 120 will be enough. (quite suicidal, as it has less than 30% chance success).
Personly, I only attack when I have a real chance to win the combat. So I raise the ratio values...
To attack an unit, AI will now have to regroup an army with enough strength before attacking.
All those ratio value have to be adapted (different values for the different strategies...)
2. When an army is affected to a goal, it will be released only when the goal is accomplished or cancelled.
So I try to reevaluate all the goals affectations every turns
3. with those modifs, AI now groups units, but can't ungroup them
AI don't need only grouped armies, but also single units (to explore, ...)
So I added a token 'UnGroupFirst' for several goals in 'goals.txt', and ungroup methods associated...
4. Goal Explore : new goal are only created when all old one's are accomplished.
Now, it set new goal every turns. I Changed also the resolution (an explore goal every 2 tiles instead of every 5 - perhaps can be set as constant in 'const.txt' ?).
5. too many units in cities -> problem with transports
As there is a lot of units in the cities, transports have to get out of cities to allow armies to board in.
So I use a copy of the 'make room' algorithm to expulse the transports out of city. it leaves them quite undefended,
that's why I'm working on their protection (next point)
6. Transport protection (to be done)
transport units are vulnerable, they should be protected as the settlers.
7. Road and Tile Improvement
I discovered that the Road and Tile improvement construction is only every 5 turns. changed to do it every turns.
I'm now waiting for questions,comments or eventually bug reports.
I'll go on with tests and try to work on further points :
- the transports (protection, huge armies' cargo problem)
- treaty respect (non trespassing,...)
- retreat of wounded units to heal (in city or forts)
|
|
|  |
 |
|
calvitix
|
|
Strasbourg (North-Est France)
Jun 2003 time: 05:34
|
|
quote: Originally posted by Martin Gühmann
Why have the transports to leave the city in order to to allow the army to board in? I would put the units into sleep mode and leave with the transport the city, the units are then put automaticly on the transport.
|
The problem is when the transport is in the city with for example 8 units, a 5-units army cannot enter in the city to sleep. it occurs only when the join point is defined as the city tile (that appends when the transport is in a city at the moment we need it), but I encounter the problem several times during my test games.
quote: Originally posted by Martin Gühmann
Is it really necessary to do it every turn, I mean this eats calculation time, and such a delay of 5 turns doesn't matter I think. In fact it helps the AI to save some PW for more expansive tile improvements.
-Martin |
it has to be discuss when we'll work on tile improvement and road. (I don't really care for the moment on calculation time, and for some games it can gives advantages (specially for roads that have to be build after pillage or pollution). can rollback the change, not a problem for me...
|
|
|  |
 |
|
Martin Gühmann
|
 |
Berlin, Germany
Mar 2001 time: 06:34
|
|
In the case above it is the 2 res game, the units are concentrated at the coast, I think this is OK as the Incians are at war with the Scotts and the Americans on the other side of the see. However one thing I don't like about the groups is that there are more groups then necessary. We don't see 12 units at one place but rather 4 or 6. That is more vulnerable to an attack then the 12 units solution. However some more compact rallying and that would be fine for the invasion. The oversea invasion itsself seems to work, however the AI moves single ships and that is not so good, because this means that the units arrives at different points of time on the target continent, where single units are a easy goal. In fact the units should arrive at the same point of time and at the same place, a 12 statck is better then a 2 stack. In fact another problem of this fleet is that the ships have all different targets. My strategy in that case would be to move the units or enough units to one target on the other continent combine there the force and attack.
Attachment: inka_invasion_test1.jpg
This has been downloaded 226 time(s).
Last edited by Martin Gühmann on 03-09-2004 at 22:12
|
|
|  |
 |
|
calvitix
|
|
Strasbourg (North-Est France)
Jun 2003 time: 05:34
|
|
Hi Martin,
Thanks for all those reports
To be clear, all the changes I have done about grouping are to allow AI to group units. For the moment, the AI also comport itself as the activision developpers implemented it (contrary to Frenzy for example, I didn’t force the units to group).
I didn’t change anything for the moment about the way transports works or AI attacks, I just change the order in goal affectation to enable them.
quote: Originally posted by Martin Gühmann
However now to the military strength in both games the strengthes do not grow liniarly. That is a good sign, because this means that troops are using and killed in battles. However this should be more effictive. But in the end we have to investigate how it turns out in the next 300 turns. But in the end I see that we still need some improvement. |
So Yes, there is still a lot of work left.
A lot of improvement or problem you mention can be resolved by adjusting the values in goals.txt and strategies.txt. I’m working on it, for the moment on maps without sea (there is enough problems to solve first only with one continent…)
quote: Originally posted by Martin Gühmann
However one thing I see is that the AI has units in the middle of nowhere. What do the units there. |
To better understand what each army is doing, you can activate armytext (even in final version) by changing the m_armyTextOn variable to ‘true’ in the gfx_options.cpp constructor.
(I usually add the coords in infobar too (by desactivating #ifdef _DEBUG after the command : Concat(g_theStringDB->GetNameStr("INFOBAR_UNEXPLORED")); in infobar.cpp).
quote: Originally posted by Martin Gühmann
And the same situation in the 5 res game, well the Incians explored a little bit further then in the 2 res game |
I tried it again an it effectively appears that with a 5 resolution AI is exploring further, unless you have a lot of small islands. Perhaps it will be wise to set the value depending on map size and number of continents. For the moment, rollback to 5 will be easier.
About Calculation time, one problem is that the expore goals are added every turn with my modifications (I desactivated a condition that added explore goals only when there aren’t any left.
I tried to change it to add explore goals only when half of maxeval goals are remaining, so it improve performance and the goals are regulary added.
quote: Originally posted by Martin Gühmann
However in both games I see units sitting in the middle of the main civ territory: |
With original AI, the unused units were send back to towns. Now they stand where they are. But I don’t think those units are unused. It's probably a NO_PATH problem (please check it with armytext).
quote: Originally posted by Martin Gühmann
We don't see 12 units at one place but rather 4 or 6. That is more vulnerable to an attack then the 12 units |
The units are grouping until the needed force for the goals is reached. To have 12 units group, the force match ratio in strategies.txt can be raised (specially value_ratio (or we can add threat ratio in needed_force_computing).
|
|
|  |
 |
|
calvitix
|
|
Strasbourg (North-Est France)
Jun 2003 time: 05:34
|
|
Hi,
I never had seen so much unused forces! (due to personality of Incans perhaps…). I just discovered a bug in my armytext concerning 'NO GOAL'. When a unit is doing the same goal for several turns, the armytext is reset to NO_GOAL… So perhaps they weren't all unused but blocked for any reason. I'm fixing the NO_GOAL bug and I'll post the new patch soon. Could you post a savegame for this game?
Other points I'm working on (I'm in holiday this week, I expect to have time to finish them to post all I'll have done) :
Wounded units retreat:
When a unit is wounded (criterion : less than half HP), it will have bonus for defend or retreat goals, and malus for other attack goals.
Territory respect :
When non-trespassing agreement, all the goals concerning the territory will be considered as BAD_UTILITY (explore, seige, attack,…) - Only for Civ with Lawful or neutral.
Problem with garrison units :
When a city is taken (by seige force), all the group is actually affected to garrison. So I have to ungroup garrison forces (only one or two have to be affected to garrison, other can be affected to other goals.
Grouping Problems :
When units are one tile close and want to group, it appends on several cases a 'cat-mouse' play : the two units endless go to tile where the other unit was.
Pathing problems :
1. Grouped units cannot go across cities (due to max army problem). The pathfinding don't check that (it checks only the final destination), and the army is blocked. I trried to place roads to avoid the city, but the pathfinding apparently prefer going through cities.
2. When units are in enemy territory, (civilian or not), they most of the time path close to enemy cities (to use the benefits of roads). Problem : enemy bombards them (AI loose a lot of units this way). It will be wise for those units to avoid tiles that are too close from cities.
3. Roads problem : when a tile with road is polluted, AI don't build road around…
In order to realize those last points, I introduced a concept of avoid tiles (tiles that are forbidden for pathfinding). When demanding to find path, we give as parameter a list of avoid tiles.
Princip :
1. find a path without setting avoid tiles.
2. Check for each tile of path if it has enough room (or if it is too dangerous, or if the tile is polluted).
3. If such tiles are found, set them as avoid tiles and try to find another path.
4. again check…. This can be reproduced several time (MAX_CYCLES has to be defined).
I know, it's again time consuming, but I didn't find other solutions. Perhaps any ideas ?
Exploration
No idea why units aren't explore further. Perhaps they entered in war, and all units were required to set war. (It appends during my test games). The problem I have seen in games that need sea invasion is the lack of transport units (specially If the sea distance is high). As I said I first concentrate my efforts on 'One continent games' - map with only land.
With units respecting non-trespassing treaty, I experienced that AI doesn't explore much in enemy territory. So I add a new goal : GOAL_STEALTH_EXPLORE, to use special units to explore deeply in enemy territory. It works fine, except the fact that settlers ARE special units (and I have the same problem you mention, there is too much settler unit, even if there is no room left to settle… perhaps we'll have to add a condition : settler units can only be build if there is settle goals). So I have a lot of settlers coming right in my territory, a pleasure for slavers :.
Stealth Units
By observing special units, I discover they aren't very efficient : (spy trying to steal_technology on civ that don't have any,… abolitionists that try to free slaves where there isn't… I think I'll apply a filter to cancel all those stupid goals. AI so will cheat, by knowing where it's useful to send spy and other units, but it's really needed (otherwise those units are quite useless for AI - I Ttink that's why there have been desactivated in SAP…
For all the changes described here, I have to introduce several new constants in 'goals.txt' and 'strategies.txt', It seriously reduce the chances of backward compatibility (and mod compatibility). But I think we have to go in that direction to really improve the game.
As I said, I'm on holyday, so I don't know how often I'll be connected… (I'll also change my Internet connection too, I'll soon have DSL). Please be patient if I don't respond quickly next weeks…
|
|
|  |
 |
|
Martin Gühmann
|
 |
Berlin, Germany
Mar 2001 time: 06:34
|
|
quote: Originally posted by calvitix
Wounded units retreat:
When a unit is wounded (criterion : less than half HP), it will have bonus for defend or retreat goals, and malus for other attack goals. |
I don't think less than halh HP is a good criterion alone, you also have to consideer the military readiness, so a better criterion would be less HP then military readiness gives.
quote: Originally posted by calvitix
Grouping Problems :
When units are one tile close and want to group, it appends on several cases a 'cat-mouse' play : the two units endless go to tile where the other unit was. |
Well you have to check before the move if there is still the other unit on the destination tile to end that game.
quote: Originally posted by calvitix
Pathing problems :
1. Grouped units cannot go across cities (due to max army problem). The pathfinding don't check that (it checks only the final destination), and the army is blocked. I trried to place roads to avoid the city, but the pathfinding apparently prefer going through cities. |
I think the path finding algorithm needs to be improved in general to take this problem into consideration.
quote: Originally posted by calvitix
2. When units are in enemy territory, (civilian or not), they most of the time path close to enemy cities (to use the benefits of roads). Problem : enemy bombards them (AI loose a lot of units this way). It will be wise for those units to avoid tiles that are too close from cities. |
In my BetterAI.slc I check whether the city is a good goal if the army encounters one. In general when an army is in enemy territory, then everthing there is a possible goal. If the unit should go to a city to attack it but it encounters an enemy stack that is weak enough it attacks this stack. If the enemy stack is too strong and the army can bombard the army bombards. If it encounters on the way to another city a city that is also worth of taking then the city is taken. In conclusion I would change the goal of the army if there is something on the way. It is more intelegent to take outposts first then the capital in the middle of the empire.
quote: Originally posted by calvitix
With units respecting non-trespassing treaty, I experienced that AI doesn't explore much in enemy territory. So I add a new goal : GOAL_STEALTH_EXPLORE, to use special units to explore deeply in enemy territory. It works fine, except the fact that settlers ARE special units (and I have the same problem you mention, there is too much settler unit, even if there is no room left to settle� perhaps we'll have to add a condition : settler units can only be build if there is settle goals). So I have a lot of settlers coming right in my territory, a pleasure for slavers :. |
That's right that settlers and slavers are special units, but the setter has VisionClass: Standard and the slaver has VisionClass: Stealth. So you should rather consider the vision class, then the attribute special unit.
quote: Originally posted by calvitix
Stealth Units
By observing special units, I discover they aren't very efficient : (spy trying to steal_technology on civ that don't have any,� abolitionists that try to free slaves where there isn't� I think I'll apply a filter to cancel all those stupid goals. AI so will cheat, by knowing where it's useful to send spy and other units, but it's really needed (otherwise those units are quite useless for AI - I Ttink that's why there have been desactivated in SAP� |
That's a real problem, if the spy figures out the other civ does not have any techs to steal he should change the goal and try something else on the same city. Abolistionists should know which city has slaves has human player you know it when you arrive at the city. For the special units in Apolyton Pack, I cannot remember that they have been disabled there, the only problem there might be the settings in strategies.txt. In fact I was able to make the AI use of them in GoodMod and not only the slaver, but also Clerics. One problem I see with the special units is if they have more then one possible order, that I was only able to make the AI use of one order but not of the other orders.
-Martin
|
|
|  |
All times are GMT. The time now is 05:34. Apolyton Time is 00:34. |
top of page
|
|
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
|
|
|
|
|
|