Gamestudio Links
Zorro Links
Newest Posts
How to buy tomorrow at open?
by frutza. 06/01/23 19:58
Adding Position to Current Trade
by AndrewAMD. 05/30/23 10:34
Unable to change multiplier of contract
by vicknick. 05/30/23 06:56
Wrong Definition of Sharpe Ratio in Zorro?
by vicknick. 05/29/23 06:32
Backtest strategy on bitcoin/crypto
by JamesHH. 05/26/23 04:36
Return type of floor()
by AndrewAMD. 05/25/23 14:17
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
1 registered members (AndrewAMD), 1,065 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
BInnacle, androsa, XquicksnowX, danishinvest, Trail
18942 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Virtual maze - can anyone help? #216502
07/17/08 11:05
07/17/08 11:05
Joined: Jul 2008
Posts: 1
E
ekf Offline OP
Guest
ekf  Offline OP
Guest
E

Joined: Jul 2008
Posts: 1
I'd like to make a virtual environment of a brick wall maze. This will be very simple, with just the brick wall corridors, with about 20 turns or junctions and 12 objects as landmarks. This is for an experiment to see how well children can remember a route through the maze. I am not a programmer, and have no idea how to go about this. Does anyone have the code for a basic maze which they are willing to share?
Thanks

Re: Virtual maze - can anyone help? [Re: ekf] #216508
07/17/08 11:20
07/17/08 11:20
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline
Senior Expert
ello  Offline
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
did you try the forumsearch? mercuryus and me did some aproaches to this...

this is my php-version. i did a lite-c version, too, but dont have it here.

i implemented it into a game: botMaze

Code:
<!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;'>&nbsp;</span>";
			if ($feld[$i][$j]=="0") echo "<span style='background-color:#FFF;width:5px;height:5px;'>&nbsp;</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."&amp;h=".$h."&amp;nw=".$nw."&amp;min=".$min."&amp;max=".$max."&amp;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>


check it live


www.earthcontrol.de
quoted: We want to maintain a clean, decent, American family suited forum look... which means you may post zombies or chainsaw massacres, but no erotic.

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1