<?php
function gen() {
// top left room
$width1 = rand(1, WIDTH
* 3 / 4); $height1 = rand(1, HEIGHT
* 3 / 4); for ($y = 1; $y < $height1; ++$y)
for ($x = 1; $x < $width1; ++$x)
$dungeon[$y * WIDTH + $x] = ' ';
// top right room
$width2 = rand(1, WIDTH
* 3 / 4); $height2 = rand(1, HEIGHT
* 3 / 4); for ($y = 1; $y < $height2; ++$y)
for ($x = 1; $x < $width2; ++$x)
$dungeon[$y * WIDTH + WIDTH - 1 - $x] = ' ';
// bottom left room
$width = rand(WIDTH
- $width2, WIDTH
* 3 / 4); $height = rand(HEIGHT
- $height2, HEIGHT
* 3 / 4); for ($y = 1; $y < $height; ++$y)
for ($x = 1; $x < $width; ++$x)
$dungeon[(HEIGHT - 1 - $y) * WIDTH + $x] = ' ';
// bottom right room
$width = rand(WIDTH
- $width1, WIDTH
* 3 / 4); $height = rand(HEIGHT
- $height1, HEIGHT
* 3 / 4); for ($y = 1; $y < $height; ++$y)
for ($x = 1; $x < $width; ++$x)
$dungeon[(HEIGHT - 1 - $y) * WIDTH + WIDTH - 1 - $x] = ' ';
for ($i = 0; $i < HEIGHT; ++$i) {
echo substr($dungeon, $i * WIDTH
, WIDTH
) . "\n"; }
}
header('Content-type: text/plain'); for ($i = 0; $i < 10; ++$i) {
gen();
echo "\n";
}
PD9waHAKCmRlZmluZSgnV0lEVEgnLCAxMCk7CmRlZmluZSgnSEVJR0hUJywgMTApOwoKZnVuY3Rpb24gZ2VuKCkgewoJJGR1bmdlb24gPSBzdHJfcmVwZWF0KCcjJywgV0lEVEggKiBIRUlHSFQpOwoKCS8vIHRvcCBsZWZ0IHJvb20KCSR3aWR0aDEgPSByYW5kKDEsIFdJRFRIICogMyAvIDQpOwoJJGhlaWdodDEgPSByYW5kKDEsIEhFSUdIVCAqIDMgLyA0KTsKCWZvciAoJHkgPSAxOyAkeSA8ICRoZWlnaHQxOyArKyR5KQoJCWZvciAoJHggPSAxOyAkeCA8ICR3aWR0aDE7ICsrJHgpCg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