Thanks for the testing script boreas, i had no idea about how to test it...
and i added a chance calculator in it, and the report at the end is aligned:
SCAR Code:
function randomex(startrange, endrange, midpoint: integer; domidpoint: boolean): integer;
var
endrangex, xl: integer;
begin
midpoint:=midpoint+1
if (midpoint<=0) then
begin
midpoint:=2
end;
if (domidpoint=true) then
begin
repeat
begin
endrangex:= random(endrange)
xl:=(midpoint*2)-endrangex
result:= random(endrangex)+(random(xl))
end;
until (result > startrange) and (result < endrange)
end else
begin
repeat
begin
endrangex:=random(endrange)
result:=endrangex
end;
until (endrangex > startrange) and (endrangex < endrange)
end;
end;
var
counters: array [0..1000] of integer;
number,i,chancei,roundchance,lengthi,lengthcounter,lengthroundchance:integer;
chance: extended;
ilength,counterlength,roundchancelength: string;
begin
repeat
number:=randomex(0,100,50);
counters[number]:=counters[number]+1;
i:=i+1;
until (isfkeydown(12) and (i>=10000) or (i=1000000000000))
chancei:=i
cleardebug;
writeln('Done ' + inttostr(i) + ' times');
writeln('REPORT:');
i:=0;
repeat
chance:= counters[i] div chancei
chance:= chance * 100
roundchance:= round(chance)
lengthi:= length(inttostr(i))
lengthcounter:= length(inttostr(counters[i]))
lengthroundchance:= length(inttostr(roundchance))
if (lengthroundchance=1) then begin roundchancelength:= ' ' end;
if (lengthroundchance=2) then begin roundchancelength:= ' ' end;
if (lengthroundchance>=3) then begin roundchancelength:= ' ' end;
if (lengthi=1) then begin ilength:= ' ' end;
if (lengthi=2) then begin ilength:= ' ' end;
if (lengthi=3) then begin ilength:= ' ' end;
if (lengthi>=4) then begin ilength:= '' end;
if (lengthcounter=1) then begin counterlength:= ' ' end;
if (lengthcounter=2) then begin counterlength:= ' ' end;
if (lengthcounter=3) then begin counterlength:= ' ' end;
if (lengthcounter=4) then begin counterlength:= ' ' end;
if (lengthcounter=5) then begin counterlength:= ' ' end;
if (lengthcounter=6) then begin counterlength:= ' ' end;
if (lengthcounter=7) then begin counterlength:= ' ' end;
if (lengthcounter>=8) then begin counterlength:= '' end;
writeln('Number '+ inttostr(i) + ilength + 'Detected '+inttostr(counters[i]) + counterlength + 'times ' + ' chance is round: '+ inttostr(roundchance)+'%' + roundchancelength + 'or ' +floattostr(chance)+ '% for exact');
i:=i+1;
until i=100;
end.
I will try to put my nose into a math book and then i will try again