Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function moveOrigin($nextID, $targetID, $history, $depth){
- //NextID is the key for the next steps to be made off of.
- $potentials = $Systems[$nextID]["JumpsTo"];
- 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)){
- if(moveOrigin($value, $targetID, $history, $depth) == true){
- return true;
- }
- }
- }
- }else{
- return;
- }
- }else{
- foreach($history as $value){
- include("systems.php");
- $path .= "/".$Systems[array_search($value, $Systems)];
- return true;
- }
- }
- }
- }
- $origin = 0; //Get starting point
- $target = 0; //Get end point
- include("systems.php");
- $originID = array_search($origin, $Systems);
- $targetID = array_search($target, $Systems);
- moveOrigin($originID, $targetID, null, 0);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment