Advertisement
Guest User

Untitled

a guest
May 25th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. /*
  2.  
  3. author: [vik] mindbl4ster
  4.  
  5. description:
  6. get connections for each city
  7. parameter:
  8. 0: (optional)NUMBER - StartIndex
  9. 1: (optional)NUMBER - Amount of following indices
  10. 2: (optional)NUMBER - -1: Random distribution - else ending connection index
  11. return
  12. 0: ARRAY - [ [List of indices, including start], [List of positions ] ]
  13. notes
  14.  
  15. */
  16. private["_startIndex","_checkpoints","_endingIndex"];
  17.  
  18. _startIndex = [_this, 0, -1, [0] ] call bis_fnc_param;
  19. _checkpoints = [_this, 1, -1, [0] ] call bis_fnc_param;
  20. _endingIndex = [_this, 2, -1, [0] ] call bis_fnc_param; //---> gonna get pretty complicated :(
  21. _listOfIndicies = [];
  22. _listOfPositions = [];
  23. _sizeinfoMatrix = count MB_LocationInfoMatrix;
  24.  
  25. if(_startIndex == -1)then{ _startIndex = floor random _sizeinfoMatrix};
  26. if(_checkpoints == -1)then{ _checkpoints = ceil random _sizeinfoMatrix};
  27.  
  28. _listOfIndicies pushback _startIndex;
  29. _listOfPositions pushback ( (MB_LocationInfoMatrix select _startIndex) select 0);
  30.  
  31.  
  32. //----- create list with connections
  33. //--- read first connections
  34. _connections = (MB_locationInfoMatrix select _startIndex) select 1;
  35. _nextConnection = _connections call BIS_fnc_selectRandom;
  36.  
  37. for[{_i=0},{_i<_checkpoints},{_i=_i+1}]do{
  38.  
  39. _listOfIndicies pushback _nextConnection;
  40. _listOfPositions pushback ( (MB_LocationInfoMatrix select _nextConnection) select 0);
  41. _connections = (MB_locationInfoMatrix select _nextConnection) select 1;
  42. _lengthCon = count _connections;
  43. _valCon = [];
  44. //--- filter connections for place not visited yet
  45. for[{_j=0},{_j<_lengthCon},{_j=_j+1}]do{
  46. _valNum = _connections select _j;
  47. if( !(_valNum in _listOfIndicies))then{_valCon pushback _valNum;};
  48. };
  49.  
  50. if(count _valCon == 0)then{_valCon = _connections}; // allow movement backwards once
  51. _nextConnection = _valCon call BIS_fnc_selectRandom;
  52.  
  53. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement