Supreme Economy

Post here if you want to help developing something for FAF.

Supreme Economy

Postby Axle » 02 Jan 2016, 08:47

I want to make some fixes to the Supreme Economy mod (mass consumption is inaccurate due to rounding errors). However there are a few versions:

- "v3" doesn't work.
- "EM-edition v2" is the most recently updated
- "2.1 (noloag) v2.1" also works and has a higher version number, but is older

so ... Anyone know whats going on with these different versions? which one should I modify and upload?
Axle
Avatar-of-War
 
Posts: 93
Joined: 02 Apr 2013, 10:14
Has liked: 0 time
Been liked: 4 times
FAF User Name: Axle

Re: Supreme Economy

Postby nine2 » 03 Jan 2016, 07:21

I have been working on a competitor to that for the last few days... whilst I love the mod, it has lots and lots of problems. On the way I discovered that the unit view (hover over unit display) and economy overlay have lots of problems too. I'm slowly getting it there.

I always used 2.1 (noloag) v2.1, its good
I used v3 but didn't like it - it was very different, showing eco usage bars over the units themselves on the map - not in its own ui on the left
Never heard of the EM edition, would be interested to know what it's about.

Re the problem that you mentioned (mass consumption due to rounding errors), that is not something you can fix in a UI mod because the figures are rounded before they get to the UI mod layer. So if you have 100 mantis each assisting a t3 factory they use something like 0.4 mass which should equate to 40 mass - but the UI layer sees zero. The solution is to integrate a fix into the FAF base code that sends the decimal figures to the UI layer ... which I've got working and can send you once I straighten some things out.
nine2
Councillor - Promotion
 
Posts: 2416
Joined: 16 Apr 2013, 10:10
Has liked: 285 times
Been liked: 515 times
FAF User Name: Anihilnine

Re: Supreme Economy

Postby nine2 » 03 Jan 2016, 07:24

v3:
Image
nine2
Councillor - Promotion
 
Posts: 2416
Joined: 16 Apr 2013, 10:10
Has liked: 285 times
Been liked: 515 times
FAF User Name: Anihilnine

Re: Supreme Economy

Postby Axle » 03 Jan 2016, 09:43

Hi Anhilnine! That's interesting that you can correct the rounding error in the FAF code base. I assumed that since no one ever bothered to fix it (in the mouse-over tooltip for the units) that the rounding was done in the FA exe.

The solution that I came up with is actually a UI-only work-around (its still not 100% accurate, but it does improve accuracy significantly). Basically the approach is to work out mass consumption by looking at energy consumption. It only gets a little hairy when you consider eg ACU upgrades and radar energy consumption. But I believe I've got it working reasonably. I want to test it a bit longer before I upload a patched version though. Anyway, relevant code below in case you're interested.

Thanks for that information about v2.1. I did noticed yesterday that I had some intolerable UI lag with the EM edition when I put it on +10 speed. I did a diff on the v2.1 and the EM edition. It looks like v2.1 is retrieving unit data a bit differently (presumably to reduce lag), whereas the EM edition looks like someone has changed it to use the Common Mod tools to retrieve unit data.

I'm looking forward to seeing your competitor mod, hopefully I can ditch Supreme Economy and use yours instead when its released! :)

Code: Select all
econData = unit:GetEconData()
...

local blueprint = unitToGetDataFrom:GetBlueprint()

-- econData.energyConsumed generally has more significant figures than econData.massConsumed
-- so here we use energyConsumed to work out a more precise massConsumed
local energyAdjusted = 0.5+econData.energyConsumed
local massAdjusted = 0.5+econData.massConsumed
local candidateMassCosts = { }
candidateMassCosts["upkeep"] = 0
candidateMassCosts["unit"] = energyAdjusted*blueprint.Economy.BuildCostMass/blueprint.Economy.BuildCostEnergy
if blueprint.Enhancements then
  for k,v in pairs(blueprint.Enhancements) do
    if v.BuildCostEnergy > 0 then
        candidateMassCosts[k] = energyAdjusted*v.BuildCostMass/v.BuildCostEnergy
    end
  end
end

local bestFitDesc = false
local bestFitMass = false
for k,v in pairs(candidateMassCosts) do
  if (not bestFitMass) or math.abs(v-massAdjusted) < math.abs(bestFitMass-massAdjusted) then
    bestFitDesc = k
    bestFitMass = v
  end
end

if bestFitMass then
  econData = { energyConsumed=energyAdjusted, massConsumed=bestFitMass }
end
Axle
Avatar-of-War
 
Posts: 93
Joined: 02 Apr 2013, 10:14
Has liked: 0 time
Been liked: 4 times
FAF User Name: Axle

Re: Supreme Economy

Postby nine2 » 03 Jan 2016, 10:56

That's some pretty out of the box thinking there. It's still not perfect but it's more accurate. Nice one
nine2
Councillor - Promotion
 
Posts: 2416
Joined: 16 Apr 2013, 10:10
Has liked: 285 times
Been liked: 515 times
FAF User Name: Anihilnine

Re: Supreme Economy

Postby IceDreamer » 03 Jan 2016, 11:56

Please do drop any relevant under the hood accuracy improvements as PRs onto the main FA git repo, the base game needs help in this area :)
IceDreamer
Supreme Commander
 
Posts: 2607
Joined: 27 Dec 2011, 07:01
Has liked: 138 times
Been liked: 488 times

Re: Supreme Economy

Postby nine2 » 03 Jan 2016, 14:00

Onto it like measles
nine2
Councillor - Promotion
 
Posts: 2416
Joined: 16 Apr 2013, 10:10
Has liked: 285 times
Been liked: 515 times
FAF User Name: Anihilnine

Re: Supreme Economy

Postby Saxxon » 16 Jan 2016, 15:34

That's some deep stuff. I'd love to see this working again, not sure if this is the one that had the T1, T2 and T3 mex shown on side, but that was a big help too as it let you select all mex of a given tech, and if they had mass storage around them or not.
Saxxon
Avatar-of-War
 
Posts: 95
Joined: 28 Dec 2014, 13:56
Has liked: 1 time
Been liked: 4 times
FAF User Name: Saxxon

Re: Supreme Economy

Postby nine2 » 16 Jan 2016, 16:45

2.1 (nolag) is working today and in the mod vault.
nine2
Councillor - Promotion
 
Posts: 2416
Joined: 16 Apr 2013, 10:10
Has liked: 285 times
Been liked: 515 times
FAF User Name: Anihilnine

Re: Supreme Economy

Postby watermelon » 17 Jan 2016, 11:44

Anihilnine wrote:2.1 (nolag) is working today and in the mod vault.

It says "Uploaded 2014-04-13"? Or does the upload date not adjust when mods are updated?
User avatar
watermelon
Avatar-of-War
 
Posts: 59
Joined: 05 Jul 2015, 18:05
Has liked: 7 times
Been liked: 4 times
FAF User Name: watermelon

Next

Return to Contributors

Who is online

Users browsing this forum: No registered users and 1 guest