irrAI 0.50 - AI module for Irrlicht [Updated 28/11/09]

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Post Reply
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

irrAI 0.50 - AI module for Irrlicht [Updated 28/11/09]

Post by JP »

Image

If you've been following christianclavet's First King project then you'll know that he's planning some big things for the irrlicht community in reusable modules. I decided to help him out with the AI for his project and what we want to do is to make an external module of AI functions that will be reusable in any irrlicht project.


Website & Downloads
irrAI Webpage
IrrAI Forum

IrrAI SDK 0.50: 12mb
- Download (for Irrlicht 1.4.2)
- Download (for Irrlicht 1.5)
- Download (for Irrlicht 1.6)



IrrAI Editor

Initially i was working on using IrrEdit as the editor to create and link together waypoints but i discovered fairly quickly that this wasn't a very viable option so i've now created my own editor which does the job a lot better.

Image

There's a file called config.xml in the Media folder which allows you to change the video driver and screen resolution for the editor.

Please do try it out and let me know your thoughts!


Custom Entity Example

This example shows how I've opened up the IAIEntity interface so that you can really easily make your own entities if the basic implementations provided are not suitable enough for your needs!

Basically there's a very simple Turret entity which has been implemented which when you get in its field of view it will start shooting at you (if you're in range). The example also shows how the new AI sensors can be used for things like checkpoints and powerups.

Apologies for the poor screenie... I'm being shot by 'plasma balls' :lol:

Image


Calm-a-geddon Example

This example shows how you might go about using the library for pretty much a GTA sort of AI, what you'll see when you run the example is this:

Image

There are 2 types of NPC; zombies and cars. They can be considered as opposing teams and they have their own set of waypoints which are not linked together (but do cross over each other). The cars drive around on the roads with the usual rules of driving on the left by using one-way waypoint links. The zombies walk around on the pavements and zebra crossings by using two-way waypoint links. For your convenience the waypoints and their links are also colour coded to easily show the seperate groups.

When an NPC (of either type) sees another NPC they will stop dead. The cars will wait for the zombies to finish crossing the road and then continue and the zombies will do the same for the cars. If a zombie sees another zombie then they will stop for 4 seconds before moving past the other zombie. Currently they generally end up moving through each other which is less than desirable but evasion will come at a later date. Now as far as i can tell the NPCs will never get into a stalemate where they never move again and everything comes to a halt so let me know if you see this. There is one case where this will happen and that's if two cars start the simulation facing each other. This will make them never move and will cause a massive traffic jam eventually causing everyone to stop moving. If this happens just restart the app and if this initial stalemate doesn't occur everything should be fine!


FPS Example

This example shows how you might go about using the library for an FPS sort of AI, what you'll see when you run the example is this:

Image

EXTRA STUFF: I've now extended this example so that you can take an active role and join either of the available teams, try it out ;)

There are 2 types of NPC. One chases and the other flees. The ones that chase, the guys in red, just randomly wander around until they sees the other enemy NPCs, the guys in blue. When they see the enemies they move towards them until they're in range to fire and then stop and start firing. The blue guys on the other hand don't have a weapon so would rather stay put and just scan the surrounding area, trying to make sure no one creeps up on them and when they see the red guys they just run away, crouched down, basically just to show you they're trying to get away. Unfortunately i haven't put any effort into the actual path they use to flee so they just plot a path to a random waypoint for now. When an NPC, in this example, is chasing/fleeing they have red exclamation marks above their head to show that they're, shall we say... 'aroused'... (stop that sniggering at the back!). That's about it for now, it's still very limited behaviour, but it's another step in the right direction!


Simple Example

This example simply shows you NPCs pathfinding. What you'll see when you run the example is this:

Image

There's only one type of NPC in this example, a 'patrolling' NPC who randomly wanders around between the waypoints.


RPG Example

This example shows how you might go about using the library for an RPG sort of AI, what you'll see when you run the example is this:

Image

There are 2 characters in the scene, one (Sydney) is controlled by you using the WASD keys and a 3RD person camera (very simplistic implementation as the focus of the example is not on this but on the AI) and the other (Faerie) is an NPC with which you can have a conversation. Go up to Faerie and press space, once the conversation is over follow her, simple as that. It doesn't really show off irrAI in any different way to the FPS example but it just shows how it can be used for different types of games and is just meant as a bit of fun (no disrespect to Niko at all ;))


Performance & The Code
As for the number of NPCs you can have running around at one time the current fps example can handle 30 quite easily, without dropping below 60fps (vsync on) and only really starts to struggle when you add up to 40 when the frame rate drops down to between 50 and 60fps.

This is still very early work, i can only have worked on it for a small number of hours i'm sure... So there's still lots to sort out and the source isn't perfectly seperated out into things that should be in the library and things that should be in the application. No doubt there will be many API breaking changes to come ;)

I've tried to comment the code as well as possible and it should explain how everything's done but if there's anything you're unsure of then give me a shout!


The future
Upcoming examples include examples of how to make unconventional AI things like automatic doors with the library and expansions to the chasing, fleeing and attacking behaviour. Nav mesh support is also hopefully something I can bring to IrrAI, this will greatly improve the pathfinding over the current waypoint graphs.
Last edited by JP on Sat Nov 28, 2009 8:37 pm, edited 43 times in total.
Image Image Image
TheGameMaker
Posts: 275
Joined: Fri May 12, 2006 6:37 pm
Location: Germany

Post by TheGameMaker »

great work! (I din't try it. sry) nut it sounds great & usefull
thx
fireside
Posts: 158
Joined: Thu Dec 01, 2005 10:55 pm

Post by fireside »

Looks interesting.
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Post by Nadro »

Good work:) This is very useful AddOn for Irrlicht Users.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Thanks guys, it's very early days and it will improve greatly and even though i don't have much time to work on it i hope that it won't take too long to get some really good stuff in there.

Some of things we hope to include are a field of vision for the NPCs so that they can't see through objects or outside a sensible field of vision like a human or a camera might have and also different levels of AI so that you can have smart and stupid NPCs.

Also the AI will be applicable to more simple things such as doors and ladders so that you can make doors open when you get near or go up and down ladders fairly automatically (still working on the best way to handle ladders actually). So basically instead of just being NPC AI we're hoping to make it applicable to anything with even the remotest link to 'AI' so anything that will respond or have some kind of motion that requires a response.

Even if we don't get everything in there hopefully it can still be of some use to people, even as it stands you could easily use it to add path finding to enemies or just to look at to get the ideas of how AI might work and to expand upon it.
Image Image Image
lostclimategames
Posts: 331
Joined: Sat Sep 02, 2006 4:11 am
Location: Michigan
Contact:

Post by lostclimategames »

how easy is the code to integrate, because obviously at certain points you want the ai to stop and do something else for a second, does it allow for that. I just ask because I am putting together a very basic fps minigame, and want easy pathfinding integration.
___________________________
For all of your 3D/2D resource needs:
Image
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Well obviously the plan is to have it very easy to integrate and as it's very early days if we get some good feedback then we should be able to make it that way.

At the moment there isn't really any source that you'd be able to try and integrate yet unfortunately but hopefully there will be some kind of early initial release not too long down the line.

If you have any ideas on how you'd like to have it integrated into your project, what sort of functions you might expect then it could give us ideas on how to proceed. Obviously we can't make it perfect for everyone to integrate in their own specific ways but we should be able to figure out a good way to make it pretty easy to use.
Image Image Image
Strong99
Admin
Posts: 687
Joined: Fri Mar 31, 2006 7:06 pm
Location: Netherlands
Contact:

Post by Strong99 »

the project sounds very interresting,
but the link seems dead :s
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

The link works fine for me but i've uploaded it to a few more places so see if any of those work.

I've also made an additional comment in the original post about making your own set of waypoints with irrEdit; all waypoints should be made children of a scene node (empty it probably best) called WaypointRoot.
Image Image Image
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

How's the progress? Anything new? How bout releasing the source code for it?
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post by christianclavet »

Matergod, patience is a virtue.. :wink:
JP will get something out soon enough... FOV is being worked now.
FlyingIsFun1217
Posts: 219
Joined: Fri Apr 13, 2007 8:29 pm
Location: Illinois
Contact:

Post by FlyingIsFun1217 »

I believe this, along with the shader addon I saw somewhere else, will make Irrlicht amazing!

FlyingIsFun1217
dejai
Posts: 522
Joined: Sat Apr 21, 2007 9:00 am

Post by dejai »

Great work Jp :D I can host it for you if you want :D Post me
Programming Blog: http://www.uberwolf.com
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Yeah, as Christian says, an update is coming, hopefully later today i'll have an updated demo with field of vision included.

Cheers for the offer of hosting, dejai, but i've applied for a sourceforge account for this project so that should be good enough for hosting i imagine!
Image Image Image
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Original post updated with a new demo and all the information you need!
Image Image Image
Post Reply