paulofmandown / rotLove

Roguelike Toolkit in Love. A Love2D/lua port of rot.js
http://paulofmandown.github.io/rotLove/
Other
258 stars 25 forks source link

Digger produces many dead-end corridors #41

Closed airstruck closed 7 years ago

airstruck commented 7 years ago

Compare the rotLove digger example to rot.js examples, which don't seem to produce any dead-ends.

Haven't looked into it closely yet, but it looks like maybe corridors are being dug to rooms that never get created because there isn't enough space.

airstruck commented 7 years ago

After reading up on the algorithm, I suspect priority walls aren't (always) getting created at the end of corridors as they should be. I found one bug in Corridor:createPriorityWalls:

if dx>0 then dx=dx/math.abs(dx) end
if dy>0 then dy=dy/math.abs(dy) end

Should be:

if dx~=0 then dx=dx/math.abs(dx) end
if dy~=0 then dy=dy/math.abs(dy) end

The original JS:

if (dx) { dx = dx/Math.abs(dx); }
if (dy) { dy = dy/Math.abs(dy); }

Unfortunately the dead-ends are still there after fixing that. I'm stumped for now.

airstruck commented 7 years ago

Found it, was one more instance like the one mentioned above. Fix in #42.