[EDIT: This originally-documented issue is not actually an issue, just a mistake on my part! Please scroll down to see the updated, real issue.]
Hi all! Back again with a pathfinder report. (I hope I'm not the only one using this library
)
I've noticed that with the new2DGrid initializer (which is very convenient by the way), diagonal connections are not added automatically, even if the diagonal boolean is passed in as true.
The expected behavior is that if I pass in allowDiagonals as true, then connections between diagonal nodes would be made automatically.
A small example of this behavior:
--- Pathfinder graph in the form of:
--- [ 1 0 ]
--- [ 0 1 ]
local graph = playdate.pathfinder.graph.new2DGrid(2, 2, true, { 1, 0, 0, 1 })
for _, node in pairs(graph:allNodes()) do
if #node:connectedNodes() > 1 then
print("Node has connections: " .. node.x .. " " .. node.y)
else
print("Node has no connections: " .. node.x .. " " .. node.y)
end
end
You'd expect from the above example to have nodes (1, 1) and (2, 2) to be connected to each other.
However, the output is the following:
Node has no connections: 1.0 1.0
Node has no connections: 2.0 1.0
Node has no connections: 1.0 2.0
Node has no connections: 2.0 2.0
Hopefully this helps and is actually a bug. I'll have to build a work-around in the meantime but I know that doing this in the C-library will be a lot more efficient ![]()

