Giter VIP home page Giter VIP logo

pynpuzzle's Introduction

pynpuzzle is an application that helps you to solve n-puzzle problem and also to test your algorithms for n-puzzle problem. It is written in Python and uses tkinter for it's graphical interface.

pynpuzzle screenshot

NOTE: This project is not actively maintained and you may encounter some issues running it. One known issue is due to the psutil library's access denied issue on macOS. Feel free to send a pull request at anytime.

Installing

Prerequisites

Debian Linux (Ubuntu)

Open terminal and install these packages:

sudo apt-get install python3.5 python3-tk python3-psutil

Now you can run pynpuzzle from terminal: ./pynpuzzle

Windows

Download and install Python's installer (version 3.5 or higher) from it's official website. After installing python, open command line and install psutil package using pip: pip install psutil. Now you can run pynpuzzle.py from command line: python pynpuzzle.py.

Adding new algorithm

pynpuzzle loads algorithms from algorithms folder next to pynpuzzle.py.
All python files (.py) inside this folder (./algorithms/*.py) are considered as algorithms and pynpuzzle tries to load them.
An algorithm module should have a search function that accepts two arguments.
First argument is the n-puzzle's current state and the second one is the goal state.
Each of the arguments are two dimensional lists that represnt a n-puzzle. For example (test_algorithm.py):

def search(state, goal_state):
  """
  Test algorithm
  """
  pass

Docstring of the function will be presented as the name of the algorithm in app's algorithms combobox (if function has no docstring, module's filename will be used. test_algorithm in this case.).
And finally, function should return an m*n*n three dimensional list which represents a set of paths from state to goal_state.

Logs about algorithm's modules can be seen from menubar's Show logs item.

These algorithms are included in the app and can be used as code examples for adding new and more complex algorithms:

Author

Hamidreza Mahdavipanah

License

MIT

pynpuzzle's People

Contributors

mahdavipanah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.