Support for returning false by costCallback option of Room.findPath.#113
Open
xilexio wants to merge 1 commit intoscreeps:masterfrom
Open
Support for returning false by costCallback option of Room.findPath.#113xilexio wants to merge 1 commit intoscreeps:masterfrom
xilexio wants to merge 1 commit intoscreeps:masterfrom
Conversation
|
I have wasted so many hours trying to get my creeps just to avoid one room. I've tried costCallback in Room.findPath. I've tried roomCallback in Pathfinder.search. I've tried just using Game.map.findRoute and given up on resolving the room contents from a distance. I've made sure of room visibility. No matter the method, creeps keep pathfinding directly into rooms I've tried to explicitly avoid. These three lines of code would have been helpful. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently
roomCallbackinPathFinder.searchhas an option to return false instead of cost matrix to efficiently avoid the room entirely. There is no easy way to do that fromCreep.moveToefficiently, since it would require replacingroomCallbackin_findPath2. One could usePathFinderdirectly, but that results in losing much ofCreep.moveToutility such as path caching, at least without knowledge ofmoveTointernals such as_move.roomCallbackcreates the cost matrix and passes it tocostCallbackto modify it. WhencostCallbackreturns something else, it is ignored. No exception or anything. I propose that at least whencostCallbackreturnsfalse, it should be treated as ifroomCallbackreturned false. This isn't as efficient as coding customroomCallback, since the cost matrix is still created, but at least it is fully compatible with existing code and will not require the player to code all functionality betweenCreeps.moveToandRoom.findPathif they just want to avoid certain rooms, e.g., rooms owned enemies.