Recompute the path instantly while dragging start/target#26
Open
Stephan-342B wants to merge 3 commits into
Open
Recompute the path instantly while dragging start/target#26Stephan-342B wants to merge 3 commits into
Stephan-342B wants to merge 3 commits into
Conversation
After a run has finished, dragging the start or target node now recomputes and repaints the visited cells + shortest path live as the node moves — and on drop — matching the original. No animation/arrow during the recompute (that would be unusable mid-drag); the search runs synchronously and paints final colours. - GridService: `pathDisplayed` gate (the original's "algoDone", set on run completion, cleared on clear/maze) and `recomputeInstant(start, target)` that reruns A* with the dragged endpoint overridden and paints instantly. - GridStepRenderer: "arrowless" mode — colour cells to their final state with no travelling arrow, CURRENT collapsed to VISITED, special nodes left untouched. - GridSnapshot.of(grid, start, target): snapshot with explicit endpoints so the path can be previewed before the move is committed. - NodeAnimations.visitedInstant: fill a visited cell cyan with no pulse. - CellEventHandler: emit a preview callback on DRAG_OVER while dragging a special node, and a finished callback on drop. - MainWindowController: suppress reveals during the instant repaint; wire the live preview (throttled to cell changes) and the drop finalize (also corrects a stale preview when a drop is invalid). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Follow-up to the instant-recompute feature: - Visited cells stayed white during the drag recompute: the programmatic cyan fill was wiped by the CSS pass triggered by the :visited pseudo-class (base .cell is transparent). Give :visited its cyan in CSS so it persists on its own; the animated reveal keeps growing "from nothing" via a temporary "revealing" class that holds the cell transparent until the tile finishes. - The recompute called the full grid.clear() every frame, which is meant for the Clear buttons — it reset the target's icon via getChildren().get(0) and stripped the start's style, which made the target icon vanish on drop and churned the special nodes. Add Grid.clearSearchFlags() (flags only, no icon/ style/position changes) and use it for the instant recompute. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Match the original for start/target during the instant recompute: - The path endpoints (start/target cells) now turn yellow too instead of being left blank, so the non-dragged node is always yellow. The arrowless renderer colours PATH on special nodes (keeping their icon); visited/wall stay off the endpoints. - On drop, the dropped endpoint plays a reveal from a rounded square to a full yellow square (NodeAnimations.pathReveal), like the original's cell animation. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Feature
Matches the original: once a pathfinding run has finished, dragging the start or target node recomputes the visited cells + shortest path live as the node moves over the grid (and on drop). No re-clicking Visualize needed.
Behaviour
pathDisplayed, the original'salgoDone). Cleared by any Clear action or maze generation.How
pathDisplayedflag +recomputeInstant(start, target)— reruns A* with the dragged endpoint overridden and paints instantly.CURRENT→VISITED, special nodes left untouched.DRAG_OVERpreview callback + drop finalize callback.Testing
mvn testgreen (5);mvn compilegreen.🤖 Generated with Claude Code