Home   Help Search Login Register  

Author Topic: Giving the AI brains without input from the mission designer  (Read 2537 times)

0 Members and 1 Guest are viewing this topic.

HelmutS

  • Guest
Okay, anyone here ever played "Combat Mission" tactical war games or similar?

It uses non-scripted AI, and creates random maps from pre-made tiles. Still the AI manages to "find" the right spots for defensive positions on every new map made without anyone telling it in the editor. It also even manages to attack "victory locations" correctly (correctly means tactically sound) without any pre-scripted paths.
This gives it a lot of replayability which currently lacks in OFP self-created missions.

I think there's a not too complicated way of getting similar random AI-Setups into OFP Missions. But my scripting skills are not that good yet, so some input is appreciated.

Obviously just using waypoints with randomized range circles will not place the AI in good defense positions.

I think what we need here is a two-part script.

Part 1 would enable the player to "map" an area for the AI. You would walk (or drive) the mission area for your later mission, and see to find good defensive spots. When you find one, you call a script that writes the position to some kind of database - including the information if the defense spot is meant for vehicles, a squad, or a gun/HMG. You'd also store the player's view direction into it so if you're looking south, it will be a defense position against an attack from the south.

With this kind of semi-automation, you could easily map 30 to 45 good defense spots in half an hour.

The second part of the script would then take a given amount of enemy troops provided by the mission editor, and place them randomly into these defense positions. It would make sure to place vehicles in spots marked for vehicles, infantry in their own places, and heavy weapons/guns as well. It would also take into account the direction from which the player is going to attack - so if you're coming from the north, it wouldn't use the south defense points etc.


This would be a very basic start to get some replayability into custom made OFP attack/defense missions.

I guess technically (though this is very advanced) you could actually place one AI unit on the map - place a grid-like arrangement of other AI units around it - and use the "can see" command to automatically determine field of view/line of sight from any given position on the map.

A good defense position usually is one with the defender in cover, and the enemy in the open. If you can determine line of sight from any given position, you could create parameters that would automatically identify good defense positions.


Lastly, if you use the knowledge about LOS from any given point on, you could actually simulate the AI "sneaking up" to pre-set victory locations on their own without the need for user-created waypoints.

In summary, I think it's possible to have non-scripted but tactically decent AI reactions in standard attack/defense type of missions. Lack of such is what keeps me playing Combat Mission and Battlefield 1942, because contrary to OFP in those games I never know what will happen.

bdfy1

  • Guest
Re:Giving the AI brains without input from the mission designer
« Reply #1 on: 04 Jul 2005, 01:23:57 »
As far as I understand you sugest to choose a massive of right positions for AI and then force bots to use them during battle ?

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:Giving the AI brains without input from the mission designer
« Reply #2 on: 04 Jul 2005, 03:51:15 »
This is one way of 'teaching' the AI to use it's environment, but in essence all it is is providing pre-set locations and paths. If you've obseved the AI acting under a 'DoMove' command you'll see this behaviour. In fact, this approach is the one favoured by most games. You will find that BF1942 uses a variation on this theme also, and although it might be harder to observe it's still there.

Teaching the AI to 'read' it's environment dynamically, like you mention, is most certainly possible, and I am making (or was making, it's kind of on hold at the moment) one or two subclasses of AI in UT that attempt to do this, but the problem I find is the sheer processing power and large chunks of memory required to do the calculations. The standard AI in Unreal Tournament uses a set a pre-defined coordinates called pathnodes which it interpolates to calculate the shortest distance to a point; UT can have dozens of creatures roaming the map at any one time, smoothly. I can run one instance of my creature in UT at a time, and it takes several seconds where my computer is totally frozen for it to calculate a path through some obstacles on a level suface.

Phew, going a bit OT there, back to what you were saying.

I guess technically (though this is very advanced) you could actually place one AI unit on the map - place a grid-like arrangement of other AI units around it - and use the "can see" command to automatically determine field of view/line of sight from any given position on the map.
I've never heard of the 'can see' command- what is this ??? Is it a function someone has made?

A good defense position usually is one with the defender in cover, and the enemy in the open. If you can determine line of sight from any given position, you could create parameters that would automatically identify good defense positions
Line of sight has been a problem I spent a lot of time on, and could come up with no reliable method to determine. My best attempts were often up to 1-2 metres wrong, the projectile used succumbed to gravity and was totally inaccurate over long distances.... the full story is in another topic on this board.

 I agree totally that LOS would be incredibly useful if indeed it were possible, and that it would be easy for the game designers to add a scripted command, given that they must surely use raytraces in the AI core  :-\, but people inform me that that is unlikely to happen.

Lastly, if you use the knowledge about LOS from any given point on, you could actually simulate the AI "sneaking up" to pre-set victory locations on their own without the need for user-created waypoints.

Terrain is just one of the problems with this, and although I'll admit it probably is possible, I've had only limited luck calculating paths on sloped surfaces so far (speaking about UT now). It's possible, straightforward even to help an AI navigate along on a flat plane, but more difficult when you introduce inclines. LOS and collision cylinder checks often fail on inclines where in fact there is a clear path between two points. Introduce obstacles (for example editor-placed sandbags and fortifications, if we're talking OFP) and it becomes even more difficult.

Hm, to round this off... the idea of preset locations may well work, but storing the data you collect might be a problem. You want to produce some sort of output file that the mission designer can user later for their map, because it's not possible to transfer information between two separate instances of a mission. When a player plays a mission, any information for that mission must come from that mission itself.

So you'd need some for of storing all this tactical data in a form that the mission designer can readily translate into AI waypoints, domove commands, et cetera. I've no idea how you could achieve this, short of making a dialog that dumps the data in a text field for the mission designer to copy and use later. That's still quite a lot of work..... but certainly possible. However I think the LOS idea is doomed, unless this 'cansee' function works. Otherwise, you just have no tools available to do what you suggest.

HelmutS

  • Guest
Re:Giving the AI brains without input from the mission designer
« Reply #3 on: 04 Jul 2005, 09:51:36 »
BDfy1 - yes, that's the most basic approach.

Map out good positions for the AI, and then randomly populate them. This gives better replay value than standard static defense positions, and it's better than totally randomly placing AI which may end up in bad positions.

Fragorl - my mistake.

I thought there was a "can an unit see another unit" command, but recently I looked closer and all I found was the "Isaware" command. Which doesn't seem to take forrests into account and does not very well translate into real LOS terms.

I guess you know exactly what I wanted to do and tried that already, but if you have found  no LOS check option then most likely neither will I.

Real-Time LOS calc is out of the question anyway - indeed what one would need is some way of writing a basic text file with all favorable locations in a pre-mission run and then to use these "waypoints" later during the execution of the mission.

I guess my basic idea was sound, but if the tools aren't there to script them then we're lost. Even though it would be really great to have random AI setups and might they be just as stupid as BF1942 - it would still be a lot more replayable than the current status Q.

bdfy1

  • Guest
Re:Giving the AI brains without input from the mission designer
« Reply #4 on: 04 Jul 2005, 15:52:56 »
Great , one more topic about ingame AI :)
HelmutS, there is a script: unit changes its positions after several shots. Those positions are predefined by missionmaker (do you suggest  terrain maker to do this ?) placing markers etc. Unit moves on its own using ingame pathfinding algorithm.  
Fragorl, I guess you start on pathfinding just because existing in game works awfully in towns ?
soldierOne disableAI "Move" command can disable ingame algorithm, but would you be able to make a better one instead ?
I had an idea to force units to advance from cover to cover : search nearest cover with nearestobject command, run to it , provide some coverfire for the comrades, find next cover , run to it etc...   It shouldn't be too luggy, but I wonder  how huge will be massive  objects-covers... Although I never
tried to  realize it...
When in "Stealth" mode bots are smart enough : they hide themselves behind bushes and terrain holes. The problem is that most of us do not play on the very high terrain settings -  sowe can't see  landscape hollows on the map.
Also note that we don't know much about ingame AI. For example, I know that bots won't  fire  at the target if correlation "bot's weapo hit"/"target armor" less then 10% , but I have no idea how AI selects target (and weapon)  from several ones.





HelmutS

  • Guest
