Search-Visualization is a framework that can be used to implement and visualize AI algorithms. The Search-Visualization uses two perspectives to represent the algorithmic behavior. On the left hand side a search tree is drawn that shows which search node was expanded by the algorithm. On the right hand side the problem with a representation of the state is shown. AI algorithms and search threads are independent of each other. The visualization is done via an entity component system.
- Provides Classes for AI and search algorithms
- Representation and implementation of two games for AI to work with
- Construction and representation of search trees according to the algorithm data structure
- GUI with control elements for visualization control
- Administrators can view all pictures on one page with the user inserted data
- Pausing and resuming algorithms
- Java16
- JavaFX 17.0.0.1
- Install Java16
- Install JDK
- Install an IDE (e.g. eclipse)
- Install JavaFX libary into IDE
- Import src folder into your IDE
- Run the
Main.java
class in theapplication
package
You should see the following:
Select a problem and a search-algorithm and press the START-Button. Press the STEP-Button to proceed the visualization. Picture 2: Depth first search
Navigate to the ai_algorithm
package inside go to search
create a new class with your own algorithm name e.g. DepthFirstSearchExplored
.
Picture 3: Package organization
package ai_algorithm.search;
import ai_algorithm.ExploredSet;
import ai_algorithm.Frontier;
import ai_algorithm.Path;
import ai_algorithm.SearchNode;
import ai_algorithm.problems.State;
import application.debugger.Debugger;
public class DepthFirstSearchExplored extends SearchAlgorithm {
@Override
public Path search() {
SearchNode start = new SearchNode(null, problem.getInitialState(), 0, null);
Frontier frontier = new Frontier();
ExploredSet explored = new ExploredSet();
explored.add(start);
Debugger.pause();
if (this.problem.isGoalState(start.getState())) {
return start.getPath();
}
frontier.add(start);
Debugger.pause();
while (!frontier.isEmpty()) {
SearchNode node = frontier.removeLast();
Debugger.pause();
System.out.println(node);
for (SearchNode child : node.expand()) {
State state = child.getState();
if (problem.isGoalState(state)) {
Debugger.pause("Finished");
return child.getPath();
}
if (!explored.contains(state)) {
Debugger.pause();
explored.add(child);
frontier.add(child);
}
}
}
return null;
}
}
As a last step you have to announce your algorithm to the framework by adding the algorithms name to the algorithm SearchAndProblemRegister
.
public class SearchAndProblemRegister {
...
public static String[] searchAlgorithms = { //
DepthFirstSearch.class.getName(), //
DepthFirstSearchExplored.class.getName(), //
RecursiveDepthSearch.class.getName(), //
BreadthFirstSearch.class.getName(), // <<<your new algorithm
BidirectionalBreadthFirstSearch.class.getName(), //
ManualSearch.class.getName()//
};
...
}
Start the framework and select your new algorithm. The result of the algorithm is shown in picture 2.
Like many Game Engines the Search-Visualization framework is based on an Entity-Component-Sytem. Therefore it uses Game-Objects to represent all Objects that are part of a search algorithm. The components can be give to a Game-Object to add functionality. Picture 3: Components are assigned to Game-Objects
The visualization is seperated into two threads the Search-Thread and the Visualization-Thread. The connecting element between them are visitors that are managed by the Game-Object-Registry to be applied on the Game-Objects. Picture 4: Broad architecture of the framework
For more information on this topic read the full documentation: full java doc.
Here are some pictures generated by the Search-Visualization:
- FIX: Sliding Tile Problem Visitors
- FIX: Overlapping search nodes in some trees
- CHANGE: CSS Theme
- CHANGE: Userinterface
- ADD: More problems/games
- ADD: More search algorithms