From f8c9eb5220afaf2f9a62f9a176a45913240f4081 Mon Sep 17 00:00:00 2001 From: raylu Date: Thu, 7 Apr 2011 00:27:27 -0400 Subject: Initial import from Dropbox --- includes/pathing.php | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 includes/pathing.php (limited to 'includes/pathing.php') diff --git a/includes/pathing.php b/includes/pathing.php new file mode 100644 index 0000000..fc07f0b --- /dev/null +++ b/includes/pathing.php @@ -0,0 +1,108 @@ +"; + $nextTile = GetTileID($mapMatrix, $mapMatrix[0][0] - 1, $i); + $finish[($i-1)] = $nextTile; + } + + //Initialize $targets with Checkpoints and Finish. + switch($mapMatrix[0][2]) + { + case 3: array_push($targets, 'C'); + case 2: array_push($targets, 'B'); + case 1: array_push($targets, 'A'); + } + array_reverse($targets); + array_push($targets, 'Finish'); + + print_r($queue); + echo "
"; + + while(count($queue) > 0) + { + $nextSearch = array_shift($queue); + $idFinish = array_shift($targets); + } + + /* + echo "Pre-PrintArray.
"; + print_r($queue); + echo "Post-PrintArray.
"; + */ + + //Search($mapMatrix, $loc, $path); + + return $path; +} + +function Search($mapMatrix, $idStart, $idFinish, $path) +{ + +} + +function GetTileID($mapMatrix, $x, $y) +{ + //echo "Request for TileID of (".$x.",".$y."): "; + if($mapMatrix[0][0] >= $x && $mapMatrix[0][1] >= $y) + return $mapMatrix[0][0] * ($y-1) + $x; + else return -1; +} + +//WOULD be a function if not for overhead of calling a function and +// inconvenience of returning an array. Here to display formula. + +function GetTileCoordinates($mapMatrix, $tileID) +{ + $x = $tileID % $mapMatrix[0][0]; + $y = (int)($tileID / $mapMatrix[0][0]) + 1; + + echo "(".$x.",".$y.")"; + echo "
"; +} + +?> \ No newline at end of file -- cgit v1.2.3