Conversation
sswadkar
reviewed
Apr 28, 2025
|
|
||
| val newNode = Node(currentNode, grid[newY][newX]) | ||
| newNode.g = currentNode.g + 1 | ||
| newNode.h = |
Member
There was a problem hiding this comment.
manhattan distance might be a better heuristic to use here
sswadkar
reviewed
Apr 28, 2025
| ) { // Keep running until all the nodes are visited. In that case, no optimal path is | ||
| // found. | ||
| currentNode = | ||
| openList.minByOrNull { it.f } ?: openList.last() // Find the node with the lowest cost. |
Member
There was a problem hiding this comment.
your openList should be a priority queue supported by a minheap -- will notice a performance difference for larger open lists
sswadkar
reviewed
Apr 28, 2025
| newNode.f = newNode.g + newNode.h | ||
|
|
||
| // Discard node if it means going over the charge station. | ||
| if ((newNode.position.x - currentNode.position.x).absoluteValue.inMeters >= 10) { |
Member
There was a problem hiding this comment.
old game so understandable but i think you want to construct your graph so that this isn't even a possibility. think about an actual graph, it can only follow edges that exist, an edge that goes over the charge station shouldn't exist
sswadkar
requested changes
Apr 28, 2025
|
|
||
| import org.team4099.lib.geometry.Pose2d | ||
| import org.team4099.lib.units.base.inMeters | ||
| import kotlin.math.pow |
Member
There was a problem hiding this comment.
does our value class not have a pow function?
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.
Uses a starting position and ending position (Pose2d objects) with a grid given (a 2D list of Pose2d objects) to find the most optimal path between the starting position and the ending position.