[WIP] Free Energy

Discussion in 'Work-In-Progress Mods' started by cola_colin, July 29, 2015.

  1. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,125
    Likes Received:
    16,255
    So I'll show you two test games first. They were basically the same. I placed down one bot factory. Commander queued one pgen and a long row of power storage. Factory made 3 bot fabbers then idle. Bot fabbers support the commander in building power storages. The following graph shows the normal PA energy stored I had:

    [​IMG]

    And this one with a UI mod I am working on. Notice the scale is a bit different.
    [​IMG]

    More than 100k energy out of NOWHERE.

    In the 2nd one for some reason my build speed was slightly reduced. Not sure if that is due to a negative effect from the mod or from stupid pathfinding or something. Needs more comparison work.

    So Free Energy is an automatic economy management UI mod. It does the following things atm:

    • Detect when you are metal stalling. Metal stalling is really bad, as it basically wastes energy in a roundabout way since fabbers still require full energy when building even though they are building slower. Free Energy will periodically pause your stuff so everything always works at full energy efficiency. Fabbers that are reclaiming will not be paused due to metal stalls.
    • Add a new state to the pause system: [​IMG] . Units that are running on this specific setting will be given more resources to work with. Be careful: If you put too much on priority then non priority tasks will make near zero progress.
    • Shows a specific icon when your selection has a mixed energy stance combination: [​IMG]
    • Detect if you are out of energy. If you are out of energy radar and teleporters will be disabled until you have energy again. They would not actually do anything but drain energy for no reason otherwise.
    • Detect that you are "rich". Rich atm means that both your storages are filled by more than 60%. In this case even paused units will start to build
    • Automatically make even paused fabbers (whatever the reason for the pause) build for half a second every 10 seconds. This prevents buildings from being destroyed by atrophy. Due to atrophy fabbers that build walls will not be paused, they tend to break too much otherwise.
    • The UI will not show the automatic pauses. It'll show a "I would prefer"... status. So as I said already: Just because you paused does not mean it will pause, just because you set prio it does not mean it will always fab. The system may decide there is a reason to still unpause (you are rich/prevent atrophy) or pause (you are stalling metal). The decision the system makes should always be the right ones....

    A quick summary of how it internally works:
    Twice per second it will calculate how long you can sustain your current metal and energy net income before your storage is empty. These values will be used to potentially pause things. A priority builder will pause later than a non priority builder. Builders will always pause if you are metal stalling to prevent energy losses. If you are energy stalling you will only see pauses if you have something set on priority.

    Consider this a beta release. It may have bugs that will lose you games ;)
    Also there are few drawbacks:

    • This mod disables server culling of data. Making a lot of units will potentially network lag the game much faster than you are used to. This is required so that the mod can manage units you are not watching.
    • This mod only manages your economy while you are not watching the chronocam.
    • This mod will screw over your teammates in shared army games.
    • This mod forgets your energy stance settings on UI reloads or on reconnects. Everything will be back to the default state of "enabled".
    • Stats systems are screwed over: Ingame APM of 1k and more. PA Stats sees a constant 100% build efficiency.
    • Decisions are not completely perfect. A lot of what this does kinda comes down to predicting the future. Not easy ;)

    Mod is on pamm
    Code is on github: https://github.com/pamods/FreeEnergy/tree/master/FreeEnergy
    Last edited: August 1, 2015
  2. wondible

    wondible Post Master General

    Messages:
    3,278
    Likes Received:
    2,078
    Beat me to it; although I was going to start with the problem that radar is just wasted energy when energy is low, and perhaps build priorities from there.
    stuart98 likes this.
  3. Killerkiwijuice

    Killerkiwijuice Post Master General

    Messages:
    3,827
    Likes Received:
    3,573
    This is awesome but it seems like cheating imho :>

    Also what does energy storage have to do with? Should it be a graph of energy wasted?
  4. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,125
    Likes Received:
    16,255
    I basically build the same thing with the same workers. Without the mod my energy storage stays empty, with the mod I have 150k energy in it. 150k energy I could spent on other things.
    cdrkf, Killerkiwijuice and stuart98 like this.
  5. stuart98

    stuart98 Post Master General

    Messages:
    6,020
    Likes Received:
    3,902
    Does the mod pause workers that are reclaiming?
  6. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,125
    Likes Received:
    16,255
    Atm yes. I've not verified, but I *probably* can detect if they are and not pause them. Haven't verified what the orders API tells me in that case though, but I hope I can.
    stuart98 likes this.
  7. Clopse

    Clopse Post Master General

    Messages:
    2,516
    Likes Received:
    2,858
    So a mod that gives you 150k energy isn't cheating?

    Anyhows it's not as good as pausing factories. As you most likely will have fabbers building energy.
    elodea likes this.
  8. cdrkf

    cdrkf Post Master General

    Messages:
    5,750
    Likes Received:
    4,831
    Well it isn't cheating- it's simply managing your resources better (i.e. *not* wasting all the energy when you metal stall).

    Note that if you balance your eco really carefully and *totally avoid metal stall* then @cola_colin's mod won't give you anything at all (so I would imagine this will make little difference at top level play). I mean the scenario as presenting isn't exactly a winning build :p
  9. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,125
    Likes Received:
    16,255
    It'll probably have some form of priority system in the end, so you can make it favor that energy making fabber over all else.

    And yep the presented scenario was the epic "11 energy storages into main menu"-build.
    We'll see how much difference this makes in real games. The difference only happens when you are stalling metal and could use more energy later on.
  10. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,125
    Likes Received:
    16,255
    Bonus, have the most epic looking ingame command rate graphs:
    [​IMG]

    @pinbender Pretty low prio, but I think you should not count commands given via the API as user input for that graph, or maybe offer two graphs, one with the API and one without.
    stuart98, doud and Killerkiwijuice like this.
  11. pinbender

    pinbender Active Member

    Messages:
    78
    Likes Received:
    137
    Currently, they are identical from the server's perspective. (Which is where that graph comes from, IIRC.)
    stuart98, doud and cdrkf like this.
  12. andreasgg

    andreasgg Well-Known Member

    Messages:
    212
    Likes Received:
    384
    It is not managing your recourses better, it is a "robot" (automatically) managing your eco for you, in my eyes cheating. I don't like where all this is going with automated factories, energy saving etc. Why don't we replace every player with a AI and let the players do the micro/ macro. You get the point?

    I like your work and your spirit cola, don't get me wrong keep it up!! You are doing amazing things to the community and I admire that. I just don't like the way this is going.
    Corgiarmy likes this.
  13. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,125
    Likes Received:
    16,255
    I realize this kind of mod is probably a little more controversial, but it is what it is.
    We'll see what it does. I think it's better to have it out there and test how it affects the game.
    stuart98 and Quitch like this.
  14. cdrkf

    cdrkf Post Master General

    Messages:
    5,750
    Likes Received:
    4,831
    All I'd say is that all this mod does is make the eco work more like TA did (as in power usage scaled with metal up to a fabbers full build rate rather than hitting you so hard with energy). I personally think the economy should work like this- the way PA is it's all kinda inverted with metal functioning like energy in terms of how it limits things.
    aevs, stuart98 and ace63 like this.
  15. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,125
    Likes Received:
    16,255
    Yep that's where the idea comes from in the end. PA's economy system has that questionable change. A change that is basically asking you to spend a hundred APM on your economy to make it work better.
    Nicb1, stuart98, ace63 and 2 others like this.
  16. ace63

    ace63 Post Master General

    Messages:
    1,067
    Likes Received:
    826
    I see the economy system at fault here (which was bad from the beginning coupling energy usage to fabbers the way it does), not cola_colin.
    stuart98 and cdrkf like this.
  17. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,125
    Likes Received:
    16,255
    beta release is on pamm, check the OP. Please test at your own risk. It may just flat out decide to pause everything and never unpause it, don't blame me :p

    EDIT:
    played 2 ranked games. Won both. Certainly not only because of this mod, but it didn't kill me either at least :D
    Last edited: August 1, 2015
    stuart98 and maxpowerz like this.
  18. probodobodyne

    probodobodyne Active Member

    Messages:
    216
    Likes Received:
    182
    It begins. The machine revolution is nigh!
    stuart98 likes this.
  19. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,125
    Likes Received:
    16,255
    I feel the APIs are rather slow, this mod seems to cause slight camera movement lags later in the game.
    Might need to reduce the polling frequency to once a second and maybe optimize a few things to reduce API calls, that probably should be decent as well.
    It seems while API calls are being processed the whole client basically is frozen.

    EDIT: though actually even with --nomodes zooming is kinda laggy. Might be imagination though. It's 5 in the morning, maybe I should just sleep...
    Last edited: August 2, 2015
    stuart98 likes this.
  20. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,125
    Likes Received:
    16,255
    continues to work in titans, but we'll see how it goes with reclaiming now

Share This Page