Skip to content

DannyDaniel-03/A-star-grid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Grid A* Visualizer

A Java Swing application that visualizes and interacts with an Oracle PL/SQL implementation of the A* pathfinding algorithm on a configurable NxM grid.

Repository Structure

/ # Project root ├── pom.xml # Maven configuration ├── README.md # This file ├── src │ └── main │ └── java │ └── com/example/ │ └── GridAStarGUI.java # Main Swing GUI class └── db ├── sequencesDDL.sql # Sequences for GRID_NODE, GRID_EDGE, GRID_PATH_LOG ├── GridNodeDDL.sql # GRID_NODE table and triggers ├── GridEdgeDDL.sql # GRID_EDGE table and triggers ├── GridPathLogDDL.sql # GRID_PATH_LOG table and triggers ├── GridResultPathDDL.sql # GRID_RESULT_PATH table ├── PopulationScript.sql # Script to populate and reset the grid ├── Triggers.sql # Compound trigger for obstacle changes └── AStarSearch.sql # ASTAR_SEARCH procedure (raises when no path)

Prerequisites:

Java 11 or higher Maven 3.6 or higher Oracle Database XE (or equivalent) with: PL/SQL objects compiled (use the scripts under sql/) A pluggable database service (for example, XEPDB1) Oracle JDBC Driver (ojdbc8.jar) installed via Maven or local repository installation

Database Setup:

Connect as your application schema (for example, GRID_APP_USER). Run the SQL scripts in the following order:

@sql/sequencesDDL.sql @sql/GridNodeDDL.sql @sql/GridEdgeDDL.sql @sql/GridPathLogDDL.sql @sql/GridResultPathDDL.sql @sql/Triggers.sql @sql/PopulationScript.sql @sql/AStarSearch.sql

Verify that tables, triggers, and the procedure compile without errors.

The PopulationScript.sql defines the grid dimensions via the constants NUM_ROWS and NUM_COLS. You can adjust these values (for example, to create a 20×30 grid) by modifying NUM_ROWS and NUM_COLS and rerunning the script. Grid sizes from 10 to 100 in each dimension are supported.

Configuration

Maven Dependency (in pom.xml):

com.oracle.database.jdbc ojdbc8 19.3.0.0 compile

In GridAStarGUI.java, set:

private static final String JDBC_URL = "jdbc:oracle:thin:@localhost:1521/XEPDB1"; private static final String DB_USER = "GRID_APP_USER"; private static final String DB_PWD = "your_password_here";

Build and Run Reload Maven in your IDE to download dependencies.

Compile the project with:

mvn compile Run the application by executing the main method in GridAStarGUI.java.

Usage

Use the zoom slider to adjust cell size between 10 and 80 pixels. Select Set Start or Set End, then click a cell to mark the start (green) or end (red). Only one start and end are allowed at a time. Select Toggle Obstacle. Click and hold on a cell to toggle its obstacle state (black for obstacle, white for free) and drag to apply to multiple cells. Click Run A* to execute the pathfinding: If a path exists, the sequence of cells will be highlighted in cyan. If no path exists, a pop-up dialog will display "No path found." The application detects this via the PL/SQL procedure raising an application error. Grid Size Configuration The grid size is defined in the PopulationScript.sql by the variables:

NUM_ROWS CONSTANT PLS_INTEGER := <number_of_rows>; NUM_COLS CONSTANT PLS_INTEGER := <number_of_columns>;

Adjust these values and rerun the population script to change the grid dimensions. The Java GUI automatically detects and displays the updated grid size on startup.

Troubleshooting

If you receive mutating-table errors, ensure Triggers.sql contains the compound trigger TRG_NODE_OBSTACLE_CHANGE. For database connection issues, verify your JDBC URL, user, and password, and confirm the Oracle listener is running.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors