MyBigFriend,
генератор комнат ... осталось соединить коридорами )))
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
$(function () {
function randomNumber(d) {
d = parseInt(d);
var e = Math.floor(0.2 * d),
a = Math.floor(0.8 * d),
a = Math.floor(Math.random() * (a - e + 1)) + e;
return [a, d - a]
}
function append() {
$("div:empty")
.each(function (d, e) {
var a = $(e),
b = a.height(),
c = a.width();
b > c || Math.random() > .7? (b = randomNumber(b - 4), c = [c - 2, c - 2]) : (b = [b - 2, b - 2], c = randomNumber(c - 4));
$("<div/>", {
css: {
height: b[0],
width: c[0]
}
})
.appendTo(a);
$("<div/>", {
css: {
height: b[1],
width: c[1]
}
})
.appendTo(a)
})
}
function end() {
$("div:empty")
.each(function (d, e) {
var a = $(e),
b = a.height(),
c = a.width(),
b = randomNumber(b),
c = randomNumber(c),
f = randomNumber(b[1]),
g = randomNumber(c[1]);
$("<div/>", {
css: {
margin: f[0] + "px " + g[0] + "px " + f[1] + "px " + g[0] + "px",
height: b[0],
width: c[0],
background: "#228B22"
}
})
.appendTo(a)
})
};
function run()
{
append();
append();
append();
append();
end();
}
$(":button").click(function () { $('.first').empty();run() }).click()
})
</script>
<style>
div{border:1px solid black;text-align:center;padding:0px;font-size:14px;color:#000; margin: 0px; float: left; }
.first{width:400px; height: 400px;}
</style>
</head>
<body>
<div class="first"></div>
<input name="" type="button" value="more">
</body>
</html>