DeckerMMIV / FarmSim_Mod_SoilMod

Farming Simulator modification - SoilMod
25 stars 14 forks source link

Utils.cutFruitArea returns doubled volume under optimal conditions #64

Closed Mogli12 closed 8 years ago

Mogli12 commented 9 years ago

Hi,

I played the map Tunxdorfmodcontest2015 with SoilManagement. I was suprised about how fast the corn tank of the different combines was full. Finally I build a small mod to switch between the overwritten Utils.cutFruitArea and the original one (SoilManagement.fmcModifyFSUtils.origFuncs.cutFruitArea). SoilManagement almost doubles the volume. I suspect that line 309 of fmcSoilModPlugins.lua causes the doubling:

dataStore.volume = dataStore.volume + (dataStore.volume * dataStore.fertN.factor)

Regards, Mogli

DeckerMMIV commented 9 years ago

Depending on how the map-author have structured his map, and what combine is used (vanilla or modded), then there can be a huge difference in yield, comparing 'vanilla style' and 'SoilMod style'.

For instance, if the map-author has not correctly made sure that the fruit_density.GRLE file and the two SoilMod .GRLE files must have the same width/height, then strange things could happen.

Also depending on; if there has been used fertilizer or not, and the soil pH levels and the other SoilMod attributes which affect harvest yield, then the calculations can't really be compared 'vanilla style' and 'SoilMod style'.

But you are correct, that if the soil levels are at 'optimal values', then the calculation in SoilMod will produce higher yields.

Mogli12 commented 9 years ago

I compared the output of the overwritten Utils.cutFruitArea with the output of the original one. You store the function pointer in SoilManagement.fmcModifyFSUtils.origFuncs.cutFruitArea. The overwritten Utils.cutFruitArea returns the doubled value. At this level it should be independend of the combine I use. But I tried it a build-in and a modded combine.

I calculated the expected output based on the combine speed, working width and the average FPS (value of dt to be correct). I have about 31 FPS. I did the calculation with the Claas Lexion 400 package and 7.5m cutter. So with every update the combine moves around 0.08m. Based on these values I calculated the l/m² and from this the value in t/HA for wheat.

My conclusion was that the original Utils.cutFruitArea returns a rated around 10 t per HA for wheat. I checked https://en.wikipedia.org/wiki/Wheat and I have the impression that the real value should be between 9 and 12 tons per hectare. But with soil management it would be 20 tons per hectare under optimal conditions.

DeckerMMIV commented 9 years ago

Utils.cutFruitArea() returns 3 values;

In the vanilla method, it will set spraySum to greater-than-zero, in case there is just a tiny little part of the area that has been fertilized. Then in the CutterAreaEvent.runLocally() method (link, line 59) - which calls Utils.cutFruitArea() - it checks to see if the returned spraySum is greater than zero and if so it doubles the volume. So the vanilla "double yield" is actually first calculated in CutterAreaEvent.runLocally() and not returned by Utils.cutFruitArea().

In SoilMod's override of Utils.cutFruitArea() and the plugins added by fmcSoilModPlugins, it will always return zero for spraySum (except if the fmcFertN foliage-layer is not in the map) and then return the "possible double+ yield" volume instead (based on the calculations of the SoilMod layers). Setting spraySum to zero is to avoid the vanilla "double yield" calculation in CutterAreaEvent.runLocally().

So in essence;

For the "optimal conditions" you talk about, what were those optimal conditions set to in the field? Did you use the modSoilModPaint console-command to set all of the 5 properties (soil-moisture, pH level, N, PK & weeds), before doing the SoilMod-harvest test? Did you fertilize the field before doing the vanilla-harvest test?

Mogli12 commented 9 years ago

Ah, I did not check this multiplication in CutterAreaEvent.runLocally(). This explains it very well. But I do not understand why Giants did it this way. If you look at fruit types you will see that Giants starts with quite realistic values for liters per square meter and tons per liter. Wheat has values of 1.2 l/m² and 0.00082 t/l. This would lead to 9.84 tons per hectare. But now they multiply the fruit weight with 0.5 and the liters per square meter with 2. If I have a map with realistic field sizes the corn tank of combine is almost always full. But I am glad that SoilMod under optimal conditions behaves like the vanilla game. I did not want to find a bug. I was just annoyed about the unrealistic yield. So I think I have to write a yield mod.

Mogli12 commented 8 years ago

I created a new mod RealisticYield (https://github.com/Mogli12/RealisticYield) to multiply the liters per square meter by 0.5.