Re:Giving the AI brains without input from the mission designer
« Reply #5 on: 04 Jul 2005, 17:49:14 »
Hhmm...nearestobject sounds interesting.

Perhabs if I want randomized defense unit positions I could just drop a bunch of them randomly on the map and have them seek nearest cover?

bdfy1

  • Guest
Re:Giving the AI brains without input from the mission designer
« Reply #6 on: 04 Jul 2005, 18:15:16 »
I guess you know that there is ingame command "Take cover" ? :)
Quote
I looked closer and all I found was the "Isaware" command
What's this ? Do you have comref special ? :)

Bluelikeu

  • Guest
Re:Giving the AI brains without input from the mission designer
« Reply #7 on: 04 Jul 2005, 19:13:44 »
I think he means "knowsAbout"
???

btw, the appearance of some sort of tactics by the A.I. during and assault is quite easy. A script that holds and array of group formations and is periodically updated can execute other scripts when certain conditions are met. I was in-fact working on this quite a while ago, HQ mod, the post is quite old but its somewhere in this section, you might get some ideas from the post. I trashed the project because it was too much of a time burden.


Thanks,
Bluelikeu
« Last Edit: 04 Jul 2005, 19:19:30 by Bluelikeu »

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:Giving the AI brains without input from the mission designer
« Reply #8 on: 04 Jul 2005, 23:04:34 »
As for nearestObject, General Barron has basically already done this with his AI take cover script. Unfortunately, he ran into a problem - running the getpos command on certain objects that nearestObject can pick up (a whole bunch of random stuff, including footprints, bullet marks and craters) causes an irreversible crash to desktop (well, irreversible until you rebooted OFP). I think the script eventually was halted because the problem was insurmountable (?).

HelmutS

  • Guest
Re:Giving the AI brains without input from the mission designer
« Reply #9 on: 05 Jul 2005, 10:10:59 »
Okay, so yes I meant "knowsabout".

This idea is, for lack of usefull scripting commands, obviously far more difficult than I thought. No direct LOS check, nearestobject doesn't work well, and writing to a text file is not supported.

I guess Fragorl you already tried checking LOS using bullets and "dowatch" command?


bdfy1

  • Guest
Re:Giving the AI brains without input from the mission designer
« Reply #10 on: 05 Jul 2005, 11:02:09 »
Fragorl, I've  just checked "take cover script"  - 1st method works nicely,  even when group is under fire etc. Idea to check object Zcoord is non-trivial :) I like it. The only thing to get fixed is units crowding near one cover.
3rd method crashes  game , but I don't know what  advantages 3rd method  could give me...

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:Giving the AI brains without input from the mission designer
« Reply #11 on: 06 Jul 2005, 00:09:58 »
Hm... the one version I tried crashed me out completely, but it sounds like I should have a look for another version... btw it seems the approach is very similar to the BIS one where you give the order 'take cover'- the units do almost the same thing

bdfy1

  • Guest
Re:Giving the AI brains without input from the mission designer
« Reply #12 on: 06 Jul 2005, 02:13:41 »
After ingame "take cover" command units often just make no headway... They stamp around, sometime covering themselves , sometimes not...
GB script is a lot better. If we can launch scripts instead using standart commands buttons...!
« Last Edit: 06 Jul 2005, 02:15:07 by bdfy1 »

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:Giving the AI brains without input from the mission designer
« Reply #13 on: 06 Jul 2005, 05:23:07 »
You can, but it requires a config edit to add actions, and then you can access then via the unit action menu, e.g. F1-6-2 (for the third action, if it happens to be that)

bdfy1

  • Guest
Re:Giving the AI brains without input from the mission designer
« Reply #14 on: 06 Jul 2005, 10:10:02 »
Fragorl, but how ? I wonder I have to edit resource.cpp  ?
But how to launch script from it ? For example this is the section for "Find cover"  command:
Quote
class SentCmdHide:NormalCommand
      {
      versions[]={"Version1"};

      class Version1
         {
         text="$STR_SENT_CMD_HIDE_1";
         Speech9[]={"%1.1","TakeCover"};
         Speech5[]={"%1.1","TakeCover"};
         };
      };
It's _very_ interesting...