Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function moveOrigin($nextID, $targetID, $history, $depth){
- echo "ID = $nextID <br>\n";
- $Systems = $GLOBALS["Systems"];
- //NextID is the key for the next steps to be made off of.
- $potentials = $Systems[$nextID]["JumpsTo"];
- echo "connects to: <br>\n";
- foreach($potentials as $display){
- echo $Systems[$display]['Name']." ($display) <br>\n";
- }
- if(!empty($potentials)){
- if(!in_array($targetID, $potentials)){ //Not at end location, therefore try next location
- $history[] = $nextID;
- $depth++;
- if($depth < 9){
- foreach($potentials as $value){
- if(!in_array($value, $history)){
- echo "Moving To: ". $Systems[$value]['Name'] ." with ID: ".$value."<br><br>\n";
- $path = moveOrigin($value, $targetID, $history, $depth);
- if(isset($path)){
- return $path;
- }
- }
- }
- }else{
- return;
- }
- }else{
- echo "TARGET LOCATION CAN BE REACHED FROM THIS LOCATION<br><br>\n";
- foreach($history as $path){
- $output .= $Systems[$path]["Name"]."<br>";
- }
- $output .= $Systems[$targetID]["Name"];
- echo "<br>Path:<br> $output <br><br>\n";
- return $output;
- }
- }
- }
- include("systems/systems2.php");
- $origin = 30000090; //Get starting point
- $target = 30000011; //Get end point
- echo "attempting to move from, ".$Systems[$origin]['name']." with ID: ".$origin.", to ".$Systems[$target]['Name']." with ID: ".$target."<br><br>\n";
- $path = moveOrigin($origin, $target, null, 0);
- echo $path;
- /*
- array_push($History, $target);
- $from = $Systems[]["Name"];
- $to = $Systems[$History[Count($History) - 1]]["Name"];
- //echo "From: $from, To: $to -><br>";
- foreach($History as $SystemID){
- echo "{$Systems[$SystemID]["Name"]} ({$Systems[$SystemID]["Sec"]})<br>";
- };
- */
- ?>
Advertisement
Add Comment
Please, Sign In to add comment