m0u53m4t
2007-02-24 16:48:58
I was thinking about a code that would make random numbers, so that if you told it:
RandomM(10)
it would most commonly come up with 0, and only rarely come up with ten. This could be good for the random on clicking I reckon. Thoughts?
Here's the function I've written:
RandomM(10)
it would most commonly come up with 0, and only rarely come up with ten. This could be good for the random on clicking I reckon. Thoughts?
Here's the function I've written:
Function RandomM(Range: Integer): Integer;
var
i : integer;
begin
Result := Random(Range)
for i := 0 to Result do
begin
if random(i) = 0 then Result := Result - i
if Result < 0 then Result := Result + i
end;
Result := Result + random(range-Result)/4+Random(4)
if Result > range then Result := range
end;