summaryrefslogtreecommitdiffstats
path: root/pages/gallery.php
diff options
context:
space:
mode:
authorPatrick Davison <snapwilliam@gmail.com>2011-12-05 00:52:15 -0800
committerPatrick Davison <snapwilliam@gmail.com>2011-12-05 00:52:15 -0800
commit2fcf71ee0f0feb98cdd1fb1a44b2711a567056fe (patch)
tree7189615499db5ff6180ee6b17c9b95c3962c3af7 /pages/gallery.php
parentf5d9568541feab221a366075517d99d5c17a57c6 (diff)
downloadpathery-2fcf71ee0f0feb98cdd1fb1a44b2711a567056fe.tar.xz
Tutorial added in. More testing with a solver.
Diffstat (limited to 'pages/gallery.php')
-rw-r--r--pages/gallery.php101
1 files changed, 60 insertions, 41 deletions
diff --git a/pages/gallery.php b/pages/gallery.php
index 8468365..8b6013d 100644
--- a/pages/gallery.php
+++ b/pages/gallery.php
@@ -111,13 +111,6 @@ $map = GenerateMap(
weight(4) //Teleports
);
-$a[0] = 't';
-$a[1] = 't';
-$a['1'] = 'hi';
-echo $a[1];
-
-
-
$myshape[] = "qqqqqfffffqqqqq";
$myshape[] = "qqqqq?????qqqqq";
$myshape[] = "qqooo??b??oooqq";
@@ -162,24 +155,46 @@ $basic3[] = "soooooooooof";
$basic3[] = "soooooooooof";
+$square[] = "sfoo";
+$square[] = "oooo";
+
+
$myparams['checkpoints'] = 1;
$myparams['teleports'] = 0;
$myparams['rockchance'] = 100;
-$myparams['walls'] = 3;
+$myparams['walls'] = 13;
$map = GenerateShapedMap($basic3, $myparams);
-$motd = MapOfTheDay(4);
+if( ini_get('safe_mode') ){
+ echo "RISM";
+} else {
+ echo "NRISM";
+}
+ini_set('display_errors',1);
+ //error_reporting(E_NOTICE);
+
+ //trigger_error("Cannot divide by zero", E_NOTICE);
+
+echo ini_get('max_execution_time');
+echo ":";
+
+
+$motd = MapOfTheDay(3);
$map = $motd['map'];
-if ($_GET['walls']) {
+
+
+
+
+if (isset($_GET['walls'])) {
$map[0][4] = ($_GET['walls'] * 1);
}
//Benchmark
$time_start = microtime(true);
-set_time_limit(1120);
+set_time_limit(70020);
$newmap = executeTryMaze($map);
echo DisplayMap($newmap, 2);
@@ -194,6 +209,8 @@ function getAffected($route) {
$start = explode(",", $route['start']);
$x=$start[0];
$y=$start[1];
+
+ $tog = false;
//Run through the path
$pathary = str_split($route['path']);
@@ -246,10 +263,9 @@ function executeTryMaze($mapMatrix, $intensity = 1) {
//$mapdata['walls'] = 12;
$mapdata['teleports'] = $mapMatrix[0][5];
-
- $routes = 0;
-
+
//PROCSES BEGIN
+ $routes = 0;
$wallcount = 0;
$iterations = 0;
$lastRefresh = 0;
@@ -274,19 +290,12 @@ function executeTryMaze($mapMatrix, $intensity = 1) {
continue;
}
-
//Set a wall and calculate the new path
$mapMatrix[$x][$y] = 'R';
$curpath = routePath($mapMatrix);
$routes++;
$trymoves = $curpath['moves'];
-
- //if ("$x,$y" == "3,17") {
- //echo "T($x,$y)\n:";
- //print_r($affected);
- //return;
- //}
- //path blocked?
+
if ($curpath['blocked'] == true) {
//Sometimes it's better to remove a different wall;
@@ -297,7 +306,7 @@ function executeTryMaze($mapMatrix, $intensity = 1) {
//determin wall values.
$walllist = wallvalues($mapMatrix, $arrayWalls);
- $routes++;
+ $routes = $routes + $wallcount;
//Put the best wall to remove on top; - A mono directional bubble sort would be better here.
$walllist["$x,$y"]--;
@@ -329,15 +338,15 @@ function executeTryMaze($mapMatrix, $intensity = 1) {
continue;
}
//The last choice, or first choice?
- //if ($trymoves >= $bestmoves) {
- //echo "[$x, $y: $trymoves]";
- if ($trymoves > $bestmoves OR ($trymoves >= $bestmoves AND $bestcount <= $count) ) {
- $bestcount = $count;
- $bestmoves = $trymoves;
- $bestx = $x;
- $besty = $y;
- $mapMatrix[$x][$y] = 'o';
- //break;
+ //Can't decide, let's do both.
+ if ($trymoves > $bestmoves OR ($trymoves >= $bestmoves AND $iterations % 4 >= 2)) {
+ if ($bestcount <= $count) {
+ $bestcount = $count;
+ $bestmoves = $trymoves;
+ $bestx = $x;
+ $besty = $y;
+ $mapMatrix[$x][$y] = 'o';
+ }
}
$mapMatrix[$x][$y] = 'o';
}
@@ -349,22 +358,32 @@ function executeTryMaze($mapMatrix, $intensity = 1) {
echo "B($bestx,$besty)\n:";
//Refresh walls (Remove obsolete walls)
- if ($iterations % 2 == 0 AND $wallcount > ($mapdata['walls'] * .6))
+ //Do a smidgens less than every other one.
+ if ( ($iterations % 2 == 1 AND $iterations % 20 <> 1)
+ AND ($wallcount > ($mapdata['walls'] * .6)) )
{
echo "RW";
+ echo "MU";
+ echo memory_get_usage(true);
+ echo "MGPU:";
+ //echo memory_get_peak_usage();
+ //echo memory_get_peak_usage();
+ echo "::";
$walllist = wallvalues($mapMatrix, $arrayWalls);
- $routes++;
+ $routes = $routes + $wallcount;
//Remove low valued wall;
$lowvaluewall = true;
$nullwalls = 0;
foreach ($walllist as $nwallposition => $wallvalue) {
- if ($wallvalue == 0 OR ($lowvaluewall == true AND $wallvalue == 1))
- {
+ if ($wallvalue == 0 OR ($lowvaluewall == true AND $wallvalue == 1)) {
$nloc = explode(",", $nwallposition);
$x=$nloc[0];
$y=$nloc[1];
- if ($x == $bestx AND $y == $besty)
+ if ($x == $bestx AND $y == $besty) {
+ //echo "LVW USED";
+ //$lowvaluewall = false;
continue;
+ }
$mapMatrix[$x][$y] = 'o';
unset($arrayWalls[$x][$y]);
$wallcount--;
@@ -388,14 +407,14 @@ function executeTryMaze($mapMatrix, $intensity = 1) {
$walllist = wallvalue($mapMatrix, "R");
$routes++;
foreach ($walllist as $nwallposition => $wallvalue) {
- if ($wallvalue <= 1) {
+ if ($wallvalue < 1) {
$nloc = explode(",", $nwallposition);
$i=$nloc[0];
$j=$nloc[1];
$mapMatrix[$i][$j] = 'o';
- unset($arrayWalls[$x][$y]);
+ unset($arrayWalls[$i][$j]);
$wallcount--;
- echo "RM($x, $y)";
+ echo "LRM($i, $j)";
}
}
echo "End Refresh walls to:[$wallcount]";
@@ -403,7 +422,7 @@ function executeTryMaze($mapMatrix, $intensity = 1) {
//If all walls are placed even after refresh, we're done
if ($wallcount >= $mapdata['walls']) {
- echo "END;($wallcount) <b>Solution routed the path $routes times.</b>";
+ echo "END;($wallcount) <b>During $iterations iterations 'TryMaze' routed the path $routes times. Placing $wallcount walls</b>";
break;
}
} while ($done == false);