Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. bool TLabirynt::MissPathStep( bool& pCompleted, TElement* pCurrentElement, System::Windows::Forms::Form^ pFr, bool pVisualize )
  2. {
  3. labVectType candidates;
  4. labIterType it;
  5.  
  6. bool success = false;
  7.  
  8. //if ( pVisualize ) pFr->Refresh();
  9. if (pVisualize && !(pCurrentElement->Visited)) pFr->Refresh();
  10. //set visited flag for current element
  11. pCurrentElement->Visited = true;
  12.  
  13. //find neighbours - candidates to next step
  14. candidates = FindConnectionCandidates( pCurrentElement );//check the path i completted
  15.  
  16. //check completed
  17. if ( pCompleted = LabiryntMissPathComplete( pCurrentElement, candidates ) ) return true;
  18.  
  19. //suffle randomly candidates
  20. ShuffleCandidates( candidates );
  21.  
  22. //try next step for all candidates
  23. for ( it = candidates.begin(); it != candidates.end() && !success; it++ )
  24. {
  25. pCurrentElement->Connect( (*it) );
  26. success = MissPathStep( pCompleted, (*it), pFr, pVisualize );
  27. }
  28.  
  29. if ( success )
  30. {
  31. TmpMissElements.push_back( pCurrentElement );
  32. return true;
  33. }
  34. else //no step posibility in this recursion
  35. {
  36. return false;
  37. }
  38.  
  39. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement