<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Ello's Maze Generator</title>
</head>
<body style="font-family:monospace;font-size:5px;line-height:3px;">
<?php
parse_str($_SERVER['QUERY_STRING']);
if ($w>230) $w=230;
if ($h>230) $h=230;
if ($w<1) $w = 16;
if ($h<1) $h = 16;
echo "<p style='font-family:monospace;font-size:8pt;line-height:10pt;'>w = width ($w)<br>h = height ($h)<br>nw = num walls ($nw)<br>min = min wall length ($min)<br>max = max wall length ($max)<br>g = granularity ($g)<br></p>";
function createMaze($maze_width,$maze_height,$numWalls, $minLength, $maxLength, $granularity)
{
$feld = array();
for($i=0;$i<$maze_height;$i++)
{
$t = array();
for($j=0;$j<$maze_width;$j++)
{
array_push($t,"0");
}
array_push($feld,$t);
}
while($numWalls>0)
{
$sx = $granularity * rand(0,($maze_width)/$granularity);
$sy = $granularity * rand(0,($maze_height)/$granularity);
$dir = (int)rand(0,3);
$length = $granularity * rand($minLength,$maxLength) + 1;
if ($feld[$sy][$sx]=="0")
{
while($length>0)
{
$feld[$sy][$sx]="1";
switch ($dir)
{
case 0:
$sx --;
if ($sx<0) $sx = 0;
break;
case 1:
$sy --;
if ($sy<0) $sy = 0;
break;
case 2:
$sx ++;
if ($sx>($maze_width)) $sx = $maze_width;
break;
case 3:
$sy ++;
if ($sy>($maze_height)) $sy = $maze_height;
break;
}
$length --;
if ($feld[$sy][$sx]=="1") $length = 0;
}
}
$numWalls --;
}
for($i=0;$i<$maze_height;$i++)
{
for($j=0;$j<$maze_width;$j++)
{
if ($feld[$i][$j]=="1") echo "<span style='background-color:#00F;width:5px;height:5px;'> </span>";
if ($feld[$i][$j]=="0") echo "<span style='background-color:#FFF;width:5px;height:5px;'> </span>";
}
echo "<br>";
}
}
createMaze($w,$h,$nw,$min,$max,$g);
echo "<br><br>";
$min = rand(1,8);
$max = $pm+rand(1,32);
$nw = rand(100,4000);
$h=rand(32,128);
$w=rand(32,128);
$g = rand(1,8)*2;
$param = "w=".$w."&h=".$h."&nw=".$nw."&min=".$min."&max=".$max."&g=".$g;
echo "<a style='font-family:monospace;font-size:8pt;line-height:10pt;' href='".$_SERVER['PHP_SELF']."?$param'>create new maze with: <strong>$param</strong></a>";
?>
</body>
</html>