";
$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 "
";
}
?>