/** * @class Maze generator - Eller's algorithm * See http://homepages.cwi.nl/~tromp/maze.html for explanation * @augments ROT.Map */ ROT.Map.EllerMaze = function(width, height) { ROT.Map.call(this, width, height); } ROT.Map.EllerMaze.extend(ROT.Map); ROT.Map.EllerMaze.prototype.create = function(callback) { var map = this._fillMap(1); var w = Math.ceil((this._width-2)/2); var rand = 9/24; var L = []; var R = []; for (var i=0;i rand) { this._addToList(i, L, R); map[x+1][y] = 0; } /* bottom connection */ if (i != L[i] && ROT.RNG.getUniform() > rand) { /* remove connection */ this._removeFromList(i, L, R); } else { /* create connection */ map[x][y+1] = 0; } } } /* last row */ for (var i=0;i rand)) { /* dig right also if the cell is separated, so it gets connected to the rest of maze */ this._addToList(i, L, R); map[x+1][y] = 0; } this._removeFromList(i, L, R); } for (var i=0;i