Pathfinding improvements #42
Open
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.
Bug fixes
This PR lists a couple of improvements to the getBlock() function in Pathfinding which is intended to return the WalkableBlock at a specific position.
Bug 1
The Gooeys in MR are never actually able to calculate the path to target (Behavior returns path.INVALID) because the system is unable to locate the WalkableBlock where the gooey are present. I speculate the reason is that the heights of the Gooeys are really low and since in the original implementation of the getBlock(), it only checks all the blocks below the current pos (upto a depth of 4), it starts off underground and is never able to find a WalkableBlock. That is why, I have added the
pos+=2to ensure that it starts off a little higher.Bug 2
Imagine a Gooey standing at the edge of a block that is at a height 2 (the ground is at height 0). If the gooey walked to the edge, then even if most of the gooey is actually not on the edge block at height 2, the gooey would still be at a height 2. Hence if we don't find a block at the current pos, it becomes important to check the surroundings.