Author Topic: AI: Some AI Control and Walls, Gatehouses, etc  (Read 2249 times)

ChupaReaper

  • Guest
AI: Some AI Control and Walls, Gatehouses, etc
« on: 31 May 2010, 12:15:03 »
I've made a few buildings which can produce fighting units but the AI will only build one type, making one cheaper, etc would only mean it'd just build that instead, really more control over the AI using xml would help.
Some form of AI flags would be a good idea, this way the AI has more of an idea on how to use each unit. <important value="true"/> would mean that the AI would have to build this at some point in a random order with other units or better still <importance value="#"/> the lowest number takes priority. <siegebuilding value="true"/> would let the AI they need them for attack or defence. Some AI flags in the faction XML would really be good stuff like <siegebuildings-toattack value="#"/> how many siege buildings should the AI have at least before it makes its first attack. Could sit here all day and list loads of useful flags. Could link storage buildings with resources so the AI opts to build them next to their suitable resource, etc too. I'll copy this over as a feature request.
Also looking into the Stronghold series, each AI has 8 pre built castle designs, would this can be repeatability this idea could be useful for giving the AI hints on placing buildings such as an order of what to build, this could be set for each difficulty. Walls or any unit could be placed using a cell map with a list of randomly layouts to choose from, if a map object obscures the layout the AI would just build up to it as it still keeps them safe, with walls a flag would be needed for cellmaps which only allow allied players to pass through them. Something like this:
Code: [Select]
In units xmls...
<flags>
<building-importance type="important, siege or minor" order="#" position="resource_name, unit_name, closest or cellmap_reference" duplicate="true/false"/>
The lowest order has priority. Important buildings are built first then minor and siege are varied depending on whether the AI needs resources, defence or attack. Position helps with positioning the units, by a named resource, closest to the start, another building, if this building is not built the AI wont build this building until its position building is ready. Also a cell map reference, cell maps can't have the same name as a building or resource or closest therefore a convention such as cellmap01 or cellmap_walls should be used. Duplicate states whether the AI needs more than one, this works differently for each type. Important is more than one or just one, siege if false will build a siege building of each type before duplicate buildings, minor will work like important.

In faction xml or new ai.xml...
<ai name="cpu_(ultra)">
<unit-order>
<important-units> these are built before anything else, resources are gathered if needed.
<amount-per-session value="#"/>
How many units of this type to build before the AI decides to consider building an amount of siege or minor buildings, always minor after its first 'session'.
</important-units>

<siege-units>
<amount-before-attack value="#"/> How many to build before any attack.
<amount-for-powerattack value="#"/> How many to have for a full on attack.
<unit-combo unit1="unit_name" unit2="unit_name"/>
Combos for the AI to use when attack unit1 acts as a master unit so the Ai will try and make unit2 to fight alongside unit one. Linking more than one unit to unit1 would mean the AI would try and group a few types of unit2s with unit1, a snake effect could be created by linking unit2 to unit1 then a new unit2 to the old unit2 so for example:
<unit-combo unit1="ravager" unit2="reaper"/>
<unit-combo unit1="reaper" unit2="worg"/>
This would create an effect where there are many ravagers a load of reapers and a worgs, vs:
  <unit-combo unit1="ravager" unit2="reaper"/>
<unit-combo unit1="ravager" unit2="worg"/>
Here there will be a more equal amount of reapers worgs alongside a load of ravagers. Basically look at it as a chain, the further down the chain, the rarer and less amount. Dependency loops could be made but this would just act as a separate chain, each chain is picked randomly. This way you can have strategies per AI difficulty, these would be random too. If buildings are set here they will be included this way units can be build for defence.
</siege-units>

<minor-units randomize="true/false">
This will work the same as important only not as important.
</minor-units>
</unit-order>

<cellmaps width="#" height="#">
These are referenced by buildings using the position attribute. All cellmaps must have the same width and height. Cell maps are centred from the starting point using the top left centre cell of the cell map is even width/height (if it is odd an exact cell in the middle is used).
Different behaviour could be set for each map so:
behaviour="close" 1 = build here (randomly on it or as close as possible if obscured). 0 = Don't build here unless obscured or a non-cellmap building. Positions are chose randomly.
behaviour="exact" 1 = built from the top left of here. 0 Don't build here unless a unit is too large to fit completely in a 1 area. If obscured from a point completely then don't build at all.
behaviour="wall" Same as exact but once the first unit is placed the AI will attempt to build as close to that as possible.
<cellmap name="cellmap_01" behaviour="close"> Here is an example of placing some buildings, good for defence towers, etc.
<field value="000000"/>
<field value="010010"/>
<field value="000000"/>
<field value="000000"/>
<field value="010010"/>
<field value="000000"/>
</cellmap>
<cellmap name="cellmap_01" behaviour="wall"> Here is an example of placing walls.
<field value="111111"/>
<field value="100001"/>
<field value="100001"/>
<field value="100001"/>
<field value="100001"/>
<field value="111111"/>
</cellmap>
One more thing, AI will try to box it self in but not completely, it will keep on building until it  is about to box itself in, here it could use a flag called <box-in value="#radius"/> so it will ensure that it can always get out of its domain with this radius considered. More thought could be put into Gatehouses with a flag set to tell the AI these are to be placed in box-in gaps with the radius considered still, these buildings must have a cell map. Alternatively you could have complete control setting the box-in to 0 and using exact and wall types to have complete control over where the AI builds.
</cellmaps>
</ai>

A hell of a lot there, something like that would be nice or a smart AI that works it out itself. More realistically though a few flags for builds would be useful, especially ones to force the AI to build a buildings and not to (as randomly blocks of walls just look stupid at the minute so might as well disable them from the AI for now).
« Last Edit: 19 September 2010, 16:38:18 by ChupaReaper »

emscape

  • Guest
Re: AI Hints and Walls
« Reply #1 on: 31 May 2010, 13:58:47 »
SOUNDS NICE! PLEASE PLEASE PLEASE integrate it:D:D:D:D:D:D:D:D:D:D:D
(oh and the possibility to make walls in one time also)

ChupaReaper

  • Guest
Re: AI Hints and Walls
« Reply #2 on: 31 May 2010, 14:42:53 »
That's an idea, could group every unit of a wall as one unit, that way it could be upgraded using morph where all units morph at once, the resource cost and time, etc would be every wall unit's added together. Building the entire would should be optional though because I think it would be odd if a whole wall was built from nowhere also if something gets in the way while it's being placed it would get awkward.

Gabbe

  • Guest
Re: AI Hints and Walls
« Reply #3 on: 31 May 2010, 14:52:47 »
wall is the most anticipated feature right?

ChupaReaper

  • Guest
Re: AI Hints and Walls
« Reply #4 on: 31 May 2010, 20:30:17 »
Well my mod has walls in it now along with gatehouses which can open and close so for human players they're pretty much in now though stairs and having units mount the walls would be nice but that's been requested a lot already. I think their should be some control over the AI using xml, what I put above is a lot but some parts are more realistic like forcing the AI to build things, then again I don't know how it's all programmed so I could be very wrong, I do know the AI needs to catch up, I'm not so bothered though because I'll be networking mostly, though it is nice to team up against a super hard AI.
I know there's gonna be more than 4 players in 0.3.0 (if think that's right), I'd rather see this first than AI improvements.

Gabbe

  • Guest
Re: AI Hints and Walls
« Reply #5 on: 31 May 2010, 20:55:38 »
16 player support yes, im going to play your mod on the LAN as my faction, were having a tournament, every time before the LAN me and the leaders make sure the mods are balanced and then we maqke them ready. like every player sends us their chosen mod and then i make sure theyr balanced, if theyr not i change XML and then we can play with them in a torunament..OT i think...anyways, i would mostly like to see Walls, but the AI i suppose is always under work?

ChupaReaper

  • Guest
Re: AI Hints and Walls
« Reply #6 on: 1 June 2010, 14:35:14 »
OT: That tournament thing sounds interesting, my faction still has a bit of work before it'd be ready and might be quite hard to balance due to damage multipliers, also network Glest crashes with emanations at the minute.

Gabbe

  • Guest
Re: AI Hints and Walls
« Reply #7 on: 1 June 2010, 17:50:51 »
Mounting walls would demand something from the pathfinder, a 3D pathfinder, and stuff...

ChupaReaper

  • Guest
Re: AI Hints and Walls
« Reply #8 on: 2 June 2010, 08:42:44 »
Ah, now I know making a new path finder would be a lot of work, I've some ideas to do with meddling with the fields property though, the unit could just change to a mounted field and is then raised from the ground depending on the height of the unit it is currently on, still units would need to know what heights they can climb at, etc which would turn to the path finder I think.

Gabbe

  • Guest
Re: AI Hints and Walls
« Reply #9 on: 2 June 2010, 13:46:19 »
It would aswell need a new 3D map maker, but we could start simple and have two maps, surface and under ground.

ChupaReaper

  • Guest
Re: AI Hints and Walls
« Reply #10 on: 3 June 2010, 11:33:35 »
Advanced maps could have xmls (stored in the maps folder with the same name) these xmls could link to 'submaps' which would act as maps for the different fields, the main map would be for ground and water then an underground/underwater map and an air map. This would make the game much trickier to map for though, but would be interesting.

Before that though I think more AI should be worked on as the AI would have to use these advanced maps too so working on the likes of walls and even mounting walls would take priority.

Gabbe

  • Guest
Re: AI Hints and Walls
« Reply #11 on: 3 June 2010, 13:33:20 »
archers should also be able to attack from the map were the tower is to the map were the surface is.

emscape

  • Guest
Re: AI Hints and Walls
« Reply #12 on: 5 June 2010, 15:57:49 »
maybe just create one map, and a transition map, and a semi air map for units on walls, the air map would be an xml which would be empty at the start but some information about the heigt, when u build a wall and stairs it will change the air map and the transition map...

so mapmaking wont get more difficulty, and u can still make rock walls and stuff....

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: AI Hints and Walls
« Reply #13 on: 6 June 2010, 02:08:04 »
What's wrong with multilayered maps? Its almost commonplace with games today.
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

ChupaReaper

  • Guest
Re: AI Hints and Walls
« Reply #14 on: 15 June 2010, 01:56:40 »
A 3D map editor built-in to Glest would be the best with the ability to choose what tileset you want to edit the map in and to change the tileset so the game quickly loads a new tileset, this way you can see exactly what it'll look like. I think it will be a very long time before anything like this though lol still would be pretty damn awesome!