I'd say that code is missing a }
(although it is pseudo-code, so anything goes really)
do {
Length = rand() % Max;
}
while( Length < Min );
rand()
is a function is C++ which generates an integer between 0 and at least 32767 (although, for the purposes of this, I think we should assume that the maximum number than can be generated is greater than Max
).
% Max
gives the remaining of the number divided by Max
, so Length
will be between 0
and Max-1
(inclusive).
Then you repeat this until Length >= Min
, so, at the end, Length
will between Min
and Max-1
(inclusive).
We can completely avoid the loop with this code:
Length = Min + rand() % (Max - Min);
Or, since this is pseudo-code:
Length = random number in the range [Min, Max)
The rest of the code generates two paths at the same time from the source and destination, and then stops when linking them (using the shortest possible path) would result in a walk longer than Length
.