Advanced AI
by Curtis Murray · in Torque Game Engine · 09/27/2009 (1:54 am) · 25 replies
Hey all,
A friend of mine and myself have managed to create some simple AI Bots within our Torque Environment.
1) Grunt like Orc: Runs at you and when close enough, stops to fire at you until you are dead/he is dead.
2) Berserker like Orc: Runs and shoots at you at the same time until you are dead/he is dead.
3) Sniper like Orc: Stationary and when within a certain range, he will fire at you from long range until you are dead/he is dead.
Now I am having no problems with them and they all work fine, just I am now looking to make them a little more advanced. For example, when the Grunt or berserker run into a wall, they are not smart enough to go around it to get to you.
If anyone knows of any tutorials around the web that could help me with this, I would appreciate it.
Thanks a bundle!
P.S. Also looking for a tutorial on how to create spawn points for AI.
A friend of mine and myself have managed to create some simple AI Bots within our Torque Environment.
1) Grunt like Orc: Runs at you and when close enough, stops to fire at you until you are dead/he is dead.
2) Berserker like Orc: Runs and shoots at you at the same time until you are dead/he is dead.
3) Sniper like Orc: Stationary and when within a certain range, he will fire at you from long range until you are dead/he is dead.
Now I am having no problems with them and they all work fine, just I am now looking to make them a little more advanced. For example, when the Grunt or berserker run into a wall, they are not smart enough to go around it to get to you.
If anyone knows of any tutorials around the web that could help me with this, I would appreciate it.
Thanks a bundle!
P.S. Also looking for a tutorial on how to create spawn points for AI.
About the author
#2
If you don't want to set up an A* system, you may want to check out The Universal AI Starter Kit. It allows bots to avoid obstacles without the use nodes or a nav-mesh.
@Daniel Buckmaster
Personally I found that the AIManager didn't really do anything, so I always just used AIPlayer as the class.
09/27/2009 (5:46 am)
@Curtis MurrayIf you don't want to set up an A* system, you may want to check out The Universal AI Starter Kit. It allows bots to avoid obstacles without the use nodes or a nav-mesh.
@Daniel Buckmaster
Personally I found that the AIManager didn't really do anything, so I always just used AIPlayer as the class.
#3
Curtis stated:
From what I've read of how you're kit works they'd have limited success in bypassing any reasonably sized wall or any amount of complexity in level design.
@Curtis - The real solution is to implement a Pathfinding solution but unfortunately whilst it would be possible to write one in Torquescript I don't believe theres an existing resource for that probably for the simple reason that it would be quite slow. There are free resources on the site for pathfinding but they require modification to the C++ source code so you'd have to be licensed for Torque to use them
09/27/2009 (6:44 am)
@Twisted - Without a navMesh you're only going to be able to avoid walls not neccesarily plot a path around the wall to get to where you want to be and the bots will still get stuck all over the place in any crowded environment i.e. buildings, forests, etc. so suggesting a product that may not be the full solution isn't helpful in my book.Curtis stated:
Quote:they are not smart enough to go around it to get to you.
From what I've read of how you're kit works they'd have limited success in bypassing any reasonably sized wall or any amount of complexity in level design.
@Curtis - The real solution is to implement a Pathfinding solution but unfortunately whilst it would be possible to write one in Torquescript I don't believe theres an existing resource for that probably for the simple reason that it would be quite slow. There are free resources on the site for pathfinding but they require modification to the C++ source code so you'd have to be licensed for Torque to use them
#4
First off the quote-
Was directed at his own AI system, not mine. Curtis does not currently own The Universal AI Starter Kit, and was likely not even aware it existed (which is why I mentioned it).
Second, I doubt that you've seriously looked into how my pathfinding works because, without looking at the code itself, there's little information about it. My kit's pathfinding is much better than you give it credit for and some of your assumptions are wrong. Currently my AI can easily bypass any "reasonably sized" obstacles; and in an update in the near future, my kit will be receiving some major navigation improvements.
Because Curtis doesn't have access to the source code, my system is by far the best that he could use right now.
09/27/2009 (7:10 am)
@Andy RollinsFirst off the quote-
Quote:they are not smart enough to go around it to get to you
Was directed at his own AI system, not mine. Curtis does not currently own The Universal AI Starter Kit, and was likely not even aware it existed (which is why I mentioned it).
Second, I doubt that you've seriously looked into how my pathfinding works because, without looking at the code itself, there's little information about it. My kit's pathfinding is much better than you give it credit for and some of your assumptions are wrong. Currently my AI can easily bypass any "reasonably sized" obstacles; and in an update in the near future, my kit will be receiving some major navigation improvements.
Because Curtis doesn't have access to the source code, my system is by far the best that he could use right now.
#5
RE pathfinding - it's definitely the case that obstacles could be avoided without the need for actual pathfinding. This will get AIs short distances, but it doesn't allow them to have the foresight to make complicated paths through a level.
I didn't realise Curtis wasn't a licensee (first thing I need to check :P), or I wouldn't have reccommended A* (though a scripted solution might suffice, if you use a rough enough grid of waypoints that doesn't take too long to search).
09/27/2009 (9:51 am)
Quote:Personally I found that the AIManager didn't really do anything, so I always just used AIPlayer as the class.Oh, I agree. All it does in stock TGE is respawn Kork if he dies. But I didn't feel like implementing my own better system, so I just hacked the existing one in a way that meant minimal work for me (AIManager::think is already called in game.cs, so I only had to modify those two functions).
RE pathfinding - it's definitely the case that obstacles could be avoided without the need for actual pathfinding. This will get AIs short distances, but it doesn't allow them to have the foresight to make complicated paths through a level.
I didn't realise Curtis wasn't a licensee (first thing I need to check :P), or I wouldn't have reccommended A* (though a scripted solution might suffice, if you use a rough enough grid of waypoints that doesn't take too long to search).
#6
I completely agree that the only time a nav mesh is needed is for long distances. However...
I don't see any reasonable scenario in which the AI would need to travel such a distance, thus making a nav mesh system useless.
-If the bot is coming from a long distance away and it can see the player, then there are no obstacles in its way that it has to go around.
-If the bot is a long distance away from the player and there are obstacles blocking the line of sight, then the bot should be spawned or teleported closer to the player and has no need to actually travel over the distance.
-If the bot is a long distance away from the player and there are obstacles blocking the line of sight, why would the bot even detect the player in the first place? (That’s unrealistic.)
Bots shouldn’t even be rendered unless they are in vicinity of the player. There is no good reason why a bot should have to travel a long distance, navigating around obstacles to go after a player. Having bots active that far away from the player is a gross misuse of CPU resources. Using a node or mesh based system is usually only needed as a crutch for poor game design. Proper planning should negate any need for such a system.
09/27/2009 (10:52 am)
Quote:RE pathfinding - it's definitely the case that obstacles could be avoided without the need for actual pathfinding. This will get AIs short distances, but it doesn't allow them to have the foresight to make complicated paths through a level.
I completely agree that the only time a nav mesh is needed is for long distances. However...
I don't see any reasonable scenario in which the AI would need to travel such a distance, thus making a nav mesh system useless.
-If the bot is coming from a long distance away and it can see the player, then there are no obstacles in its way that it has to go around.
-If the bot is a long distance away from the player and there are obstacles blocking the line of sight, then the bot should be spawned or teleported closer to the player and has no need to actually travel over the distance.
-If the bot is a long distance away from the player and there are obstacles blocking the line of sight, why would the bot even detect the player in the first place? (That’s unrealistic.)
Bots shouldn’t even be rendered unless they are in vicinity of the player. There is no good reason why a bot should have to travel a long distance, navigating around obstacles to go after a player. Having bots active that far away from the player is a gross misuse of CPU resources. Using a node or mesh based system is usually only needed as a crutch for poor game design. Proper planning should negate any need for such a system.
#7
I don't want to get into a huge argument, but that's how I see it. ;)
09/27/2009 (11:18 am)
Quote:Bots shouldn’t even be rendered unless they are in vicinity of the player. There is no good reason why a bot should have to travel a long distance, navigating around obstacles to go after a player. Having bots active that far away from the player is a gross misuse of CPU resources. Using a node or mesh based system is usually only needed as a crutch for poor game design. Proper planning should negate any need for such a system.Bold statements there ;). However, I, for one, am working on an FPS that is not entirely player-centric. AI characters have their own objectives to complete that may not have anything to do with the player. And they need to be able to get across the map, whether or not the target destination is the player. Using a node or mesh based system is usually a solution to a game design that requires a simulation rather than illusion.
I don't want to get into a huge argument, but that's how I see it. ;)
Quote:I don't see any reasonable scenario in which the AI would need to travel such a distance, thus making a nav mesh system useless.If you were talking about AI for a certain type of game or application, then fine, but it seemed like you were arguing general principles, so I had to respond.
#8
09/27/2009 (11:22 am)
Quote:Using a node or mesh based system is usually only needed as a crutch for poor game design.Roflcopter
#9
09/27/2009 (11:25 am)
...or, what Steve said. ;)
#10
But what you're thinking of doing could be done as an illusion rather than a simulation. Assuming that the AI isn't visible to the player at all times, you could just wait a certain period of time then have the AI teleport to near their destination point. Having them actually moving and doing battle with other bots is completely a waste of resources if the player can't see it.
I probably was a bit too general with my earlier statements, but nav meshes still aren't as necessary as some people seem to think.
09/27/2009 (11:31 am)
Quote:AI characters have their own objectives to complete that may not have anything to do with the player. And they need to be able to get across the map, whether or not the target destination is the player. Using a node or mesh based system is usually a solution to a game design that requires a simulation rather than illusion.
But what you're thinking of doing could be done as an illusion rather than a simulation. Assuming that the AI isn't visible to the player at all times, you could just wait a certain period of time then have the AI teleport to near their destination point. Having them actually moving and doing battle with other bots is completely a waste of resources if the player can't see it.
I probably was a bit too general with my earlier statements, but nav meshes still aren't as necessary as some people seem to think.
#11
Great argument, you've really turned me around on this issue.
09/27/2009 (11:32 am)
@Steve YorkshireRifles AcasterQuote:Roflcopter
Great argument, you've really turned me around on this issue.
#12
This is obviously an clash of ideals. I strive to simulate, rather than emulate. Good simulation makes good illusion redundant, and while the former is certainly more difficult and expensive, it is far more satifsying (to me), and there are less cases like 'what if the player walka in on a place the NPCs should be?' For example, if you just teleported NPCs to their goal, but the player was waiting along the path, well...
09/27/2009 (11:53 am)
Quote:But what you're thinking of doing could be done as an illusion rather than a simulation.Yes. But I just don't think it makes sense to do it that way, nor is it a fun or interesting challenge for me as a designer. There's a certain point where you're simulating too much to be worth the fuss - for example, I'd have to write rules for what happens if enemy NPCs encounter each other while going about their tasks, and at that point I'm not creating an FPS, but a board game.
This is obviously an clash of ideals. I strive to simulate, rather than emulate. Good simulation makes good illusion redundant, and while the former is certainly more difficult and expensive, it is far more satifsying (to me), and there are less cases like 'what if the player walka in on a place the NPCs should be?' For example, if you just teleported NPCs to their goal, but the player was waiting along the path, well...
#13
I agree. For example, I'm attempting to make games for players/customers, where as you seem to doing it for fun or as a hobby. I am NOT saying one is better than the other, they're both great reasons for making games; but they do have different approaches. I want my games to be fun for the end user, whether I have fun making them or not (although most of the time I do like it).
That's where the specific game design comes in. And in this case you could have the bots actually running to their goal, but just do it using a simple way-point path instead of a full nav-mesh (which by the way, bots made with The Universal AI Starter Kit can use simple paths).
I'll admit that if you keep posing hypothetical scenario with severe limitations, you will eventually find one that requires a nav-mesh to be used. My point is that, for the majority games, in the vast majority of situations; a full nav-mesh isn't necessary, or your design could be very slightly modified to make it unnecessary.
09/27/2009 (12:15 pm)
@Daniel BuckmasterQuote:This is obviously an clash of ideals.
I agree. For example, I'm attempting to make games for players/customers, where as you seem to doing it for fun or as a hobby. I am NOT saying one is better than the other, they're both great reasons for making games; but they do have different approaches. I want my games to be fun for the end user, whether I have fun making them or not (although most of the time I do like it).
Quote:For example, if you just teleported NPCs to their goal, but the player was waiting along the path, well...
That's where the specific game design comes in. And in this case you could have the bots actually running to their goal, but just do it using a simple way-point path instead of a full nav-mesh (which by the way, bots made with The Universal AI Starter Kit can use simple paths).
I'll admit that if you keep posing hypothetical scenario with severe limitations, you will eventually find one that requires a nav-mesh to be used. My point is that, for the majority games, in the vast majority of situations; a full nav-mesh isn't necessary, or your design could be very slightly modified to make it unnecessary.
#14
And since I'm going to bed, I think we can take away that AI design can be drastically simplified from current industry standards if you don't want to simulate everything, and are happy with a little sleight of hand to provide an equivalent, handcrafted experience for the player.
09/27/2009 (12:53 pm)
Quote:For example, I'm attempting to make games for players/customers, where as you seem to doing it for fun or as a hobby. I am NOT saying one is better than the other, they're both great reasons for making games; but they do have different approaches.Yep. (And did I really say 'an clash of ideals'? :P) Well, of course I want them to be fun for the end user as well ;). But I certainly don't consider my design to be of mainstream interest - it takes a certain mindset to enjoy simulation over emulation.
Quote:I'll admit that if you keep posing hypothetical scenario with severe limitations, you will eventually find one that requires a nav-mesh to be used.I don't consider the scenario I posted to be hypothetical or limited at all. On the contrary, it would simply be a natural consequence of the player moving through the simulated world. Though I do understand what you're saying.
Quote:or your design could be very slightly modified to make it unnecessary.That does entirely depend on my design, but I take your meaning.
And since I'm going to bed, I think we can take away that AI design can be drastically simplified from current industry standards if you don't want to simulate everything, and are happy with a little sleight of hand to provide an equivalent, handcrafted experience for the player.
#15
Teleporting AI only works for friendly A.I. last thing you need is enemy AI teleporting in front of you.
I'm sorry but what a ridiculous comment to make, virtually every game I've come across uses a mesh/waypoint grid of some sorts for the AI to pathfind - now if the industry professionals are using it that should tell you something.
Oh sorry they must just all have poor game design!!! Roflcopter indeed Steve.
Again what rubbish, without some form of mesh the AI has no method of knowing where it can and can't go up front and must rely on LOS tests every move it makes... that's a huge overhead on the game compared with a mesh.
Also I still fail to see how you'd get an AI reliant on LOS tests and no mesh to work out how to get down stairs, inside buildings, etc.. and I don't mean when they have a player to follow because 90% of AI in games isn't following a player it's moving of it's own free will..
How does it find it's route down the stairs? or even know where they are?
Again without a mesh you'd have to do a LOS call every chance of direction so how do you smooth the paths so they don't run in angles? If you have to do a LOS test on every point in an ARC then that'll kill performance.
How about if you need AI to take cover or hide from the player? a mesh also has that information of which nodes would be out of sight
Or if an AI player needs to go and find health or a particular item (thinking RPG based here) - that item could be a huge distance away and require you to navigate around a hundred different objects.
Or what about driving games where the game AI must know where the track is and to stay on that track not drive off into the wilderness.
Or how about navigating around obstacles i.e. water or fire where a LOS would still see the player the other side and you wouldn't want to run through the fire or swim/sink in the water.
Or how about how to get through an area where the AI must crawl, crouch, swim, climb, smash, jump or a hundred different actions that a Mesh contains information about.
NavMesh info can be used to build up Influence Maps to focus more/less AI on certain areas or used to influence say sniper based AI to look for High positions.
Or squad based behaviours where you'd want to ambush, flank an opponent?
Or using cover to fire from behind? with a Mesh you know whether you can or can't get behind something without that info you'd have to move there to find out.
Sorry but you just seem to understand so very little about Meshs to make such a sweeping statement about their usage. I'm sure your AI works perfectly well in certain basic situations but it's limited in its usage without a Mesh/waypoint grid and all the extra functionality it brings.
09/27/2009 (6:34 pm)
Quote:-If the bot is coming from a long distance away and it can see the player, then there are no obstacles in its way that it has to go around.What about low fences? or if an AI player spots someone from the roof of a building and must get downstairs? plenty of scenarios where I want AI to navigate large distances.
Teleporting AI only works for friendly A.I. last thing you need is enemy AI teleporting in front of you.
Quote:Having bots active that far away from the player is a gross misuse of CPU resourcesAnd what if you're in a multiplayer situation where ALL AI must be active all the time.
Quote:Using a node or mesh based system is usually only needed as a crutch for poor game design
I'm sorry but what a ridiculous comment to make, virtually every game I've come across uses a mesh/waypoint grid of some sorts for the AI to pathfind - now if the industry professionals are using it that should tell you something.
Oh sorry they must just all have poor game design!!! Roflcopter indeed Steve.
Quote:I'll admit that if you keep posing hypothetical scenario with severe limitations, you will eventually find one that requires a nav-mesh to be used. My point is that, for the majority games, in the vast majority of situations; a full nav-mesh isn't necessary, or your design could be very slightly modified to make it unnecessary.
Again what rubbish, without some form of mesh the AI has no method of knowing where it can and can't go up front and must rely on LOS tests every move it makes... that's a huge overhead on the game compared with a mesh.
Also I still fail to see how you'd get an AI reliant on LOS tests and no mesh to work out how to get down stairs, inside buildings, etc.. and I don't mean when they have a player to follow because 90% of AI in games isn't following a player it's moving of it's own free will..
How does it find it's route down the stairs? or even know where they are?
Again without a mesh you'd have to do a LOS call every chance of direction so how do you smooth the paths so they don't run in angles? If you have to do a LOS test on every point in an ARC then that'll kill performance.
How about if you need AI to take cover or hide from the player? a mesh also has that information of which nodes would be out of sight
Or if an AI player needs to go and find health or a particular item (thinking RPG based here) - that item could be a huge distance away and require you to navigate around a hundred different objects.
Or what about driving games where the game AI must know where the track is and to stay on that track not drive off into the wilderness.
Or how about navigating around obstacles i.e. water or fire where a LOS would still see the player the other side and you wouldn't want to run through the fire or swim/sink in the water.
Or how about how to get through an area where the AI must crawl, crouch, swim, climb, smash, jump or a hundred different actions that a Mesh contains information about.
NavMesh info can be used to build up Influence Maps to focus more/less AI on certain areas or used to influence say sniper based AI to look for High positions.
Or squad based behaviours where you'd want to ambush, flank an opponent?
Or using cover to fire from behind? with a Mesh you know whether you can or can't get behind something without that info you'd have to move there to find out.
Sorry but you just seem to understand so very little about Meshs to make such a sweeping statement about their usage. I'm sure your AI works perfectly well in certain basic situations but it's limited in its usage without a Mesh/waypoint grid and all the extra functionality it brings.
#16
09/27/2009 (7:13 pm)
NavMesh Pathfinding, Locomotion and Dynamic Obstacle Avoidance ftw.
#17
*I may be completely off-base, but that's what it looks like to me.
Andy - while all those tasks should be accomplished using navmeshes, Twisted's point is that there's always a workaround that circumvents the need, and can be solved with obstacle avoidance rather than pathfinding. It's a completely different design paradigm, but I think it's valid.
Twisted - are you a member of aigamedev.com? I'd love to see a discussion over there about your ideas.
09/27/2009 (10:16 pm)
Multiplayer - I wish I'd thought of that ;P. That's definitely a situation, IMO, which requires active simulation. A single-player experience can be tightly controlled, but not so in multiplayer. Seems to be why so many competitive MP games don't feature bots - because their AI is geared towards illusion.**I may be completely off-base, but that's what it looks like to me.
Andy - while all those tasks should be accomplished using navmeshes, Twisted's point is that there's always a workaround that circumvents the need, and can be solved with obstacle avoidance rather than pathfinding. It's a completely different design paradigm, but I think it's valid.
Twisted - are you a member of aigamedev.com? I'd love to see a discussion over there about your ideas.
#18
09/27/2009 (10:16 pm)
Many different ways to do this it looks like. Thank you for the replys everyone, I'll try them out to see if I can get these ideas to work out.
#20
I've just been reading through the code for it over the weekend a total of 790 files and 150,000 lines of code no wonder it took them 5years to write the A.I.!!!! Although they did only have one guy - Paul Orkin working on it.
Twisted may try and confuse you with comments like "using a navMesh is just a substitute for poor design" but that's just not true or perhaps all those professionals in the industry your Call of Duty, Ghost Recons, etc, etc just have crap design and Twisted is just smarter than them all. If you're really interested in A.I. you should join www.aigamedev.com that Daniel listed.
Sorry to have hijacked your thread just trying to give a more rounded and accurate representation of things - given that you aren't licensed for Torque then Twisted's pack probably is one of your best options but don't expect it to navigate round complex worlds seamlessly. Personally I'd save my cash up to buy a Torque license so you can implement one of the free A* based resources on the site.
@Daniel - given Twisted's comments akin to "If you need navmeshes then you have poor design" I'm not sure if that is what he meant and even it is then you still can't achieve some of the things I listed even with some trickery.
There are actually many illusions used in almost all AI implementations using some form of LOD for AI can be fairly common in single player games and illusions with A.I. almost always relate to performance. A NavMesh gives you much much much better performance as the mesh is pre-computed and I already know where I can and can't go with doing that on the fly you add one hell of load on the game with Raycasts left right and center to test if you can move.
Also raycasts have many issues - if you cast them at eye level you may miss a wall at waist height, if you cast from the center of the box you may still bump and get stuck on the characters left or right arm (more of an issue for wider characters).. Sure you can get around some of that with multiple raycasts or some more advanced raycasting but those methods also drain a lot of performance.
Given that the performance hit for an A* star path find can quite easily be near to Zero (i.e. running the Path Manager in a seperate thread, Hierachical A*) then you could easily have 200-300 bots running about (I've tested it in TGEA and I hit rendering bottlenecks at around 100bots - need to create an AI model with say 20 polys).
Even if you could implement all those functions using Twisted's approach I don't see why you would take the route that puts a much bigger performance hit on the game and gives you a poorer solution.
09/28/2009 (6:25 am)
@Curtis - There are a thousand different ways to accomplish AI but in every commercial FPS game I've come across the pathfinding is always based on a Mesh/Grid and A* of some sorts - I'm sure someone can think of an exception to the rule but certainly all the major ones - Call of Duty, Ghost Recon, Fallout 3, Crysis, Left4Dead and F.E.A.R. The most impressive of them for me is the A.I. in F.E.A.R. which one awards for the A.I. in it.I've just been reading through the code for it over the weekend a total of 790 files and 150,000 lines of code no wonder it took them 5years to write the A.I.!!!! Although they did only have one guy - Paul Orkin working on it.
Twisted may try and confuse you with comments like "using a navMesh is just a substitute for poor design" but that's just not true or perhaps all those professionals in the industry your Call of Duty, Ghost Recons, etc, etc just have crap design and Twisted is just smarter than them all. If you're really interested in A.I. you should join www.aigamedev.com that Daniel listed.
Sorry to have hijacked your thread just trying to give a more rounded and accurate representation of things - given that you aren't licensed for Torque then Twisted's pack probably is one of your best options but don't expect it to navigate round complex worlds seamlessly. Personally I'd save my cash up to buy a Torque license so you can implement one of the free A* based resources on the site.
@Daniel - given Twisted's comments akin to "If you need navmeshes then you have poor design" I'm not sure if that is what he meant and even it is then you still can't achieve some of the things I listed even with some trickery.
There are actually many illusions used in almost all AI implementations using some form of LOD for AI can be fairly common in single player games and illusions with A.I. almost always relate to performance. A NavMesh gives you much much much better performance as the mesh is pre-computed and I already know where I can and can't go with doing that on the fly you add one hell of load on the game with Raycasts left right and center to test if you can move.
Also raycasts have many issues - if you cast them at eye level you may miss a wall at waist height, if you cast from the center of the box you may still bump and get stuck on the characters left or right arm (more of an issue for wider characters).. Sure you can get around some of that with multiple raycasts or some more advanced raycasting but those methods also drain a lot of performance.
Given that the performance hit for an A* star path find can quite easily be near to Zero (i.e. running the Path Manager in a seperate thread, Hierachical A*) then you could easily have 200-300 bots running about (I've tested it in TGEA and I hit rendering bottlenecks at around 100bots - need to create an AI model with say 20 polys).
Even if you could implement all those functions using Twisted's approach I don't see why you would take the route that puts a much bigger performance hit on the game and gives you a poorer solution.
Torque Owner Daniel Buckmaster
T3D Steering Committee
function AIManager::spawn(%this) { %groupName = "MissionGroup/AISpawnPoints"; %group = nameToID(%groupName); if (%group != -1) { %count = %group.getCount(); if (%count != 0) { for(%i = 0; %i < %count; %i++) { %spawn = %group.getObject(%i); %player = AIPlayer::spawn("Kork" @ %i,%spawn.getTransform()); if (isObject(%player)) { %player.mountImage(CrossbowImage,0); %player.setInventory(CrossbowAmmo,1000); } } } else error("No spawn points found in " @ %groupName); } else error("Missing spawn points group " @ %groupName); }This was kind of compied from the player spawn logic. What it does is search for a SimGroup called AISpawnPoints, and then spawns an AIPlayer at the location of each object in the group.You'd have to modify that a bit to get it to respawn individual AIs, but this will let you place them in, for example, initial locations in a linear mission.
About the rest of your question, if you want 'advanced AI' as in pathfinding (helping characters get around), do some searches for A* or A-star, a search algorithm. There are even some good resources for it here on GG.
This site is a really good explanation of the basics of A*, it helped me a lot.
If you meant 'advanced AI' as in better decision making, you could have a look at the AIGuard or Killer Kork resources. Also check out AIGameDev, there are some great resources in there if you dig for them (and get a basic account).