hedgewars/uRandom.pas
changeset 6580 6155187bf599
parent 5123 b0b57f247e02
child 6700 e04da46ee43c
equal deleted inserted replaced
6579:fc52f7c22c9b 6580:6155187bf599
    58 procedure SetRandomSeed(Seed: shortstring);
    58 procedure SetRandomSeed(Seed: shortstring);
    59 var i: Longword;
    59 var i: Longword;
    60 begin
    60 begin
    61 n:= 54;
    61 n:= 54;
    62 
    62 
    63 if Length(Seed) > 54 then Seed:= copy(Seed, 1, 54); // not 55 to ensure we have odd numbers in cirbuf
    63 if Length(Seed) > 54 then
       
    64     Seed:= copy(Seed, 1, 54); // not 55 to ensure we have odd numbers in cirbuf
    64 
    65 
    65 for i:= 0 to Pred(Length(Seed)) do
    66 for i:= 0 to Pred(Length(Seed)) do
    66     cirbuf[i]:= byte(Seed[i + 1]);
    67     cirbuf[i]:= byte(Seed[i + 1]);
    67 
    68 
    68 for i:= Length(Seed) to 54 do
    69 for i:= Length(Seed) to 54 do
    69     cirbuf[i]:= $A98765 + 68; // odd number
    70     cirbuf[i]:= $A98765 + 68; // odd number
    70 
    71 
    71 for i:= 0 to 1023 do GetNext
    72 for i:= 0 to 1023 do
       
    73     GetNext
    72 end;
    74 end;
    73 
    75 
    74 function GetRandom: hwFloat;
    76 function GetRandom: hwFloat;
    75 begin
    77 begin
    76 GetNext;
    78 GetNext;