energyAvailable wrong - shard1



  • Update 14/2/2021: The problem is occuring live in https://screeps.com/a/#!/room/shard1/W15N2

    Old post:

    I have a strange bug occurring in one of my rooms, W11N13 on shard1. This room has several extensions that are inactive. The rooms reports an energyAvailable of 2150, and energyCapacityAvailable of 2300. However, all active extensions and spawns are filled, which amounts to 2300. This occurred on 17/10/2020 and has lasted at least until today. It might have been present long before (I'm not that attentive).

    Console log:

    W11N13 FAILED -6 spawning claimer have 2150 need 2250 body["move","move","move","claim","move","move","move","claim","move","move","move","claim"]
    Game.rooms['W11N13'].energyAvailable
    2150
    Game.rooms['W11N13'].energyCapacityAvailable
    2300
    

    State of the room at the moment this occurs, all spawns and extensions filled: (sorry for the confusing extra visuals) 0_1603038987379_state.png

    Example replay where this occurs (total amount of energy is 2300): https://screeps.com/a/#!/history/shard1/W11N13?t=29948661

    The result of this is that my spawn isn't spawning because it is indicating that there is not enough energy - while there definitely is. I'm assuming this problem is because of the inactive extensions in the room, causing a mismatch in which extensions are inactive somehow?



  • This problem is currently still present. Now in W15N2. https://screeps.com/a/#!/history/shard1/W15N2?t=31911200

    energyAvailable results in 450, although 550 is available.

    Any help on this issue?



  • It's the disabled extensions that are full of energy. I think it's reading them as available energy, but the structures are not allowed at that rcl.



  • Thanks for thinking along!

    So I checked in this situation: 0_1611136487097_bfff9398-662e-4bf8-a5d4-215c7698825d-image.png

    In this situation, this is reported by the API:

    Game.rooms['W15N2'].energyAvailable
    450
    Game.rooms['W15N2'].energyCapacityAvailable
    550
    

    However, as you can see from the image, 450 energy is available in the extensions, and 300 in the spawn. energyAvailable, if the disabled extensions are counted, should be 750. If they are not counted, it should be 550. As all of the extensions are filled up, I'm not sure why this gap of 100 energy exists, and I cannot fill up this gap anywhere, causing my room to come to a standstill.

    I think the extensions that show up as disabled might be different than which extensions are counted in the back-end? It's a really strange situation.



  • @tijnoz As far as I remember, the client renders extensions disabled by distance to the controller I think, I can't remember the details, ags dug around, so that might explain some of it, this issue on the 3D client contains some of the information ags found https://github.com/thmsndk/Screeps3D/issues/176#issuecomment-644314073



  • Another thought is that you are defining what extensions to use when spawning, and you might be using the disabled ones? e.g. https://docs.screeps.com/api/#StructureSpawn.spawnCreep has energyStructures as an array, are you trying to use disabled ones to spawn with?



  • I reported this bug months ago with no response via ticket.The work around is to pass the active extensions via energyStructures https://docs.screeps.com/api/#StructureSpawn.spawnCreep or destroy the inactive structures.



  • Problem still persists, even after passing ONLY active energyStructures. I do pass the list myself yes: 0_1613336383729_66dbcbf2-b974-4283-8a68-7c01c37594e9-image.png

    In the output in the console you see the list of IDs that I pass to the spawnCreep function, it totals 550 energy and only contains active structures.

    room.energyAvailable reports 450, which results in the engine giving me the -6 error. I'm convinced this is a game engine issue, and would love for a dev's eye on this... Room is still fully broken. Maybe destroying all the structures solves the bug, but it's a bug nevertheless.



  • Bug is still present. Convinced it's a backend/engine issue. https://screeps.com/a/#!/room/shard1/W15N2



  • Sadly never have received a reply from a dev here, on slack, or via a support ticket. I'm destroying and rebuilding the room as a solution, but I'm dissapointed the problem will never get adressed.



  • I wrote my own function to fix this since it's been months with no response. Hit me up on slack on CrAzYDubC and I will help ya out.