-
Notifications
You must be signed in to change notification settings - Fork 0
A* algorithm solver #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| val newNode = Node(currentNode, grid[newY][newX]) | ||
| newNode.g = currentNode.g + 1 | ||
| newNode.h = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
manhattan distance might be a better heuristic to use here
| ) { // 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
your openList should be a priority queue supported by a minheap -- will notice a performance difference for larger open lists
| 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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
|
|
||
| import org.team4099.lib.geometry.Pose2d | ||
| import org.team4099.lib.units.base.inMeters | ||
| import kotlin.math.pow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does our value class not have a pow function?
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.