From 3a1b90cbb7034e285a9e216a4866972dad3288be Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Sat, 18 Aug 2012 18:56:39 -0700 Subject: Gallery Update to test dual path. --- pages/gallery.php | 352 +++++++++++++++++++++++++----------------------------- 1 file changed, 161 insertions(+), 191 deletions(-) diff --git a/pages/gallery.php b/pages/gallery.php index 8b6013d..e4e5d17 100644 --- a/pages/gallery.php +++ b/pages/gallery.php @@ -1,170 +1,146 @@ $bestmoves OR ($trymoves >= $bestmoves AND $iterations % 4 >= 2)) { - if ($bestcount <= $count) { - $bestcount = $count; - $bestmoves = $trymoves; - $bestx = $x; - $besty = $y; - $mapMatrix[$x][$y] = 'o'; - } + //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; } $mapMatrix[$x][$y] = 'o'; } @@ -358,32 +338,22 @@ function executeTryMaze($mapMatrix, $intensity = 1) { echo "B($bestx,$besty)\n:"; //Refresh walls (Remove obsolete walls) - //Do a smidgens less than every other one. - if ( ($iterations % 2 == 1 AND $iterations % 20 <> 1) - AND ($wallcount > ($mapdata['walls'] * .6)) ) + if ($iterations % 2 == 0 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 + $wallcount; + $routes++; //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) { - //echo "LVW USED"; - //$lowvaluewall = false; + if ($x == $bestx AND $y == $besty) continue; - } $mapMatrix[$x][$y] = 'o'; unset($arrayWalls[$x][$y]); $wallcount--; @@ -407,14 +377,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[$i][$j]); + unset($arrayWalls[$x][$y]); $wallcount--; - echo "LRM($i, $j)"; + echo "RM($x, $y)"; } } echo "End Refresh walls to:[$wallcount]"; @@ -422,7 +392,7 @@ function executeTryMaze($mapMatrix, $intensity = 1) { //If all walls are placed even after refresh, we're done if ($wallcount >= $mapdata['walls']) { - echo "END;($wallcount) During $iterations iterations 'TryMaze' routed the path $routes times. Placing $wallcount walls"; + echo "END;($wallcount) Solution routed the path $routes times."; break; } } while ($done == false); -- cgit v1.2.3