hedgewars/uRandom.pas
changeset 7577 bdbb072b38b9
parent 7575 f415b3e0f3b9
child 7579 51724c98a74f
equal deleted inserted replaced
7575:f415b3e0f3b9 7577:bdbb072b38b9
    63 end;
    63 end;
    64 
    64 
    65 procedure SetRandomSeed(Seed: shortstring);
    65 procedure SetRandomSeed(Seed: shortstring);
    66 var i: Longword;
    66 var i: Longword;
    67 begin
    67 begin
    68 initModule;
    68 n:= 54;
    69 
    69 
    70 if Length(Seed) > 54 then
    70 if Length(Seed) > 54 then
    71     Seed:= copy(Seed, 1, 54); // not 55 to ensure we have odd numbers in cirbuf
    71     Seed:= copy(Seed, 1, 54); // not 55 to ensure we have odd numbers in cirbuf
    72 
    72 
    73 for i:= 0 to Pred(Length(Seed)) do
    73 for i:= 0 to Pred(Length(Seed)) do
    97 begin
    97 begin
    98 num.isNegative:= odd(GetNext);
    98 num.isNegative:= odd(GetNext);
    99 rndSign:= num
    99 rndSign:= num
   100 end;
   100 end;
   101 
   101 
   102 procedure initModule;
       
   103 begin
       
   104     n:= 54;
       
   105     FillChar(cirbuf, 64*sizeof(Longword), 0);
       
   106 end;
       
   107 
       
   108 procedure freeModule;
       
   109 begin
       
   110 
       
   111 end;
       
   112 
       
   113 end.
   102 end.