XenPath | Infinite-Dimensional Pathfinding Algorithm



XenPath is a pathfinding module which employs the A* algorithm on nodes. It can be used with an infinite number of dimensions.




local XenPath = require(6939543410)

local node_0 = XenPath.Node({x, y, z, ...}) -- input node coordinates within a table

node_0.Coordinates -- table indicating the coordinates of the node

table.insert(node_0.Connections, node_1) -- makes a one way connection from node_0 to node_1

table.insert(node_1.Connections, node_0) -- allows back-tracking on the original connection

local Graph = XenPath.Graph({node_0, node_1}) -- Frame

local Path = Graph.findPath(Starting_Node, Target_Node) -- returns node sequence table or false if unreachable



Why I Made This Module

I wanted to learn metatables, so I thought this sort of project would be perfect for understanding them. With a good understanding of metatables, I plan to improve my modules and scripting. And I think that’s all there is to it.

Please report any bugs or suggestions


Nice resource. To clarify, does infinite dimensional path finding mean this can be used with portals? What’s the difference between this and normal 3D path finding?

1 Like

What I meant by infinite dimensional, is that it will function with as many coordinates you put in. So yes, in theory, if you found a successful way of interpreting inter-dimensional coordinates it would work.


Just to clarify, aren’t you just using A*?

1 Like


1 Like

how exactly do i use this for creating a pathfinding npc?
edit: just saw the gyazo vid. can u give us an example as to how we cn generate all the points since this rn is best for like mazes and stuff idk.

This module does not support point generation (at least for now). To use this with a maze, you would need to define the points before hand. For the NPC, you would use the closest node as the starting point. Then the pathfinding function will return a sequence of nodes, which have coordinates that you can use as points for the npc to walk to respectively.

In the example usage, I duplicated parts and moved them using a fixed increment. Then, I made a script which creates nodes from the parts’ positions and creates connections between 2 if their distances are below a certain threshold. (In this case I used the pythagoreon equation for the threshold)

1 Like

I see, can I suggest you make it slightly more OOP?

Something like:

local Pathfinder = XenPath.new()
Pathfinder:AddNode(<Vector3> NodePosition) --> Returns Node
Pathfinder:AddNode(<Array> PositionArray) --> Returns Nodes
Pathfinder:PathFind(<Node> StartNode, <Node> EndNode) --> Returns waypoints
1 Like

Sure, I’ll work on that.