Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSBase.Chance does not work for certain inputs #5517

Closed
DorpsGek opened this issue Apr 1, 2013 · 4 comments
Closed

GSBase.Chance does not work for certain inputs #5517

DorpsGek opened this issue Apr 1, 2013 · 4 comments
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

DorpsGek commented Apr 1, 2013

Aphid opened the ticket and wrote:

Try out the following code.

function MyScript::ProbCheck(p,k,n){
local r = 0;
local v = 0;
while(r<n)
{
if(GSBase.Chance(p,k))
v++;
r++;
}
GSLog.Info("Sum result:" + (v.tofloat() / n.tofloat() * 100.0) + " percent");
}

I used a while(true) loop like this:

while(true)
ProbCheck(300000, 1000000, 10000);

Results are around 4%. Note: The chance of getting a result of 4% or less is 3.27270834148310^-969
The chance of this happening 100 times in a row is 3.272708341483
10^-96900. I do believe there is an error here.

Reported version: 1.3.0
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/5517
@DorpsGek
Copy link
Member Author

DorpsGek commented Apr 1, 2013

Aphid wrote:

Using

while(true)
ProbCheck(3, 10, 10000);

does work and get me a 30% chance. There is probably some issue with using larger numbers.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5517#comment12132

@DorpsGek
Copy link
Member Author

DorpsGek commented Apr 1, 2013

Aphid wrote:

From several tests, It seems that choosing p < 65536 avoids the bug.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5517#comment12133

@DorpsGek
Copy link
Member Author

DorpsGek commented Apr 1, 2013

Aphid wrote:


This comment was imported from FlySpray: https://bugs.openttd.org/task/5517#comment12134

@DorpsGek
Copy link
Member Author

DorpsGek commented Apr 6, 2013

Rubidium closed the ticket.

Reason for closing: Fixed

In r25148


This comment was imported from FlySpray: https://bugs.openttd.org/task/5517

@DorpsGek DorpsGek closed this as completed Apr 6, 2013
@DorpsGek DorpsGek added flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) bug labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant