 |
|  |
 |
|
LDiCesare
|
|
La Ferté sous Jouarre France
Jan 2001 time: 05:28
|
|
I didn't really know in which thread this would belong best, so here goes:
I'm writing the code needed to allow the ai to decide what to build. Now I finally found how to do it, it all seems clear, and I think the player can benefit from it too, in terms of user interface.
Currently, ai and players say which kind of unit they want and how much production they want to put in each. This is fine, but maybe what they want is to have that proportion of armies, and when you get your legions killed but not the archers, you have to micromanage to get more legions produced than archers to keep the good proportions. Additionally, there's the fact that archers are listed before legions, so they get produced before.
Now, the player can change production orders when they like. The ai can too, but you must script it in the scenario file, which makes it not very responsive in general, unless you want to code all the ai in xml.
So what I am doing is writing an object that maps to a certain distribution of units. For the player, that would be pretty simple, he says I want 40% legion, 60% dreadnoughts, and how much globally the econ should spend on units, and voilá.
This, however, would require some econ changes, as I'd add an econ order like 'overall military spendings', whose production/kapital/food ratios vary depending on the player's input. I can always bypass this in a first coding attempt as there will be some waste (the same problem exists for walls, which share a single wall-building category).
And then there is the ai. I can also tell the ai to build units in proportion, so it will always have combined arms TFs rather than having mostly archers in an archer/legion case.
Last edited by LDiCesare on 25-05-2003 at 15:27
|
|
|  |
 |
|
LDiCesare
|
|
La Ferté sous Jouarre France
Jan 2001 time: 05:28
|
|
Obviously, building units that are needed instead of yet another archer is a good thing for the ai, but how does it know it should build a new unit when one becomes available? Particularly, when such a unit doesn't obsolete a previous unit, but is something new (like cavalry when you didn't have any, or airplanes or ships...)?
I define for the ai use a set of unit abilities:
Right now, I picked:
Attack, defense, breach, cost, support, movement.
This defines a set of abilities which the ai will want.
For instance, you may say you want:
60% legion, 30% archers, 10% siege engines.
But you may also state it thus:
60% attack, 30% support, 10% breach.
These are not categories, however. I don't like categories a lot, because if you label an army as 'defender', ai's like civ2 use it as defender when they would sometimes make excellent attackers.
Additionnally, I put movement and cost in because you may want a mix of these. For instance, I may want a set of fast cheap units to use as scouts, a few strong attack units, even if they are slow and expensive, and a lot of relatively cheap attack units which can move a bit.
So I have categories, with weights in each category:
For example I could represent scouts/strong attackers/cheap fast attackers this way:
Scouts: Movement 10. Cost 1.
Strong attackers: Attack 1.
Cheap fast attckers: Attack 10. Movement 3. Cost 1.
The ai would then scan the available units, classify each available unit in each category, and decide which unit is best to build. If the system works well, humans could also use it (for instance, I will use it because I have to tune the ai).
Mapping of units to abilities would vary a bit:
Breaching is a yes/no ability, so it is not hard to find out when you want siege weapons. There are more extreme cases, like being an airplane or a ship, where you don't even have the breach strength value available.
Attack, defense... are numbers, so there will be a number crunching equation I haven't devised yet to find out how much a unit fits a certain role.
So this approach is to define a set of categories that the ai can use, categories which can be defined on the fly if needed (like I realize I need breachers to get through the wall of city XXX). What do you think of the approach for the ai? Should the player be able to use it too? Would you use such an interface as a player?
Last edited by LDiCesare on 25-05-2003 at 15:33
|
|
|  |
 |
