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

This subforum contains all the issues which we already resolved.
User avatar
ickputzdirwech
Filter Inserter
Filter Inserter
Posts: 787
Joined: Sun May 07, 2017 10:16 am
Contact:

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

Post 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-) .
Last edited by ickputzdirwech on Sun Mar 29, 2020 12:00 pm, edited 1 time in total.
Mods: Shortcuts for 1.1, ick's Sea Block, ick's vanilla tweaks
Tools: Atom language pack
Text quickly seems cold and unfriendly. Be careful how you write and interpret what others have written.
- A reminder for me and all who read what I write

Rseding91
Factorio Staff
Factorio Staff
Posts: 14142
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post 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?
If you want to get ahold of me I'm almost always on Discord.

posila
Factorio Staff
Factorio Staff
Posts: 5322
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

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

Post by posila »

Hmm, looking at the code, it won't ever give amount_max

User avatar
ickputzdirwech
Filter Inserter
Filter Inserter
Posts: 787
Joined: Sun May 07, 2017 10:16 am
Contact:

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

Post 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.
Mods: Shortcuts for 1.1, ick's Sea Block, ick's vanilla tweaks
Tools: Atom language pack
Text quickly seems cold and unfriendly. Be careful how you write and interpret what others have written.
- A reminder for me and all who read what I write

posila
Factorio Staff
Factorio Staff
Posts: 5322
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

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

Post 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.

Post Reply

Return to “Resolved Problems and Bugs”