@mrfaul Are you sure? the flee
flag works in creep.moveTo
? The last time I tried it didnt work.
DarkDestry
@DarkDestry
Posts made by DarkDestry
-
RE: Creep.moveTo and Pathfinder is returning single position paths
-
RE: Creep.moveTo and Pathfinder is returning single position paths
@w4rl0ck Except in my case the "Correct direction" was to run into a wall.
-
RE: Creep.moveTo and Pathfinder is returning single position paths
Something in my code was suppressing the error. It does return -2 but not every tick. How much of the
Pathfinder.search()
opts can be used increep.moveTo()
? -
RE: Creep.moveTo and Pathfinder is returning single position paths
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) -
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
Replay link: screeps.com/s/igfwWpChanging the swamp cost to 4 results in the following incomplete path
Verifying with Pathfinder,
Game.rooms["E33N33"].drawPath( PathFinder.search( new RoomPosition(16,34,"E33N33"), {pos: new RoomPosition(10,32,"E33N33"), range:1}, {swampCost: 6} ).path )
The following incomplete path is drawn with a swamp cost of 6
The following single RoomPosition path is returned when the swamp cost is 7
console.log( JSON.stringify( PathFinder.search( new RoomPosition(16,34,"E33N33"), {pos: new RoomPosition(10,32,"E33N33"), range:1}, {swampCost: 7} ).path ) )
[2:03:09 PM][shard3][{"x":16,"y":35,"roomName":"E33N33"}]
-
RE: Pathfinder flee going through structures
@mrfaul Thanks for the suggestion. Seems to work in simulation.
Further reading of the documentation at
Pathfinder.CostMatrix
does state that pathfinder only considers terrain data when finding a path. That should be further emphasized inPathfinder
docs. Reading of the sample code given at the side does show it generating a cost matrix and marking all structures as0xff
.Proposed solution:
Introduce flee tocreep.moveTo
OR
make all structures untraversable in the default costmatrix OR
just make the documentation clear on that part. -
Pathfinder flee going through structures
I have the following code
//If there is literally no more construction targets, Hide somewhere away from everything if (!target) { var path = PathFinder.search(creep.pos, creep.room.find(FIND_STRUCTURES).map(s => {return{pos:s.pos, range:5}}) , {flee:true, ignoreRoads: false} ).path creep.moveByPath(path) creep.room.drawPath(path) // My own function to visualize the path return; }
I get the following result
Am I doing something wrong? Why is it pathing through solid structures?