Page 1 of 1

[0.18.17] entity minable.results amount_min/amount_max not working correctly

Posted: Sat Mar 28, 2020 8:53 pm
by ickputzdirwech
I tried to create a mod that variates the result when you mine trees, similar to how it works with most rocks. I quickly noticed however, that I didn't get the expected result. For example I modded the "dead-tree-desert" that yields 2 wood in vanilla:

Code: Select all

data.raw.tree["dead-tree-desert"].minable.results = {{name = "wood", amount_min = 1, amount_max = 3}}
As I understand it you should expect to get 1, 2 or 3 wood equally likely if you mine that tree. I didn't. I tried a 100 different things and I couldn't get it to work as I expected.

Since I didn't knew if I was just doing something wrong I checked in vanilla. Same problem: For example when mining a "sand-rock-big" it is impossible to get 25 stone even though in the code it says otherwise:

Code: Select all

results = {{name = "stone", amount_min = 19, amount_max = 25}}
For a big sandy rock the tooltip tells you that you should expect 22 stone. For my testing (with 300 big sandy rocks) it was about 21.76 . That's not far of (and not the 21.5 I was expecting by then) but since I got quite a big sample size I am confident that it is more accurate than 22. I don't know what is going on and I am still not sure if it is just me or my bad luck that is causing this issue, but it would be nice if you could look into it.

The loot table seems to be unaffected of this (yes, I might have shot about 100 "sand-rock-big"s in the process 8-) .

Re: [0.18.17] entity minable.results amount_min/amount_max not working correctly

Posted: Sun Mar 29, 2020 1:18 am
by Rseding91
What are you saying is actually broken? That you can't get it to give a random result or that the random result it gives is wrong?

Re: [0.18.17] entity minable.results amount_min/amount_max not working correctly

Posted: Sun Mar 29, 2020 11:30 am
by posila
Hmm, looking at the code, it won't ever give amount_max

Re: [0.18.17] entity minable.results amount_min/amount_max not working correctly

Posted: Sun Mar 29, 2020 11:59 am
by ickputzdirwech
For my testing it seem to be that the random result it gives is broken. In the first example I gave, it randomly gives 1 and 2 as a result. In the second case it is the same: It gives the results 19 to 24 randomly. Here is the result from my 300 "sand-rock-big" sample:

result : how often I got it
19 : 47
20 : 31
21 : 48
22 : 51
23 : 64
24 : 59
25 : 0

So the big problem is obviously that it never gives the highest value. This would explain why the expected 22 stone are not reached on average. The other results are however very strangely distributed as well. Yes it could very well be a coincidence, but the semi random generator seems to prefer larger results.

Re: [0.18.17] entity minable.results amount_min/amount_max not working correctly

Posted: Mon Mar 30, 2020 6:55 am
by posila
Thanks for the report and investing so much time into your experiments.

amount_max not being ever returned is fixed for 0.18.18

The distribution seems fine to me. PRNG we use might not be exactly uniform on short runs, but that's fine.