hedgewars/uRandom.pas
changeset 107 b08ce0293a51
parent 105 e7cb9bb4a9de
child 124 75b892eff74d
equal deleted inserted replaced
106:98cb6606bf67 107:b08ce0293a51
    33 
    33 
    34 unit uRandom;
    34 unit uRandom;
    35 interface
    35 interface
    36 
    36 
    37 procedure SetRandomSeed(Seed: shortstring);
    37 procedure SetRandomSeed(Seed: shortstring);
    38 function  GetRandom: real; overload;
    38 function  GetRandom: Double; overload;
    39 function  GetRandom(m: LongWord): LongWord; overload;
    39 function  GetRandom(m: LongWord): LongWord; overload;
    40 
    40 
    41 implementation
    41 implementation
    42 var cirbuf: array[0..63] of Longword;
    42 var cirbuf: array[0..63] of Longword;
    43     n: byte;
    43     n: byte;
    64     cirbuf[i]:= i * 23860799;
    64     cirbuf[i]:= i * 23860799;
    65 
    65 
    66 for i:= 0 to 1024 do GetNext;
    66 for i:= 0 to 1024 do GetNext;
    67 end;
    67 end;
    68 
    68 
    69 function GetRandom: real;
    69 function GetRandom: Double;
    70 begin
    70 begin
    71 Result:= frac( GetNext * 0.0007301 + GetNext * 0.003019)
    71 Result:= frac( GetNext * 0.0007301 + GetNext * 0.003019)
    72 end;
    72 end;
    73 
    73 
    74 function GetRandom(m: LongWord): LongWord;
    74 function GetRandom(m: LongWord): LongWord;