Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("systems.php");
- $History = array();
- $Path = null;
- function moveOrigin($nextID, $targetID, $depth){
- global $Systems, $History, $Path, $Destination;
- //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
- array_push($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;
- }
- }
- }
- }
- $origin = 30000142; //Get starting point
- $target = 30000001; //Get end point
- moveOrigin($origin, $target, 0);
- array_push($History, $target);
- $from = $Systems[$History[0]]["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