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
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

For fleeing it's not necessarily good to just run in the opposite direction as that provides the player with a direct line of sight with the NPC, i.e. they just shoot straight in front of them and hit the NPC.

Best thing to do is to try and run off to the side so it's a moving target so harder to shoot at.

I had trouble with my fleeing methods in my Uni project, basically because the best working implementation i managed to get done in the available time was to just pick a random waypoint in the environment, plot a path there and follow it. But sometimes that would make the NPC run into the player which is obviously not a good fleeing plan! :lol:
Image Image Image
Strong99
Admin
Posts: 687
Joined: Fri Mar 31, 2006 7:06 pm
Location: Netherlands
Contact:

Post by Strong99 »

what about giving the nodes an flee and cover value? so if the player is near NPC's. NPCs will use the best cover nodes (for example high cover value) to walk over and the same for fleeing, they use the best cover and fasted routes to other fleepoints.

than you can precalculate different paths and get the best value for that state/second instead only the lowest path node count
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post by christianclavet »

For fleeing it's not necessarily good to just run in the opposite direction as that provides the player with a direct line of sight with the NPC, i.e. they just shoot straight in front of them and hit the NPC.
Ok. Have another idea for this.

1. Check the opposite direction (180 or less degre angle) with ray intersection where the NPC would find cover (wall that will protect the NPC). With the same ray intersection test, find a suitable position for the NPC then this will be the DESTINATION waypoint. You could determine the directional vector from the position of the NPC and the attacking node.

2. While on the destination waypoint, check for the attacking node position and distance, if distance is too near (determine a value), re-plot the trajectory.

3. If the NPC reach the destination, check the attacking node position and distance again then repeat the same until the NPC evade the attacking node. (Sufficient distance from the attaking node and NPC)

4. If the distance from the attacking node from the NPC is far enough, find the nearest static waypoint to patrol and go there (checking again not to go thru the walls)
Ico
Posts: 289
Joined: Tue Aug 22, 2006 11:35 pm

Post by Ico »

I'd try to somehow invert A* (or whatever is used). So instead of walking the path with the highest score I'd pick the one with the lowest score (blocked LOS to the player lowers score in addition).
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Excellent news, i've just fixed the problem i had where NPCs would get stuck on waypoints so i should hopefully have some source out soon i should think!
Image Image Image
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Ok, well there were some concerns over performance when handling a fair number of NPCs in a scene. Christian mentioned wanting around 20 NPCs in a level at one time.

I just tried out adding 20 simple NPCs (checking their FOVs and plotting paths all over the place) into my test scene (of 8 waypoints) and the framerate didn't drop below 60 at any point with vsync on. Without vsync it was up at a steady 125, hopefully with some optimisations that can be boosted somewhat, but it's not a bad result i feel for now!

It's around 40 NPCs, on my system, that the framerate starts having problems, then it moves around between 50 and 60 fps (vsync on).

Now 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.

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 us a shout!

Anyway, onto the code. What i've done is made an FPS example project which shows how you might go about using the library for a FPS sort of AI (based on the previous demos i've shown). There are 2 NPCs which 'patrol' around randomly and can detect each other in their FOVs (they don't actually do anything except put a list up of what's visible to them in the GUI). If you think there's only one NPC wandering round then it's probably because they're on exactly the same path, having started from the same waypoint, eventually they'll split off!

Right, well.. no idea how to upload to my sourceforge project (if anyone can tell me how that'd be great!)

So here's the source release:
MediaMax (i'll try to mirror it elsewhere tomorrow)

Any problems or feedback then let me know!
Image Image Image
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

sourceforge upload:

ftp it up to: ftp://upload.sourceforge.net/incoming/

then go to admin->files i think to create a release version.
Image
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

That's so uber-lame... Wish they had a browser upload option! :lol:

I guess i'll have to get some ftp software installed then.. Any suggestions?

Incidentally i'll continue to improve the FPS example and i also have an RPG example in the works and am considering other types of examples too, any suggestions are welcome!
Last edited by JP on Wed Jan 16, 2008 9:02 am, edited 1 time in total.
Image Image Image
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

I'll check it out..

I've just updated the first post with the mirrored downloads for the source and some extra explanations etc.
Image Image Image
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post by christianclavet »

Thanks JP. I'm checking this.

I'll update with your logo in my documentation.
Ico
Posts: 289
Joined: Tue Aug 22, 2006 11:35 pm

Post by Ico »

JP wrote:That's so uber-lame... Wish they had a browser upload option! :lol:

I guess i'll have to get some ftp software installed then.. Any suggestions?
Just open the FTP url in windows explorer (you can add it as a network resource in your network neighborhood too). Either just include login and password in the url or login using right click menu once the folder is opened.
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

Thanks! Finally :D
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

I tried using windows explorer but it didn't work, not from my work PC anyway... I could get to the ftp folder but not sign in...
Image Image Image
Ico
Posts: 289
Joined: Tue Aug 22, 2006 11:35 pm

Post by Ico »

Try "ftp://username:password@ftpserver.com/p ... somewhere/". (Explorer needs outgoing network access to port 21 for this to work).

If it still doesn't work, try a public ftp server like "ftp://ftp.microsoft.com/". It should work - if it doesn't there is something blocking your traffic (software, firewall, etc.). If it works the problem might be the ftp server or the data you provided. ;)

----------

Just had a quick look on the header files:
Instead of setting the enemies for each node, would be nice having some simple faction system.

So instead of setting the enemies for each NPC (could be quite some work too :) ), create factions like "team red" and "team blue" or "team 1" and "team 2" or whatever and then add NPCs to them (constructor parameter, get/set method, etc. in NPC). Maybe in addition add one or to default factions "hostile to everyone" and "hostile to noone" to allow simple implementations for FFA etc. where you'd need one faction per NPC.

----------

Some additional thoughts:

Supporting up to 256 factions:
One char/byte member variable on each NPC and a 256x256 matrix in the AI manager holding the alignments/reputation where a 0 would be "kill on sight" and 255 would be "superbest ally". In addition there might be some way to override those defaults later on.

The AI manager could also use an array of 256 <NPC> lists to keep track of NPCs in various groups and allow faster selection.
Last edited by Ico on Wed Jan 16, 2008 5:35 pm, edited 1 time in total.
Post Reply