ClarkeRubber

Hope This Works

Feb 10th, 2012
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.95 KB | None | 0 0
  1. <?php
  2. function moveOrigin($nextID, $targetID, $history, $depth){
  3.     //NextID is the key for the next steps to be made off of.
  4.     $potentials = $Systems[$nextID]["JumpsTo"];
  5.     if(!empty($potentials)){
  6.         if(!in_array($targetID, $potentials)){ //Not at end location, therefore try next location
  7.             $history[] = $nextID;
  8.             $depth++;
  9.             if($depth < 9){
  10.                 foreach($potentials as $value){
  11.                     if(!in_array($value, $history)){
  12.                         if(moveOrigin($value, $targetID, $history, $depth) == true){
  13.                             return true;
  14.                         }
  15.                     }
  16.                 }
  17.             }else{
  18.                 return;
  19.             }
  20.         }else{
  21.             foreach($history as $value){
  22.                 include("systems.php");
  23.                 $path .= "/".$Systems[array_search($value, $Systems)];
  24.                 return true;
  25.             }
  26.         }
  27.     }
  28. }
  29.  
  30. $origin = 0; //Get starting point
  31. $target = 0; //Get end point
  32. include("systems.php");
  33. $originID = array_search($origin, $Systems);
  34. $targetID = array_search($target, $Systems);
  35.  
  36. moveOrigin($originID, $targetID, null, 0);
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment