Mmtrx / FS22_BetterContracts

Farming Simulator mod to enhance contracts handling
GNU General Public License v3.0
114 stars 25 forks source link

Wrong jbest in userint.lua ? #17

Open Sileo35 opened 2 years ago

Sileo35 commented 2 years ago

Hello, Spread mission doesn't use the best profit/min approximation between mission and default vehicles.

I propose to replace starting to the line 231 :

  local jbest = 1
  for j = 1, maxj do
    if cost[j] > cost[jbest] then
      jbest = j
    end
  end
  local rew = m:getReward()

by :

  local rew = m:getReward()
  local jbest = 1
  for j = 1, maxj do
    if (rew + cost[j]) / dura[j] > (rew + cost[jbest]) / dura[jbest] then
      jbest = j
    end
  end

Cheers. Sileo

Sileo35 commented 2 years ago

Sorry for indentation ... I don't understand this github text editor ...

Sileo35 commented 2 years ago

maybe there is a better way by adding jbestprofit and jbestpermin, and you different the best j when you orderize by permin or profit.

Sileo35 commented 2 years ago

or just replace : if cost[j] > cost[jbest] then by : if cost[j] >= cost[jbest] then

to use the j = 2 in jbest

Mmtrx commented 2 years ago

Wow, you really dug deep into my code! That whole part of the script feels clumsy, I'm not proud of it. I always felt there must be a far more elegant way to do this.

Your suggestions are probably right. I will put them in my next update.

To write code (incl indentation) in here you can use ctrl-e, or click the <> symbol in the editor line on top. Before hitting "Comment", you can always check your formatting by clicking Preview

If you happen to understand German, we can switch our conversation to that language.