Creep.moveTo and Pathfinder is returning single position paths

  • The issue here is not whether the parameters of the pathfinder can be altered to fix the issue, but rather why the pathfinder is returning single position arrays as the incomplete path.

    I have the following code

    creep.moveTo(target.pos, {range: 1, ignoreCreeps: false, swampCost: 5, visualizePathStyle: {...}});

    it results in the creep pathing through the wall to 0_1556689886781_8e7712e6-007f-41d5-9632-7729ff3eae5e-image.png
    Replay link:

    Changing the swamp cost to 4 results in the following incomplete path


    Verifying with Pathfinder,

            new RoomPosition(16,34,"E33N33"), 
            {pos: new RoomPosition(10,32,"E33N33"), range:1}, 
            {swampCost: 6}

    The following incomplete path is drawn with a swamp cost of 6 0_1556690590533_73bbcbf0-db14-426d-b408-2b1e8d19cfe4-image.png

    The following single RoomPosition path is returned when the swamp cost is 7

                new RoomPosition(16,34,"E33N33"), 
                {pos: new RoomPosition(10,32,"E33N33"), range:1}, 
                {swampCost: 7}
    [2:03:09 PM][shard3][{"x":16,"y":35,"roomName":"E33N33"}]

  • It is quite possible that the path finder maxes out it 2000 ops and returns a incomplete path.
    (It does not throw a error only a incomplete path)
    That room is quite complex try to lower your swamp cost to 3 this should reduce the complexity OR increase your maxOps to 5000.

    P.S. you really like to punish the Pathfinder don't you? 🤣

  • I wasnt even trying to punish the pathfinder lol. It was using legacy creep.moveTo() code. I was wondering why it wasn't moving to the target.

    Yes. I realise that the issue can be circumvented by reducing complexity. But this is happening on 'creep.moveTo()' and there isnt an incomplete flag in that function. Neither is it returning any error codes. I was confused for a good 4 hours wondering why it was doing that. This needs to be better documented. Its just a room that any beginner can encounter and there are no indications when the path is incomplete using creep.moveTo() (Unless im missing that documentation)

  • You are really the first one I encounter with this problem and I'm lurking around this game for quite some time now.
    But are you sure it should return a -2 for "No path" but it still will try to get to the nearest possible place.

  • Something in my code was suppressing the error. It does return -2 but not every tick. How much of the opts can be used in creep.moveTo()?

  • all, it is just straight passing stuff through, more or less just a shorthand.

  • YP

    I guess with standard moveTo it will probably work because it will redo the path every few ticks .. so it's ok to just get the right direction for the next 5 steps.

  • @w4rl0ck Except in my case the "Correct direction" was to run into a wall.

  • YP

    ah .. I misunderstood the images... yes .. I had a similar problem once .)

  • @mrfaul Are you sure? the flee flag works in creep.moveTo? The last time I tried it didnt work.

  • sry, I meant it passes to Room.findPath() <- which use the Pathfinder but omits some stuff, flee is one of them.