ondras / rot.js

ROguelike Toolkit in JavaScript. Cool dungeon-related stuff, interactive manual, documentation, tests!
https://ondras.github.io/rot.js/hp/
BSD 3-Clause "New" or "Revised" License
2.33k stars 254 forks source link

ROT.Map.Cellular.prototype._getNeighbors #97

Closed cmal closed 8 years ago

cmal commented 8 years ago

I've been debugging my code and traced that the dijkstra.compute never go into my callback functions, then I found this._computed never include the key fromX+","+fromY, then I found the _getNeighbors function didn't return the fromX+","+fromY key. I go into the _getNeighbors function, and found the following code , if (x < 0 || x >= this._width || x < 0 || y >= this._width) { continue; }, did you mean y < 0 after the second ||? I've not finished my debugging, I don't think this is the problem. Because in the interactive manual the fromX+","+fromY does show in the path finding computation. I'm still working with the problem, and hope further helps from you. Thank you for your excellent work!

cmal commented 8 years ago

I've found the problem: the passableCallback(fromX, fromY) should return true.

ondras commented 8 years ago

did you mean y < 0 after the second ||?

Yeah, this is definitely a bug! Thanks for spotting it.

I've found the problem: the passableCallback(fromX, fromY) should return true.

Can you please be more specific? Where and what should I fix? :)

cmal commented 8 years ago

No. It is my fault. I'm using rot.js the first time. Because I didn't know the passableCallback(fromX, fromY) should return true (or the start and end should be passable to compute the path), so dijkstra.compute did not work correctly. Thanks for the excellet rot.js.

ondras commented 8 years ago

I see. I will fix the duplicate x<0 issue soon. Stay tuned :)

ondras commented 8 years ago

Fixed, thanks :)