(function(window, document, undefined) { 
    window.onload = init;
    function init() {
        //get the canvas
        var canvas = document.getElementById("mapcanvas");
        var c = canvas.getContext("2d");
        var cwidth = 960;
        var cheight = 540;
        document.getElementById("paintbtn").onclick = paint;
        
        function reset(){
            c.clearRect ( 0 , 0 , canvas.width, canvas.height );
            c.beginPath();
        }
        
        function createRoom(x, y, pw, ph){
            var randw = Math.floor((Math.random() * ((pw/2) - 1 + 1) + 1) );
            var randh = Math.floor((Math.random() * ((ph/2) - 1 + 1) + 1) );
            //alert(randw + ", " + randh);
            
            return [randw, randh];
        }
    
        function paint(){
            reset();
            
            var widthSelect = document.getElementById("width");
            var pathWidth = widthSelect.options[widthSelect.selectedIndex].value;
            
            var heightSelect = document.getElementById("height");
            var pathHeight = heightSelect.options[heightSelect.selectedIndex].value;
            var nodeMap = [];
            //alert(pathWidth + ", " + pathHeight);
            for(var i = 0; i< pathWidth; i++){
                for(var j = 0; j< pathHeight; j++){
                    var node = {
                        n:1, 
                        s:1, 
                        e:1,
                        w:1
                    };
                    nodeMap.push(node);
                    c.beginPath();
                    //c.lineWidth = 1;
                    c.fillStyle = "#000000";
                    c.fillRect(i*30+0.5, j*30+0.5, 30, 30);
                    c.stroke();
               }
           }
           
            
            for(var i = 0; i< Math.floor(pathWidth/2)+1; i++){
                for(var j = 0; j< Math.floor(pathHeight/2)+1; j++){
                    var randRoom = Math.floor((Math.random() * 9));
                    if(randRoom < 1){
                        roomDim = createRoom(i,j,pathWidth,pathHeight);
                        c.beginPath();
                        c.lineWidth = 3;
                        c.fillStyle = "#FFFFFF";
                        c.fillRect(i*30 + 0.5, j*30+ 0.5, roomDim[0]*30, roomDim[1]*30);
                        c.stroke();
                    }
                }
            }
        }
    }
})(window, document, undefined);

@@ -273,185 +273,2146 @@
     
-document.getElementById(%22paintbtn%22).onclick = paint;%0A        %0A        function reset()%7B%0A            c.clearRect ( 0 , 0 , canvas.width, canvas.height );%0A            c.beginPath(
+var moves = %7B%0A            u: %5B0,1%5D,%0A            d: %5B0,-1%5D,%0A            l: %5B-1,0%5D,%0A            r: %5B1,0%5D%0A        %7D;%0A        document.getElementById(%22paintbtn%22).onclick = paint;%0A        %0A        function shuffle(array) %7B%0A          var currentIndex = array.length, temporaryValue, randomIndex ;%0A        %0A          // While there remain elements to shuffle...%0A          while (0 !== currentIndex) %7B%0A        %0A            // Pick a remaining element...%0A            randomIndex = Math.floor(Math.random() * currentIndex);%0A            currentIndex -= 1;%0A        %0A            // And swap it with the current element.%0A            temporaryValue = array%5BcurrentIndex%5D;%0A            array%5BcurrentIndex%5D = array%5BrandomIndex%5D;%0A            array%5BrandomIndex%5D = temporaryValue;%0A          %7D%0A        %0A          return array;%0A        %7D%0A        %0A        function reset()%7B%0A            c.clearRect ( 0 , 0 , canvas.width, canvas.height );%0A            c.beginPath();%0A        %7D%0A        %0A        function walk(start, stop)%7B%0A            var distX = stop.x - start.x;%0A            var distY = stop.y - start.y;%0A            %0A            %0A            %0A            var walkSteps = %5B%5D;%0A            for(var i = 0; i%3C Math.abs(distX); i++)%7B%0A                if(distX %3C 0)%7B%0A                    walkSteps.push(moves.l);%0A                %7D else %7B%0A                    walkSteps.push(moves.r);%0A                %7D%0A            %7D%0A            for(var i = 0; i%3C Math.abs(distY); i++)%7B%0A                if(distY %3C 0)%7B%0A                    walkSteps.push(moves.u);%0A                %7D else %7B%0A                    walkSteps.push(moves.d);%0A                %7D%0A            %7D%0A            %0A            var randSteps = (Math.abs(distX) + Math.abs(distY));%0A            %0A            for(var i = 0; i%3C randSteps; i++)%7B%0A                var rand =Math.floor(Math.random() * (2 - 1 + 1)) + 1;%0A                if(rand %3C 1)%7B%0A                    walkSteps.push(moves.u);%0A                    walkSteps.push(moves.d);%0A                %7D else%7B%0A                    walkSteps.push(moves.l);%0A                    walkSteps.push(moves.r);%0A                %7D%0A            %7D%0A            %0A            return shuffle(walkSteps
 );%0A 

Update script.js