From 2fcf71ee0f0feb98cdd1fb1a44b2711a567056fe Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Mon, 5 Dec 2011 00:52:15 -0800 Subject: Tutorial added in. More testing with a solver. --- index.php | 3 +- pages/gallery.php | 101 ++++++++++++++++++++++--------------- pages/tutorial.php | 144 +++++++++++++++++++++++++++++++++-------------------- 3 files changed, 151 insertions(+), 97 deletions(-) diff --git a/index.php b/index.php index 6005fe1..a14249f 100644 --- a/index.php +++ b/index.php @@ -10,7 +10,8 @@ if ($_SESSION['accepted'] <> 1) //Links appear in order. $Links['home'] = "Home"; $Links['leaderboard'] = "Scoreboard"; -$Links['howtoplay'] = "How to Play"; +//$Links['howtoplay'] = "How to Play"; +$Links['tutorial'] = "New Tutorial"; //$Links['gallery'] = "Gallery"; if ($_SESSION['isAdmin'] == true) { $Links['admin'] = 'Admin'; 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) Solution routed the path $routes times."; + echo "END;($wallcount) During $iterations iterations 'TryMaze' routed the path $routes times. Placing $wallcount walls"; break; } } while ($done == false); diff --git a/pages/tutorial.php b/pages/tutorial.php index 15a7c83..9b472ff 100644 --- a/pages/tutorial.php +++ b/pages/tutorial.php @@ -12,21 +12,53 @@ topbar($Links); @@ -227,11 +266,7 @@ include('./includes/maps.php'); ?>
-

- The point of this game is to create the longest path between the start and the finish. -

- Press Go! -

+

The objective in this game is to create the longest path between the start and the finish.
Below is a demonstration.
Press Go!

;