summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--index.php3
-rw-r--r--pages/gallery.php101
-rw-r--r--pages/tutorial.php144
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'] = "<i>New</i> 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) <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);
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);
<script>
isChallenge = true;
+
+
+function challengeLoad() {}
+
+
+challenge1 = new Object();
+challenge2 = new Object();
+challenge3 = new Object();
+challenge4 = new Object();
+challenge5 = new Object();
+
+
+challenge1.start = "The objective in this game is to create the longest <i>path</i> between the start and the finish.<br>Below is a demonstration.<br>Press <b>Go!</b>";
+challenge1.complete = "Now that you see what is going on, let's move on to some puzzles.<br/>Press <b>Next</b>";
+
+challenge2.start = "Let's start off simple.<br>Start by pressing <b>Go!</b> first.";
+challenge2.wallstext = "Excellent; those wall placements look good!<br>Press <b>Go!</b> and see the path you\'ve made.";
+challenge2.complete = "Splendid!<br>Shall we move on to the next puzzle?<br/>Press <b>Next</b>";
+challenge2.help = "Click on the board to place two walls to make the path longer.<br>You can click on a placed wall to remove it.";
+
+challenge3.start = "The goal for this map is 64 moves<br>Press <b>Go!</b> first again.";
+challenge3.complete = "Impressive!<br/>Press <b>Next</b>";
+challenge3.help = "Note that the path can travel over the <i>Start</i> and <i>End</i> tiles.";
+
+challenge4.start = "Teleports are traps you can use to your advantage. See if you can use the teleport to reach 33 moves!<br>Press <b>Go!</b>";
+challenge4.complete = "Well done!<br>Teleports add extra intrigue to the game.";
+challenge4.help = "Let's use that teleport to block the way to the <i>A</i>!<br>We can make the path take longer to get to <i>A</i> in the process.";
+
+challenge5.start = "Now for a difficult one. The goal for this one is 75 moves.<br>Press <b>Go!</b> to check your path.";
+challenge5.complete = "Look at you, so pro.<br><a href='?page=home'>Go play the game!</a>";
+challenge5.help = "Try placing the walls as highlighted.";
+
function challengeGo(mapid) {
var moves = mapjson[mapid].moves;
switch (mapid) {
case '1':
- tv.unlock();
- updateDsp(1, 'instructions', "Now that you see what's going on, let's move on to some puzzles.");
+ tv.unlock(2);
+ updateDsp(1, 'instructions', challenge1.complete);
break;
case '2':
if (moves >= 18) {
- updateDsp(1, 'instructions', "Great, that's 18 moves!<br />Lets move on to the next shall we?");
- tv.unlock();
+ updateDsp(1, 'instructions', challenge2.complete);
+ tv.unlock(3);
} else {
- updateDsp(1, 'instructions', "The goal for this map is 18 moves.<br />Place 2 walls to make the path longer");
+ updateDsp(1, 'instructions', challenge2.help);
var tiles = ["2,3,5","2,4,6"];
markTiles(tiles);
}
@@ -34,32 +66,32 @@ function challengeGo(mapid) {
case '3':
if (moves >= 64) {
- updateDsp(1, 'instructions', '<p>I almost confused you! hehe.</p><p>Next?</p>');
- tv.unlock();
+ updateDsp(1, 'instructions', challenge3.complete);
+ tv.unlock(4);
} else {
- updateDsp(1, 'instructions', '<p>The path can travel over the start and end tiles too.</p><br>');
+ updateDsp(1, 'instructions', challenge3.help);
var tiles = ["3,3,6","3,4,7","3,3,2","3,2,1"];
markTiles(tiles);
}
break;
case '4':
- if (moves >= 45) {
- updateDsp(1, 'instructions', "Figure out how that teleport worked?<br />Play with it if you didn't");
- tv.unlock();
+ if (moves >= 33) {
+ updateDsp(1, 'instructions', challenge4.complete);
+ tv.unlock(5);
} else {
- updateDsp(1, 'instructions', "Let's use that teleport to block the way to the A!<br />We can also make it take longer to get to A in the process.");
- var tiles = ["4,1,5","4,2,6","4,3,7","4,5,9"];
+ updateDsp(1, 'instructions', challenge4.help);
+ var tiles = ["4,1,5","4,2,6","4,3,7","4,4,9"];
markTiles(tiles);
}
break;
case '5':
if (moves >= 75) {
- updateDsp(1, 'instructions', 'Look at you so pro.<br />Go play the game!');
+ updateDsp(1, 'instructions', challenge5.complete);
//Unlock next button.
} else {
- updateDsp(1, 'instructions', 'Now it gets more difficult.<br />');
+ updateDsp(1, 'instructions', challenge5.help);
var tiles = ["5,1,5","5,2,6","5,3,3","5,4,2","5,3,1"];
markTiles(tiles);
}
@@ -90,28 +122,17 @@ function challengeWall(mapid) {
return;
}
}
- updateDsp(1, 'instructions', 'Excellent; those wall placements look good!<br>Press "Go!" and see the path it takes')
-}
-
-function challengeLoad() {}
-
-function challenge() {
-//this.
+ updateDsp(1, 'instructions', challenge2.wallstext)
}
-
-//var ch = new challenge();
-
-
-
function highlightElement(Eid) {
}
function startChallenge(mapid) {
- console.log("start challenge", mapid);
+ //console.log("start challenge", mapid);
switch (mapid) {
case 1:
- updateDsp(1, 'instructions', '<p>The point of this game is to create the longest <i>path</i> between the start and the finish.</p><p>Press Go!</p>');
+ updateDsp(1, 'instructions', challenge1.start);
var goBtn = document.getElementById('1,btn');
var interval1 = setInterval(function() {
goBtn.className += ' flash';
@@ -131,16 +152,16 @@ function startChallenge(mapid) {
}
break;
case 2:
- updateDsp(1, 'instructions', "<p>Let's start off simple;</p><p>Start by pressing 'Go!' first.</p>");
+ updateDsp(1, 'instructions', challenge2.start);
break;
case 3:
- updateDsp(1, 'instructions', "The goal for this map is 64 moves<br />Press 'Go!'");
+ updateDsp(1, 'instructions', challenge3.start);
break;
case 4:
- updateDsp(1, 'instructions', "Teleports are traps. See if you can use the teleport to reach 45 moves!<br />Press 'Go!'");
+ updateDsp(1, 'instructions', challenge4.start);
break;
case 5:
- updateDsp(1, 'instructions', "Now for a difficult one. The goal for this one is 75 moves.<br />Press 'Go!' for help");
+ updateDsp(1, 'instructions', challenge5.start);
break;
}
}
@@ -149,6 +170,12 @@ function TutorialView(low, high) {
this.low = low;
this.high = high;
this.cur = low;
+ //Lock them all.
+ this.locked = low;
+
+ //Override hack to unlock all the levels.
+ //this.locked = high;
+
this.nextbtn = document.getElementById('nextbtn');
this.prevbtn = document.getElementById('prevbtn');
this.interval1 = this.interval2 = null;
@@ -161,7 +188,12 @@ TutorialView.prototype.showTutorial = function(num) {
}
var elem = document.getElementById("tut-" + num);
elem.className = elem.className.replace('hidden', '');
+ //Is the map after this disabled?
+ this.nextbtn.className = this.nextbtn.className.replace(' disabled', '');
+ if (this.locked <= this.cur)
+ this.nextbtn.className += ' disabled';
startChallenge(num);
+ tv.nextbtn.className = tv.nextbtn.className.replace(' flash', '');
}
TutorialView.prototype.next = function() {
clearInterval(this.interval1);
@@ -173,10 +205,10 @@ TutorialView.prototype.next = function() {
if (this.nextbtn.className.indexOf('hidden') < 0)
this.nextbtn.className += ' hidden';
} else {
- this.nextbtn.className = this.nextbtn.className.replace('hidden', '');
- this.nextbtn.className += ' disabled';
+ this.nextbtn.className = this.nextbtn.className.replace(' hidden', '');
+ //this.nextbtn.className += ' disabled';
}
- this.prevbtn.className = this.prevbtn.className.replace('hidden', '');
+ this.prevbtn.className = this.prevbtn.className.replace(' hidden', '');
}
TutorialView.prototype.prev = function() {
this.showTutorial(--this.cur);
@@ -184,19 +216,26 @@ TutorialView.prototype.prev = function() {
if (this.prevbtn.className.indexOf('hidden') < 0)
this.prevbtn.className += ' hidden';
} else
- this.prevbtn.className = this.prevbtn.className.replace('hidden', '');
- this.nextbtn.className = this.nextbtn.className.replace('hidden', '');
+ this.prevbtn.className = this.prevbtn.className.replace(' hidden', '');
+ this.nextbtn.className = this.nextbtn.className.replace(' hidden', '');
}
TutorialView.prototype.unlock = function(n) {
- this.nextbtn.className = this.nextbtn.className.replace('disabled', '');
- this.interval1 = setInterval(function() {
- tv.nextbtn.className += ' flash';
- }, 1200);
- setTimeout(function() {
- tv.interval2 = setInterval(function() {
- tv.nextbtn.className = tv.nextbtn.className.replace(' flash', '');
- }, 1200);
- }, 600);
+ if (n > this.locked) {
+ this.locked = n;
+ if (this.locked >= this.cur) {
+ this.nextbtn.className = this.nextbtn.className.replace(' disabled', '');
+ this.interval1 = setInterval(function() {
+ tv.nextbtn.className += ' flash';
+ }, 1200);
+ setTimeout(function() {
+ tv.interval2 = setInterval(function() {
+ tv.nextbtn.className = tv.nextbtn.className.replace(' flash', '');
+ }, 1200);
+ }, 600);
+ }
+ }
+
+
}
</script>
@@ -227,11 +266,7 @@ include('./includes/maps.php');
?>
<div id="tut-wrapper">
<div style='height:80px;' id='1,instructions'>
- <p>
- The point of this game is to create the longest <i>path</i> between the start and the finish.
- </p><p>
- Press Go!
- </p>
+ <p>The objective in this game is to create the longest <i>path</i> between the start and the finish.<br>Below is a demonstration.<br>Press <b>Go!</b></p>;
</div>
<?
@@ -265,12 +300,11 @@ $myparams['teleports'] = 0;
$myparams['walls'] = 4;
$map3 = GenerateShapedMap($challenge3, $myparams);
-$challenge4[] = "suooooatoof";
+$challenge4[] = "suooooaooof";
$challenge4[] = "sooooooooof";
$challenge4[] = "sooooooooof";
$challenge4[] = "sooooooorof";
-$challenge4[] = "sooooooooof";
-$challenge4[] = "sooooooooof";
+$challenge4[] = "soooooootof";
$myparams['checkpoints'] = 1;
$myparams['teleports'] = 1;
$myparams['walls'] = 4;