I have a basic shuffle routine. I put being, end statements in the outer loop 
for clarification.
It ended up producing random results.
Commenting out the begin, end combination allows the code to run as expected.
My code is below, can someone tell me if the begin, end combination should 
actually make a difference, or should they be more ornamental in function?
Thanks!

   {Let's Shuffle Col1  - routine from: 
https://www.theproblemsite.com/reference/science/technology/programming/randomizing-an-array
 }
   my_base := 0;
   for i:= 0 to 4 do  { Column we are currently working on }
    {  begin }
         for j:= 0 to 90 do { 20 swaps on the working column }
            begin
               index1 := RandomRange(my_base,my_base+14);   { a random # = 
length of the array }
               index2 := RandomRange(my_base,my_base+14);
               writeln('index1 ', index1,' ', 'index2 ', index2);
               while (index1 = index2) do
               begin
                  index2 := RandomRange(my_base,my_base+14); { avoid swaping on 
the same square }
                  writeln('index2 trap ',index2);
               end;
               my_temp := shuffle_array[i,index1];     { store position to get 
a random value }
               shuffle_array[i,index1] := shuffle_array[i,index2];
               shuffle_array[i,index2] := my_temp;
               writeln(shuffle_array[i,index1],'  ',shuffle_array[i,index2]);

               { ok... Index isn't a valid row.. }
            end;
            my_base := my_base + 15;
            writeln('current base ',my_base:2);
            ch := ReadKey;
    {  end;  { end i = column indexer }}
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to