I’d like to share a small AI/pathfinding system I built using Panda3D. The AI can follow a player by dynamically computing paths over a 3D graph loaded from a custom .pfs file.
Features
-pathfinding algorithm on a navigation graph
-a .pfs exporter add-on for blender 4.x
-.pfs file parser for 3D points and connections inspired by the egg syntax
-AI that tracks a moving player
-AI that wander
The .pfs syntax
<<this is a comment>> <<the pdf will present the PathFinding's Storage (the extension is
.pfs>>
<< It should be used with Panda3D and its 3d direction >>
<Area> [name] { << the tag <Area> contain points and connections, this is very useful for add
pathfinding for seperate ennemy who can't exit their own area and avoid to create multiple
file .pds>>
<Group_of_Points> { <<in the tag <Group_of_Points> there are points>>
<Point> id { <<it is very important the id, the id is writte like this <Point> 1 {} >>
<x> {0} << x direction >>
<y> {0} << y direction >>
<z> {0} << z direction >>
<Tag> [name] << not compulsory, but useful for taking enemies to a special place
by telling them to go to a special point using their tag >>
}
}
<Connections> { << he contain the connections between points >>
<Relate> { << create a connection >>
<Crossroad> {point's_id} <<we add a central connection >>
<Peripheral> {another_point's_id} <<we can add more peripheral connections >>
}
}
}
<< concreate exemple >>
<Area> [level1] {
<Group_of_Points> {
<Point> 1 {
<x> {0}
<y> {0}
<z> {0}
}
<Point> 2 {
<x> {1}
<y> {0}
<z> {0}
<Tag> [front_off_the_green_table]
}
<Point> 3 {
<x> {0}
<y> {1}
<z> {0}
}
<Point> 4 {
<x> {-1}
<y> {0}
<z> {0}
}
<Point> 5 {
<x> {0}
<y> {-1}
<z> {0}
}
}
<Connections> {
<Relate> {
<Crossroad> {1}
<Peripheral> {2}
<Peripheral> {3}
<Peripheral> {4}
<Peripheral> {5}
}
}
}
Repository
the project is in developement, you can contribute if you want.
I’m pleased to announce that I’ve managed to create a stable enough version for you to test the Ml features
Requirement:
-pytorch
-numpy
-nothing else (i think)
Warning:
There are no documentation for the moment.
This is a test version and I’m still working on other models, so don’t expect a perfected ai.
I may remove this feature.
Please let me know if you encounter any problems.
Do you think it would be possible to create a ml that predicts the trajectory of its target with training and real-time prediction?
Because I think it would be handy to have an enemy that ambushes its target.
(I’m presuming from the talk of ambushes that you’re referring to predicting which route the player will take in an environment that allows multiple routes–e.g. whether they pick corridor A, or corridor B. If that’s not what you mean, then see the parenthetical at the end.)
It seems plausible–but would the AI, in the course of a normal game, gain enough data on the player to inform such a prediction…?
I feel like ambushes might be more easily implemented by placing triggers in the environment that inform the AI of the player’s choice of routes, allowing the AI to then flank via other routes.
(Unless you mean “trajectory” as in “predicting how the player will move within a room”. That doesn’t seem to me like it would allow for ambushes overmuch, but would be useful for targeting.
Here… machine-learning might be useful, but I’m not sure that some form of mathematical approach might not be better. I really don’t know, however.)
"(Unless you mean “trajectory” as in “predicting how the player will move within a room”. That doesn’t seem to me like it would allow for ambushes overmuch, but would be useful for targeting.
Here… machine-learning might be useful, but I’m not sure that some form of mathematical approach might not be better. I really don’t know, however.)"
Hmm.. Thinking about it some more, if a game were long enough, I suppose that one might be able to extract some broad patterns in the player’s movement, and so take guesses as to how they’ll approach future rooms. This might allow for some ambushes.
I’m not convinced that most games will be long enough for the algorithm to really learn much, however, especially as rooms may differ in various ways, complicating the data.
Plus, hand-placed ambushes can still be effective, and be so right from the start–before a machine-learning algorithm has had a chance to learn about a new player.
(You could perhaps have a big player-testing project to train the algorithm before the game ships–but that seems like a lot of effort, to my mind.)
So, my instinct is that hand-designed ambushes are likely to be more efficient to implement and more effective overall.
However, I do think that it might be worth experimenting with–it’s possible that I’m wrong!