AI Libraries for Panda3D

So, I have created a simple pursue test and put it up at:

srinavinnair.com/downloads/P … ueTest.zip

Please note:

Import of PandAi in this test is given as

from libpandaai import *

but has to be modified based on your version of OS and Panda3d. So for example in 1.7.0, it will be :

from panda3d.ai import *

If this works then it is definitely a bug in your game code, which will be harder to figure out unless you isolate the problem.

As for your other question, yes you can pursue a node path and it doesn’t have to be linked to the AI. I have done this too in the sample I put up.

Hope this helps!

Yes it does, thank you very much. The sample works. Say, the character that is steered by Panda AI … can that be a nodepath (loader.loadModel) too? Because it is in my game, its not an Actor with animations 'n stuff.

EDIT: Ok, I just quickly tested that. Actor vs. model makes no difference.

I noticed that all samples add the task AIUpdate only when the first character enter the sim. I let the task run from the beginning, and when a pursuer spawns he’s added to pandaai. Is that relevant?

I noticed that the mass attribute is not explained or I overlooked it.

What about collisions? The shot I create has a collision sphere. All the shots in the game immediately after creation register a collision with the ship they spawned from. Those are then checked if they come from the ship that fired it and in that case nothing happens. Works for all shots in the game, but maybe not here?

EDIT2: Wait a seond, I think I got it.

This one crashes:

def addToAiEnv(self, model, sourceid):
		aiChar = AICharacter("test", model, 100.0, 0.25, 10.0)
		self.AIWorld.addAiChar(aiChar)
		aiBehaviors = aiChar.getAiBehaviors()
		sourcesTargetID = self.ShipObjects[sourceid].selectedTargetID
		aiBehaviors.pursue(self.ShipObjects[sourcesTargetID].ShipModel, 1.0)

But if I add a self. before aiChar, it works:

def addToAiEnv(self, model, sourceid):
		self.aiChar = AICharacter("test", model, 100.0, 0.25, 10.0)
		self.AIWorld.addAiChar(self.aiChar)
		aiBehaviors = self.aiChar.getAiBehaviors()
		sourcesTargetID = self.ShipObjects[sourceid].selectedTargetID
		aiBehaviors.pursue(self.ShipObjects[sourcesTargetID].ShipModel, 1.0)

Somebody please explain that one to me?!

EDIT3:
When a nodepath is added to the PandaAI sim, the node gets a random heading,
could that be?
When I use aiBehaviors.removeAi(“myname”) Terminal says: invalid option! This should work … I am using the same name that printList gives me.
How can I adjust how far a pursuer closes in on the target?
How do I adjust movement and turn speed? Yeah I know with those values mentioned above, but how exactly?

EDIT4:
Great, now the PandaAI lib crashes when I add a second character to the sim, i.e. fire a second guided missile. Those objects have unique names, so that can’t be it.

Okay thats a lot of questions, so let me try and answer them one by one :

  1. PandaAI only cares about node paths. Actors or Models make no difference.

It doesn’t matter when you create the AI character or set the behaviors. To test this out, in the sample I provided you,

cut this:

self.AIchar = AICharacter(“ralph”,self.ralph, 100, 0.05, 5)
self.AIworld.addAiChar(self.AIchar)
self.AIbehaviors = self.AIchar.getAiBehaviors()

and paste it in the setMove function before pursue. It should work fine.

I am taking a guess here that this has to do with variables being local and so when the scope goes out, the object is destroyed.

Definitely not. You can again test this in the sample provided by commenting out the pursue and doing step 2.

Can you tell me which was the exact string you used and also note that if the AI has already been removed it will bug out. Could you test this out in the sample by using removeAI to remove the pursue and see if that works.

If I understand what you mean, there isn’t a way to do that inbuilt in PandAI but you could use an empty node path and place it a displacement away from your object and make it pursue that.

PandAI uses simple physics to move a body. So,

v = u + at where a = F/m

But more practically, in the case of pursue,

3rd param - Increasing the mass slows it down
4th param - Increasing the movement force, increases the acceleration
5th param - This is the cap on the maximum speed.

Unfortunately, we didnt get enough time to set a turn speed parameter. Though I think it might be possible by using an empty node path.

Please check your code for mistakes in naming of the character, behavior etc… I have tested this out many times and it doesn’t bug out on any of the tests.

If you are still not convinced, please test this out in the sample, by adding a new ralph character in the setMove function so that it is dynamically done.

Hope these replies solve some of your problems.

Cheers.

Well, then what’s the implications for my game? Maybe I should explain what I am doing … In my space game I use PandaAI for guided missiles. A ship fires them, the rocket knows which ship in the system to pursue through it’s ID. Close enough to the target the collision kicks in. That means that a ship can fire multiple guided missles at a time and multiple ships can fire multiple guided missiles.

Now maybe using PandaAI on this is overkill, but I don’t want to implement my own system, where I store rockets in a dict, along with a timer system and a task that removes rockets when their timer runs out. Along with all that dot product stuff to figure out where a rocket has to turn and a position task to position the rockets.

Well I guess those are connected? My rockets need a turn parameter. Without it, the rocket spawns and immediately snaps in a heading to look at the target. The goal is that the rocket spawns like a car from a garage and then smoothly turns in onto the target.

Yes I could. I used “guided3drocket” as a char name, later I tried something unique: str(id(nodepath)), i.e. “4356981942”. Crashed on both.
Terminal says invalid option! on the remove and printList after that shows the entry is still there. Why is the removeAI option used on the AIBehaviors instead of the AIWorld? Weird. The PandaAI page does not state that by the way, that was trial and error.

But in case of the unique names that shouldnt matter. So I bet is has something to do with the self./scope problem described above. How can it crash on instancing classes? That’s the way I spawn ships for example and it works of course.

Here’s a crash report on a crash upon firing a second rocket using the unique id method: pastebin.com/JX6irqRG

No. You already got a distance check somewhere, so make it adjustable please.

Well the sample with multiple Ralphs works here too, so no convincing needed.

Thanks for your help.

removeAI should take a parameter such as ‘pursue’, ‘seek’, ‘all’ etc. not the instance name.

It should be called like this:

aiBehaviorInstance.removeAI(“pursue”)

As for using PandAI for your missiles…well thats exactly what it was meant for…yet i feel since it was a first release it may not be as cuztomizable as your needs and so you will need to use hackier methods to get it to work the way you want. If I have some spare time, I will write a way to do that using empty nodepaths and post it up.

Sorry bout that.

Hmm I will try and make a simple shooter too for multiple guided missiles and hopefully you will be able to understand whats wrong from that soon.

Cheers.

I don’t get it. The download page says:

What’s removeAI to be used on? Not the World but Behaviors? Then lets say I add my missile to the world through:

  aiWorld = AIWorld(render)
  aiChar = AICharacter("unique_id", NodePath, mass, mov_force, max_force)
  aiWorld.addAiChar(aiChar)
  aiBehaviors = aiChar.getAiBehaviors()  
  aiBehaviors.pursue(NodePath, 1.0)

Then the missile impacts, I remove the node that the AI is associated with … then I want to remove the AI, since 2000 inactive AIs after some space battle sounds like something you should clean up. Then using removeAI(“pursue”) removes the behavior from the char, but not the char itself? How would I do that? removeAiChar()?

removeAI() is to be used only to remove a particular AI behavior from the AI character and not the character itself.

Like you mentioned, use removeAiChar(). This will remove that character from the AIWorld. Now all you need to do is clean up the nodepath.

Incredible job to the PandaI team!

I’ve a question about AOE in pandai. I’ve implemented roaming ralph with pandai.

It looks like ralph runs off the roaming ralph map. I was wondering if you could help me out?

I’m using the following inputs to my wander call:

wander(2, 0, 3, 0.5)

2 = seek radius
0 = XY axis
3 = AOE
0.5 = priority

any help would be appreciated!

cheers,
ct

Hello!
I think the linked version of PandAI navmesh gen tool for blender is that one setted with z-x and not x-y. The last one is linked on forum and solved my problems. Could someone change the link with the last updated version if I am effectively right? (I’m not completely sure about it)

let me know!
and thank you for your work! is very appreciated! :smiley:

Hey guys,

Sorry about the delay in reply but for some reason I wasn’t receiving updates from the forum post.

Either ways,

@SniZzo92

Thanks.

Please refer to the download at:

srinavinnair.com/downloads/
*Note: use: from panda3d.ai import *

for now.

The reason why we haven’t been able to update our original site is because it is affiliated with Carnegie Mellon and being graduates we have lost access and freedom to edit it.

In response to this, I am in the process of creating a much more detailed and easier version of the PandAI site so that there will be one common place to check for documentation, downloads, updates, tutorials and examples. I will post back when it is done.

@ct

Thanks.

AOE refers to Area of Effect and if i remember correctly should refer to the range/radius around which the character should wander.

Are you using wander in combination to the pathfinding in the roaming ralph tutorial ?

Try these values and let me know if it works :

wander(5,0, 30, 1.0)

Note: seek radius is a parameter of how wander is implemented. Experimenting with these values should give you a desired effect I hope.

Cheers.

Hey, very cool! Thanks!

David

Since it is part of panda now… wouldn’t it be best to put some of the documentation in the manual?

Yes that is the final goal of this process. I would like to have everything here in the site ready and approved by a couple of people. Once it is fully updated it should be a trivial copy and paste into the manual.

For a glimpse at the current status of the new website here it is :

sites.google.com/site/etcpandai/

Any suggestions ?

@David

Thanks.

A couple of thoughts on the current state of PandaAI and it’s documentation…

(1) It would be helpful if we could set plane-limiting flags on all of the AI behaviors, not just “wander.” For example, I was working with a flock of virtual chickens to make them pursue or evade the camera… When pursuing, they gently float off the ground plane and tilt upwards in pitch to orient toward the camera. Likewise, when evading, the direction “away” from the camera includes a downward pitch angle, causing the chickens to go subterranean. Oops. The only way I could find to fix this was to manually reset their Z and pitch every frame.

Perhaps this could be a flag on the AI character, and not on the particular behavior. E.g., regardless of whether it’s seeking, flocking, wandering, path-finding, or evading… only adjust X,Y, and Heading.

(2) The documentation on “priority” and “weights” is confusing. Has the weight system changed since the original AI system was implemented? The documentation refers people to set an “int priority” attribute for each AI behavior and that this “int” should be a float between 0.0 and 1.0 (oops). The bigger problem is that a “priority” argument doesn’t actually exist for any of the AI methods. The AI behaviors instead use argument like “flock_wt”, “wander_weight”, and “evade_wt”. Calling “.flock( priority=0.9 )” will throw an error.

(3) The documentation on flocking similarly suggests weights for separation / cohesion / alignment in the range of 1 - 5 (e.g., separation=2, cohesion=4, alignment=5). In my testing, any value greater than 1.0 for these weights caused the character to go haywire, as if the forces were fighting each other. Values smaller than 1.0 basically negated the effectiveness of flocking. Is there a bug here?

@Hodge1620

Thanks for the comments.

(1) You are right. This was a feature we put in at the last minute since we were running out of development time. But say in a future release it would be a definite improvement.

(2) Priority is just a term we used to explain the concept. We used it interchangeably with weight. But thanks for pointing out the ‘float’. I have fixed it in the new documentation.

(3) Flocking was another feature which we didn’t get too much time on refining. In the new documentation, I have attached a new example which has a group flocking but there is some haywire turning movement in the beginning. I will check up with the developer who did this part of the code and see if he has an idea.

The new documentation is much more refined and has a lot of examples and sample code for each behavior so I hope this will solve a lot of the errors/confusions people seem to be having.

Thanks again for the support!

I am proud to announce that the new documentation for PandAI is done !

sites.google.com/site/etcpandai/

I worked hard on making all the information as accessible as possible with links to videos and code for each behavior and path finding. It also contains a getting started page which I feel was much required.

Since, this thread is cluttered with a lot of old and even outdated information, I will start a new thread so that any comments related to this and PandAI from now on can be placed there.

Thanks again for all the support. Even though PandAI is but a basic AI library I hope that it has helped some developers to get AI in their games. If not maybe even helped them understand on how to write a basic AI library/any of the behaviors/path finding.

Where can I contact you to ask few questions?

Hey shimrod,

Well I think the best way to solve any queries about PandAI would be to post them here :

[AI for Panda3D: PandAI v1.0!)

We frequently check this and reply to user posts there.

If this doesn’t work out as much, send me another post and I will send you my email.

Cheers

Hi there,

I have got a problem with generating the *.cvs file for
PandaAI. I generated the mesh within Maya and followed the steps given in the video tutorials (panda3d.org/manual/index.php/Mesh_Generation) for the Mesh generation. Also I didn’t forgot to triangulate both egg files before using them with the MeshGen. It always crashes as soon as I enter the command line for generating the cvs file.

I hope you guys can help me. I need this cvs-file pretty soon for a class that I am visiting.

Thanks Merlin

PS: Already tried it on two different PC’s with Windows 7 Professional (x64 bit).

PPS: Here are some pictures of the egg files that I am working with: