public class Amazed
extends java.lang.Object
Amazed is a simple application class that applies a
solver to a maze.
This class supports sequential solvers of class
SequentialSolver and fork/join solvers of class
ForkJoinSolver. It runs both using the common pool of
java.util.concurrent.ForkJoinPool; thus, the solvers
must be a subtype of
RecursiveTask<List<Integer>>. After creating an
instance from a map file, the solving process is started by calling
method solve. After solve terminates, the
solution can be displayed by calling method
showSolution.
| Constructor and Description |
|---|
Amazed(java.lang.String map,
boolean sequentialSolver,
int forkAfter,
int animationDelay)
Creates a maze reading from map file
map. |
| Modifier and Type | Method and Description |
|---|---|
void |
showSolution()
Displays the solution by removing all players and marking a
path from the start node to a goal on the maze graphical
representation.
|
void |
solve()
Runs the solver on the maze, waits for termination, and prints
to screen the outcome of the search.
|
public Amazed(java.lang.String map,
boolean sequentialSolver,
int forkAfter,
int animationDelay)
map.map - the name of the map file describing the maze to be searchedsequentialSolver - if true, it uses
SequentialSolver to search the maze; otherwise it
uses ForkJoinSolverforkAfter - the number of steps (visited nodes) after
which a parallel task is forked; this value
is passed to the instance of the solver as
described in
ForkJoinSolver.ForkJoinSolver(Maze, int)animationDelay - milliseconds of pause between a step and
the next one in the animation of the
solution search; if
animationDelay <= 0
then there is no graphical animation
and no spurious delays; if
animationDelay < 0 then
there is no graphical display at allpublic void solve()
public void showSolution()