Package mazealgo.viewmodel
Class MazeViewModel
java.lang.Object
mazealgo.viewmodel.MazeViewModel
Bridge between
MazeModel and the JavaFX View. Holds the full
UI-observable state (2D and 3D maze, current solution, player row /
column, victory flag, nodes-evaluated counter, visited states,
dimension mode, algorithm choice) and exposes commands (generate,
move, solve, visualize) that the controller calls in response to
user input.
Two dimensions:
- 2D mode — full gameplay; player navigates with WASD / arrows; Generate / Solution Hint can go through the embedded server when Best-First is selected (preserves the Phase 2 cache demo).
- 3D mode — visualization only (no player movement); the
3D displayer renders every layer side-by-side. Generate / Solve
/ Watch run in-process via
SearchableMaze3D(the server protocol is 2D only).
Three algorithm choices:
ALGO_BEST_FIRST(default) — A*-like with admissible heuristics; returns optimal path.ALGO_BFS— uninformed but optimal in number of edges.ALGO_DFS— finds some path, not the shortest.
-
Property Summary
PropertiesTypePropertyDescriptionjavafx.beans.property.ObjectProperty<String>javafx.beans.property.ObjectProperty<Maze3D>javafx.beans.property.ObjectProperty<Maze>javafx.beans.property.ObjectProperty<MazeViewModel.Mode>javafx.beans.property.ReadOnlyIntegerPropertyjavafx.beans.property.IntegerPropertyjavafx.beans.property.IntegerPropertyjavafx.beans.property.ObjectProperty<Solution>javafx.beans.property.BooleanPropertyjavafx.beans.property.ReadOnlyBooleanPropertyjavafx.beans.property.ReadOnlyBooleanProperty -
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionjavafx.beans.property.ObjectProperty<String>voidgenerate(int rows, int columns) voidgenerate3D(int depth, int rows, int columns) javafx.collections.ObservableSet<AState>javafx.beans.property.ObjectProperty<Maze3D>javafx.beans.property.ObjectProperty<Maze>javafx.beans.property.ObjectProperty<MazeViewModel.Mode>voidAttempts to move the player one cell in the given direction.javafx.beans.property.ReadOnlyIntegerPropertyjavafx.beans.property.IntegerPropertyjavafx.beans.property.IntegerPropertyjavafx.beans.property.ObjectProperty<Solution>voidSolves synchronously and shows the path.javafx.beans.property.BooleanPropertyjavafx.beans.property.ReadOnlyBooleanPropertyvoidRuns the selected algorithm on a daemon thread and feeds each visited state intovisitedStateson the JavaFX thread, with an adaptive per-cell delay so the animation always fits a bounded budget regardless of maze size.javafx.beans.property.ReadOnlyBooleanProperty
-
Property Details
-
mode
-
maze
-
maze3D
-
solution
-
playerRow
public javafx.beans.property.IntegerProperty playerRowProperty -
playerColumn
public javafx.beans.property.IntegerProperty playerColumnProperty -
solved
public javafx.beans.property.BooleanProperty solvedProperty -
victory
public javafx.beans.property.ReadOnlyBooleanProperty victoryProperty -
nodesEvaluated
public javafx.beans.property.ReadOnlyIntegerProperty nodesEvaluatedProperty -
visualizing
public javafx.beans.property.ReadOnlyBooleanProperty visualizingProperty -
algorithmChoice
-
-
Field Details
-
ALGO_BFS
- See Also:
-
ALGO_DFS
- See Also:
-
ALGO_BEST_FIRST
- See Also:
-
-
Constructor Details
-
MazeViewModel
-
-
Method Details
-
generate
public void generate(int rows, int columns) -
movePlayer
Attempts to move the player one cell in the given direction. No-op if the target cell is out of bounds, a wall, or — for diagonals — if both adjacent orthogonal cells around the corner are walls (the same pinhole ruleSearchableMazeenforces).3D mode is visualization-only; movePlayer is a no-op there.
-
generate3D
public void generate3D(int depth, int rows, int columns) -
solveCurrent
public void solveCurrent()Solves synchronously and shows the path. Used by the Solution Hint button.In 2D with Best-First, routes through
MazeModel.solve(Maze)— which in the running app means a socket roundtrip through the embedded SolveMazeStrategy + SHA-256 cache. Other algorithm choices and all 3D solves run in-process (the server protocol is 2D + Best-First only). -
visualizeSearchAsync
public void visualizeSearchAsync()Runs the selected algorithm on a daemon thread and feeds each visited state intovisitedStateson the JavaFX thread, with an adaptive per-cell delay so the animation always fits a bounded budget regardless of maze size. -
modeProperty
-
mazeProperty
-
maze3DProperty
-
solutionProperty
-
playerRowProperty
public javafx.beans.property.IntegerProperty playerRowProperty() -
playerColumnProperty
public javafx.beans.property.IntegerProperty playerColumnProperty() -
solvedProperty
public javafx.beans.property.BooleanProperty solvedProperty() -
victoryProperty
public javafx.beans.property.ReadOnlyBooleanProperty victoryProperty() -
nodesEvaluatedProperty
public javafx.beans.property.ReadOnlyIntegerProperty nodesEvaluatedProperty() -
visualizingProperty
public javafx.beans.property.ReadOnlyBooleanProperty visualizingProperty() -
getVisitedStates
-
algorithmChoiceProperty
-