Here it is in text format....
PHP Code:
Type A_Sector
exits(1 To 6) As Integer
sector_number
End Type
Dim path(1 To 30) As Integer
Dim all_sectors(1 To 500) As A_Sector
Function adjacent_sector()
'Determines whether one sector is adjacent to another. Code not included.
End Function
Public Sub compute_shortest_path(Source As Integer, destination As Integer, step As Integer, max_depth As Integer, start As Boolean)
Dim z As Integer
While found_it = False
If adjacent_sector(Source, destination) = True Then
path(step + 1) = destination
found_it = True
Else
If step < max_depth Then
For i = 1 To Num_Exits
If Source <> 0 Then
If all_sectors(Source).exits(i) <> 0 Then
compute_shortest_path all_sectors(Source).exits(i), destination, step + 1, max_depth - 1, False
End If
End If
Next i
End If
End If
If start = True Then
max_depth = max_depth + 1
If max_depth > Max_Distance_Possible Then
x = MsgBox("There is currently no path to that destination sector!", vbOKOnly, "No path!")
Exit Sub
End If
Else
If found_it = True Then
path(step) = Source
End If
Exit Sub
End If
Wend
If found_it = True And start = True Then
path(step) = Source
End If
End Sub
Let me add some more to that..sorry..
PHP Code:
Type A_Sector
exits(1 To 6) As Integer
sector_number
End Type
Dim path(1 To 30) As Integer
Dim all_sectors(1 To 500) As A_Sector
Dim found_it as Boolean
Function adjacent_sector()
'Determines whether one sector is adjacent to another. Code not included.
End Function
'To call the Subroutine
compute_shortest_path x, y, 1, 1, True
Public Sub compute_shortest_path(Source As Integer, destination As Integer, step As Integer, max_depth As Integer, start As Boolean)
Dim z As Integer
While found_it = False
If adjacent_sector(Source, destination) = True Then
path(step + 1) = destination
found_it = True
Else
If step < max_depth Then
For i = 1 To Num_Exits
If Source <> 0 Then
If all_sectors(Source).exits(i) <> 0 Then
compute_shortest_path all_sectors(Source).exits(i), destination, step + 1, max_depth - 1, False
End If
End If
Next i
End If
End If
If start = True Then
max_depth = max_depth + 1
If max_depth > Max_Distance_Possible Then
x = MsgBox("There is currently no path to that destination sector!", vbOKOnly, "No path!")
Exit Sub
End If
Else
If found_it = True Then
path(step) = Source
End If
Exit Sub
End If
Wend
If found_it = True And start = True Then
path(step) = Source
End If
End Sub