Giter Site home page Giter Site logo

enpm661-project1's Introduction

ENPM661-Project1

8-Puzzle Solver:

The included code has a solver for the 8-puzzle game. The game is setup as a 3x3 grid like the one below:

-------------
| 1 | 2 | 3 | 
-------------
| 8 |   | 4 | 
-------------
| 7 | 6 | 5 | 
-------------

Tiles can be moved into the blank space.

The code uses a BFS (Breadth First Search) Algorithm to solve for the necessary path to reach the goal state from the desired starting state.

How to Use the Code

Game Mode

Clone or download the repository. In terminal navigate to the directory and run:

python3 main.py

The default mode is game mode. This will allow the user to input a start configuration and goal configuration. If a path exists the code will output the steps to reach the goal.

Please input both the start and goal in column notation

For the board above the notation would be: 1,8,7,2,0,6,3,4,5

Random Mode

You can also run the game in random mode. To do this open main.py in a text editor and change lines 5 and 6 to:

game_mode = False
random_mode = True

Running main.py in this mode will generate a random starting board and find a solution if possible.

Code-Input Mode

This is the last possible mode. For this mode change lines 5,6 and 7 to:

game_mode = False
random_mode = False
input_from_code = True

This will allow you to input the start node and goal node on lines 16 and 17. Running main.py will print the path to solve your inputed configuration if possible.

Dependencies

The code requires the following modules:

numpy
deque from collections
random

enpm661-project1's People

Contributors

jaybrecht avatar

Watchers

 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.