|
LDiCesare
|
|
La Ferté sous Jouarre France
Jan 2001 time: 05:28
|
|
All the infrastructure is coded. So now, the ai gets orders like this in the xml file (one of the following):
<AI>
<buildOrders>
<militaryProduction> 0.8 </militaryProduction>
<unitsProfile>
<production>
<order> Phalanx</order>
<level> 10 </level>
</production>
<production>
<order> Bowmen</order>
<level> 8 </level>
</production>
<production>
<order> Elephant</order>
<level> 1 </level>
</production>
</unitsProfile>
</buildOrders>
</AI>
This one tells the ai to spend 80% of its income on military, in order to get proportions of 10$ of phalanx for 8$ of bowmen and 1$ worth of elephants at all times in its armies.
<AI>
<buildOrders>
<militaryProduction> 0.8 </militaryProduction>
<abilityProfile>
<production>
<ability>
<attack> 1 </attack>
<cost> 1 </cost>
</ability>
<level> 2.0 </level>
</production>
<production>
<ability>
<support> 1 </support>
</ability>
<level> 1.0 </level>
</production>
</abilityProfile>
</buildOrders>
</AI>
This one is funnier, as it orders to have low cost strong attack and strong (fire)support units. This currently results in siege weapons and light cavalry for carthaginians in Delenda scenario. The ai can use this and adapt itself, picking the best available unit as new units become buildable.
(Although I must tune the choice function because it's a bit bugged right now).
The ability objects can be named too, so I hope I can put something nice into a user interface when all the internals work fine:
I'd let the player choose to
-choose units per name (as now)
-choose units per abilities, where you could create and name your own set of abilities, and then the UI would tell you what's the unit that matches this profile best, and build it. When a better unit becomes available, it would switch production automatically, but you could still build the old unit if you liked through the econ orders UI.
|
|
|  |
 |
|
LDiCesare
|
|
La Ferté sous Jouarre France
Jan 2001 time: 05:28
|
|
Here are (hopefully) screenshots of the UI.
Note it is not very good because:
- it is not exactly the correct type of window (should probably be dialogs instead of frames...)
- it lacks an edit function after you created the category
- it is not fully functional for it is based only on civ-wide orders and not province-only for example
- there are bugs (strange as it may sound):
Attachment: clashmilitary.gif
This has been downloaded 50 time(s).
|
|
|  |
 |
|
LDiCesare
|
|
La Ferté sous Jouarre France
Jan 2001 time: 05:28
|
|
Here is the edit category panel.
Note that this allowed me to see that chariots are vastly overpowered in the Carthago scenario.
Using attack only, romans will build chariots, if you choose attack = 1 and cost = 1, they'll build legions (weaker but more cost-effective).
This screenshot is not sexy, so I think probably the figures should be replaced by sliders, as big values will screw my computations anyway so it'd be better to limit the possible values to 0/0.5/1/1.5/2 with a slider.
Attachment: clashcategory.gif
This has been downloaded 47 time(s).
|
|
|  |
 |
|
LDiCesare
|
|
La Ferté sous Jouarre France
Jan 2001 time: 05:28
|
|
I answered about naval combat in the other thread. Shortly: yes, but there is no model beneath.
The screenshots are of functional windows, except there is a conflict with the econ UI somewhere. I mostly coded the UI to test the underlying classes gave correct results for the ai to use.
|
|
|  |
 |
|
LDiCesare
|
|
La Ferté sous Jouarre France
Jan 2001 time: 05:28
|
|
This interface is available under a Mili. button in the code I last sent Mark.
(Does this look like a shameless bump?)
|
|
|  |
 |
|
Richard Bruns
|
|
NC, USA
Nov 1999 time: 06:28
|
|
This all looks very nice. Has it been released yet? The most current version I have (7.7) does not have any of this.
I also ran into a problem with getting orders hidden. I was able to use the economics.xml to hide the Food and Manufacturing tech orders, but I was not able to hide a new tech I made for a scenario:
code:
<!-- ===New, hidden technology to be used as a counter for victory== -->
<technology>
<name>Families Captured</name>
<tier>3</tier>
<growthrate>1</growthrate>
<upkeep>0</upkeep>
</technology>
<activity>
<name>Capture</name>
<description>Kidnap families so they don´t fight</description>
<recipient>
<name>Families Captured</name>
<proportion>1</proportion>
</recipient>
</activity>
<govteconordersinfo>
<ordertypename>Capture Tech</ordertypename>
<orderclass>stub</orderclass>
<hidden>true</hidden>
</govteconordersinfo>
The player can still invest in the tech. What am I doing wrong?
|
|
|  |
 |
|
Richard Bruns
|
|
NC, USA
Nov 1999 time: 06:28
|
|
The files-all is declared before the code you just saw. Here's the scanario, though. And it is fairly small:
Attachment: onslaught.zip
This has been downloaded 1 time(s).
|
|
|  |
 |
|
LDiCesare
|
|
La Ferté sous Jouarre France
Jan 2001 time: 05:28
|
|
I'll setup a most-recent code version to use as a testbed. The version with that UI is not public yet.
|
|
|  |
All times are GMT. The time now is 05:28. Apolyton Time is 00:28. |
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
|
|
|
|
|
|