If you've ever played a RPG, this might sound familiar.
But my the question is: How is this 10% calculated?
At first it was my guess to use a random number between 1 and 100.
If the result is between 1 and 10 then I get the sword.
The following snippet however, seems to proof that this methode is not correct
Code:
procedure TForm1.Button1Click(Sender: TObject);
var x,number : integer;
test : array[1..10] of integer;
begin
randomize;
for x:= 1 to 10 do
test[x]:=0;
memo1.lines.clear;
for x:= 1 to 100 do
begin
number := random(100);
case number of
1..10: test[1]:=test[1]+1;
11..20: test[2]:=test[2]+1;
21..30: test[3]:=test[3]+1;
31..40: test[4]:=test[4]+1;
41..50: test[5]:=test[5]+1;
51..60: test[6]:=test[6]+1;
61..70: test[7]:=test[7]+1;
71..80: test[8]:=test[8]+1;
81..90: test[9]:=test[9]+1;
91..100: test[10]:=test[10]+1;
end;
end;
for x := 1 to 10 do
begin
memo1.lines.add('numbers between '+inttostr(1+(10*(x-1)))+' and '+inttostr(x*10)+' ='+inttostr(test[x]));
end;
end;
In some cases only 5 numbers out of 100 are < 10, in others, as much as 17 numbers were below 10.
So this is clearly not the way to do this....
But it's the best I can think of at the moment.
Any other ideas to get the dagger within the correct percentage? :roll:
Bookmarks