So long and thanks for all the fish

  • The latest update has seriously broken my code and so I have cancelled my sub. I havent really played much for some time but I always intended to return at some point.

    I dont understand the logic of the RoomPosition change, break a load of code to save a little memory.....

    So feel free to loot any of my rooms of anything of value that u might find there.

    My sub ends at the end of the month but I expect my defenses are already broken along with everything else so happy looting.


  • Dev Team

    It's sad to hear your code is broken. Did you have a chance to check the change on the PTR? It was deployed 2 months ago, seems like plenty of time to prepare. All known possible breaking use cases are listed on the original PR page:

    • Object.create(RoomPosition.prototype, ...) -- please use new RoomPosition

    • Object.assign({}, rp) - properties on RoomPosition are no longer "own properties" so they won't be picked up by functions that filter on own properties

    • rp.x = -1; rp.y = 50 -- invalid values are no longer supported on RoomPosition

    • rp.roomName = 'e1s1' -- lowercase room names will be converted to uppercase

    I believe it's one of these. And they should not be very hard to fix.

    As to the logic behind this change, it's about heap memory usage which becomes the most crucial and vital weakness of many players' code since our transition to IVM, especially for those who have visibility to many rooms and game objects.

  • FWIW my code also broke because there was one instance where I would calculate the position and fill the pos.x / pos.y then validate that pos.x/pos.y where legitimate afterwards. But that technique no longer works.

    I know you've not had a lot of time to work on your code lately for various reasons and you've had other stuff to deal with, but I hope that at some point you will come back!


  • Sorry to see you go.

    Please consider open sourcing your code. Maybe someone will pick it up and fix it for you. Publishing broken but recently working code helps new coding players, with little risk of an NCP noob stomping with your code base.

  • Sorry to see you go! But good luck on your future world conquests!

  • @stevetrov hey steve, sorry to hear you leaving. I agree that the change is bad, broke my code too with no real performance change. I asked if they can change it to just returning an error code instead of breaking existing code, and was told this that "everything breaks"

  • AYCE

    Hope you come back later, Steve. Thanks for the SWC-organization and our other encounters in Screeps!

  • This change didn't break my code, but I still took the challenge to look at a possible fix.

    I tried to make the fix as easy as possible, but unfortunately I can't redefine the properties of RoomPosition.prototype. So here is one possible solution, which requires just simple replacements in code:

    RoomPosition.prototype.expand = function() {
        if (!this.__expanded) {
            Object.defineProperty(this, 'x', {
                value: this.x,
                writable: true
            Object.defineProperty(this, 'y', {
                value: this.y,
                writable: true
            Object.defineProperty(this, 'roomName', {
                value: this.roomName,
                writable: true
            Object.defineProperty(this, '__expanded', {
                value: true,
                writable: false
        return this;
    global.newRoomPosition = function(x, y, roomName) {
        var pos = new RoomPosition(0, 0, roomName).expand();
        pos.__packedPos = (pos.__packedPos & 0xFFFF0000) | ((x & 0xFF) << 8) | (y & 0xFF); // just for completeness
        pos.x = x;
        pos.y = y;
        pos.roomName = roomName;
        return pos;

    This almost restores the old behaviour with little changes in the code. Then you can use any value for x, y again and roomName can be lower case again. Object.assign({}, rp} also works again if rp was expanded with expand().

    You just have to replace all new RoomPosition to newRoomPosition in your code and before you use positions, call expand(). e.g.

    var myPos = Game.spawns.Spawn1.pos.expand(); myPos.x = -1; or

    var myPos = Game.creeps.Creep1.pos; myPos.expand().x = -1; myPos.y = -1; or

    var myPos = Object.assign({}, Game.spawns.Spawn1.pos.expand());

    This should minimize the effort to migrate the code now. Whereever an error pops up because you set x, y or roomName wrong, just add a call to expand() and it will be fine. You can also let the expand()-part out of your code by pasting:

    Object.defineProperty(RoomObject.prototype, 'pos', {
        get() {
            return this._pos.expand();
        set(value) {
            this._pos = value;

    This fails at the first tick, but works on subsequent ticks. I hope it helps.