Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java Sewer Maze Pathfinder

This is a Java maze/pathfinding game project. The player controls a sewer diver who must first find a hidden ring, then escape the sewer before running out of steps while collecting as many coins as possible.

The project includes graph traversal, shortest-path search, a custom priority queue implementation, GUI assets, and JUnit tests for graph/data structure behavior.

Features

  • Maze-based exploration game
  • Two-phase objective:
    • seek the hidden ring
    • escape before steps run out while collecting coins
  • Graph-based maze representation
  • Shortest-path computation for weighted directed graphs
  • Custom priority queue interface and implementation
  • Pathfinding logic for safe exit routes
  • Coin collection strategy during escape
  • Optional graphical interface
  • Command-line options for seeds, repeated runs, and no-graphics mode
  • JUnit tests for shortest paths and priority queue behavior

Tech Stack

  • Java
  • Java Swing
  • JUnit 5

Project Structure

java-sewer-maze-pathfinder/
├── README.md
├── .gitignore
├── src/
│   ├── cms/
│   ├── datastructures/
│   ├── diver/
│   ├── game/
│   ├── graph/
│   └── gui/
├── tests/
│   └── graph/
└── res/

How to Run

Make sure Java is installed.

Compile the source files:

javac -d out $(find src -name "*.java")

Run the game:

java -cp out game.Main

By default, the game runs with the graphical interface enabled.

Run Without Graphics

To run in terminal/no-graphics mode:

java -cp out game.Main --nographics

Run With a Specific Seed

To run the game with a fixed random seed:

java -cp out game.Main -s 12345

This is useful for reproducing the same maze.

Run Multiple Games

To run multiple games in a row:

java -cp out game.Main -n 10 --nographics

This prints the average score across multiple runs.

Command-Line Options

--help          Show usage information
--nographics    Run without the graphical interface
-s <seed>       Run with a specific random seed
-n <runs>       Run multiple games

Example Commands

java -cp out game.Main
java -cp out game.Main --nographics
java -cp out game.Main -s 12345
java -cp out game.Main -n 10 --nographics

Main Implementation

The main player strategy is implemented in:

src/diver/McDiver.java

This class implements the SewerDiver interface and defines behavior for both phases of the game:

  • seek: explores the maze to find the ring
  • scram: escapes the sewer while trying to collect coins

The shortest-path logic is implemented in:

src/graph/ShortestPaths.java

The priority queue implementation is in:

src/datastructures/SlowPQueue.java

Tests

This project includes JUnit tests in:

tests/graph/

The tests cover:

  • priority queue behavior
  • shortest-path computation
  • graph path reconstruction

If using IntelliJ, mark src/ as the source root and tests/ as the test root, then run the test classes in tests/graph/.

My Contributions

This project was completed as part of Cornell University CS 2110.

The course staff provided the overall project framework, including the game engine, GUI, maze representation, resource files, interfaces, and much of the surrounding support code.

My main implementation work focused on the pathfinding and algorithmic components, including:

  • implementing the pathfinding logic used by the sewer diver
  • writing the seek strategy to locate the hidden ring
  • writing the scram strategy to escape before running out of steps
  • using graph traversal to explore the maze
  • using shortest-path logic to plan safe routes
  • using priority queue behavior for pathfinding support
  • reasoning about when to collect coins versus when to prioritize reaching the exit

The main file containing my work is:

src/diver/McDiver.java

The rest of the project structure was provided as assignment scaffolding by Cornell University, CS2110.

About

Java maze/pathfinding game with graph traversal, shortest-path search, priority queues, GUI assets, and JUnit tests.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages