bencbartlett / Overmind

AI for Screeps, a multiplayer programming strategy game
MIT License
554 stars 159 forks source link

Scouts stuck when there is no way to pass a room #150

Open ykozxy opened 5 years ago

ykozxy commented 5 years ago

Issue summary

Description of issue:

When scouts try to pass a room that is impassable due to obstacles, they would be stuck and hang around at the same place. Probably due to continuously recomputing the path, CPU usage skyrockets about 25% (shard 3) during the process and eventually consumes all the bucket. (I have to kill the scouts to prevent this manually)

Steps to reproduce:

The room replay: https://screeps.com/a/#!/history/shard3/E17S38?t=8174724

The issue occurs on the upper left corner of the room when the creep cannot move to the exit at the lower right of the room

Snipaste_2019-06-30_10-39-27

Error message:

// Console output:
// Offending line:

Suggested fix (optional):

Maybe scout should stop recomputing the path and exit the room (or stand still) once it finds it cannot pass the room

Other information:

PDS-West commented 5 years ago

i had the same error, when i set the log level to 4 i got this: [1:51:39 AM][shard3]DEBUG 12288587 Movement: incomplete path for [scout_4]! ([E7N19, 43, 4] ⟶ [E8N20, 25, 25]) [1:51:41 AM][shard3]DEBUG 12288588 Movement: incomplete path for [scout_0]! ([E7N19, 45, 5] ⟶ [E8N20, 25, 25])

scout error

tamyiuchau commented 4 years ago

I have bisected the problem to https://github.com/bencbartlett/Overmind/blob/5eca49a0d988a1f810a11b9c73d4d8961efca889/src/overlords/scouting/randomWalker.ts#L43 which it tries to travel to a room where no path could be found. dirty hack fix this issue(temporary), but it breaks the assumption of 2D random walk, so it might not drift away from origin and have probability to reach anywhere

            if (Game.map.isRoomAvailable(roomName) && scout.room.findExitTo(roomName)>0b&& scout.creep.moveTo(new RoomPosition(25, 20, roomName))>=0,{maxOps:100}) {

p.s. it also solve high cpu usage of scouts when no path is find