Giter Club home page Giter Club logo

maze-solver's Introduction

Maze Solver

A program to solve simple mazes. The mazes are given in a file and the program must read in the file, solve the maze, and output the solution.

Table of Contents

  1. Running The Application
  2. Maze Input/Output Formats
  3. Maze Input Format
  4. Maze Output Format
  5. Movement
  6. Horizontal Wrapping
  7. Vertical Wrapping

Running The Application

In order to run the application either build it at the command line using: mvn clean compile package

or, download the compiled application from the releases page.

Once you have the maze-solver-1.0-RELEASE.jar, run it from a command window using: java -jar maze-solver-1.0-RELEASE.jar

Follow the on-screen instructions once the application is running.

Maze Input/Output Formats

Input Format

A plain-text file where:

  • 1 - denotes walls
  • 0 - denotes passageways

The file is laid out like so:

<WIDTH> <HEIGHT><CR>
<START_X> <START_Y><CR>
<END_X> <END_Y><CR>
... grid of 0's and 1's

Example

A 10x10 grid with starting coordinates (1,1), and ending coordinates (8,8).

10 10
1 1
8 8
1 1 1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 0 0 1
1 0 1 0 1 1 1 1 1 1
1 0 1 0 0 0 0 0 0 1
1 0 1 1 0 1 0 1 1 1
1 0 1 0 0 1 0 1 0 1
1 0 1 0 0 0 0 0 0 1
1 0 1 1 1 0 1 1 1 1
1 0 1 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1 1

Output Format

The output is a representation of the maze with a marked path from start to end where:

  • # - denotes a wall
  • whitespace - denotes a passageway
  • X - denotes the path
  • S - denotes the start
  • E - denotes the end

Example

The solution to the 10x10 grid example.

##########
#SXX     #
# #X######
# #XX    #
# ##X# ###
# # X# # #
# # XX   #
# ###X####
# #  XXXE#
##########

Movement

Valid moves are N, S, E, W only, with no diagonal movement allowed. Moves in any of these directions will be blocked by maze walls, which are identified as 1's in the input file. The edges of the grid should not be considered as walls unless specified, and allow for wrapping movement.

Wrapping Example

Horizontal

Input

10 10
1 1
8 8
1 1 1 1 1 1 1 1 1 1 
0 0 1 0 0 0 0 0 0 0 
0 0 1 0 0 1 1 1 1 1 
1 0 1 0 0 0 0 0 0 1 
1 0 1 1 0 1 0 1 1 1 
1 0 1 0 0 1 0 1 0 1 
1 0 1 0 0 0 0 0 0 1 
1 0 1 0 0 0 1 1 1 1 
1 0 1 0 0 0 0 0 0 1 
1 1 1 1 1 1 1 1 1 1 
Output
##########
XS# XXXXXX
  # X#####
# # X    #
# ##X# ###
# # X# # #
# # X    #
# # X ####
# # XXXXE#
##########

Vertical

Input
10 10
1 1
8 8
1 0 1 1 1 1 1 1 1 1 
1 0 1 0 0 0 0 0 0 0 
1 0 1 0 1 1 1 1 1 1 
1 1 1 0 0 0 0 0 0 1 
1 0 1 1 0 1 0 1 1 1 
1 0 1 0 0 1 0 1 0 1 
1 0 1 0 0 0 0 0 0 1 
1 0 1 1 1 0 1 1 1 1 
1 0 0 0 0 0 0 0 0 1 
1 0 1 1 1 1 1 1 1 1 
Output
#X########
#S#       
# # ######
###      #
# ## # ###
# #  # # #
# #      #
# ### ####
#XXXXXXXE#
#X########

maze-solver's People

Contributors

p-karanthaker avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.