Improve randomization function (from 1 to 2) I am trying to do a randomize function.  It randomly selects one person (from two) to insert something into the console.  The second person goes next, and then they keep alternating until the loop ends.

  randomize();
  RandomTurn := random(2)+1;  
  while (1) do
  begin
      if RandomTurn = 1 then 
        PersonTurn((NumberOfMoves mod 2)+1)
      else 
        PersonTurn(round(2/((NumberOfMoves mod 2)+1)));

      NumberOfMoves := NumberOfMoves + 1;
  end;


What do you think? How could this function be improved based on number of moves/user inputs?
Randomness

This answer suggests that Random(2) would be okay for most uses. If you want more randomness, you could for example use an implementation of Mersenne Twister. This page lists a few options for Pascal/Delphi, for example this implementation.

Alternating values

Now that I know what you are looking for, I would write the code like this:

// If Value is divisible by 2 then return 1, otherwise return 2
procedure AlternateValue(Value) : ShortInt;
begin
    if Value mod 2 = 0 then Result := 1 else Result := 2
end;

// Your code
randomize();
RandomTurn := random(2)+1;
NumberOfMoves := RandomTurn

while (1) do
begin
    PersonTurn(AlternateValue(NumberOfMoves))
    NumberOfMoves := NumberOfMoves + 1;
end;


You should swap the two lines in the while loop if you want to start with the same number as Random gives. From what I gather, it should not matter much, however.

(I have never written any Pascal or Delphi before, so the code and/or syntax may not be perfect or correct.)