maze-generator-and-solver


Namemaze-generator-and-solver JSON
Version 0.0.7 PyPI version JSON
download
home_page
SummaryGenerate maze using randomized DFS and Solve it using Path Finding algorithms
upload_time2022-12-10 05:42:10
maintainer
docs_urlNone
author
requires_python>=3.7
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Maze Generation & Solving
Generate/Solve Maze of any dimension using DFS and search algorithms like, Dijkstra, etc.


## Features
- Create maze of different sizes.
- Solve maze using path finding algorithm like Dijkstra(adding more later).


## Usage
This module provides 2 functions, create(...) and search(...). Both of these functions require some parameter that needs to be given by the user.
s start by ng the module, depending on what kind of project it is:
```py
import importlib
mgs = importlib.import_module("maze-generator-and-solver.main")
```

### Generate/Create a maze
There are 2 ways of using the create(...) function to generate a maze, both of them return same structure so you can use either of them as per the need.
```py
#definition:
create(width=3, height=3, cellSize=1) # width (default: 3), height (default: 3), cellsize (default: 1)
```

- The create(...) function returns 2 structure, one is a simple 1D Array and the other one is a custom Graph structure.
  - The array contains maze/grid index in the order they should be visited (including bactracked indexes). This is useful if you want to create some kind of animation to create a maze.
  - The Graph, as the name suggest, will return an object that has a Map object(adjList). This Map object maps all the index connected to each other.

NOTE: create(...) use randomized DFS, so a (3x3) maze created on your system might return some different values.
```py
#use:
maze = create(3, 3) # to create a maze of (3 x 3) grid
maze = create(90, 90, 30) # to create a maze of (3 x 3) grid
print(maze)
''' output of both the function call will be similar to this:
  {
    "mazeArr": [0,3,6,7,8,5,2,1,4,1,2,5,8,7,6,3,0],
    "mazeGraph": {
        "v": 9,
        "AdjList": {},
        "length": 9
    }
  }
'''

maze = create(3, 5) # to create a maze of (3 x 5) grid
maze = create(90, 150, 30) # to create a maze of (3 x 5) grid
print(maze)
''' output of both the function call will similar to this
  {
    "mazeArr": [0,3,4,7,6,9,12,13,10,11,14,11,8,5,2,1,2,5,8,11,10,13,12,9,6,7,4,3,0],
    "mazeGraph": {
        "v": 15,
        "AdjList": {},
        "length": 15
    }
  }
'''

# all these functions return the same structures, an array and a Graph object
```
click <a href="#example">here</a> or scroll down to get a better understanding with the help of an example

### Solve the maze
To search/solve the maze use the search(...) function,
```py
#definition:
search(graph, root, target, searchAlgoId=1)
''' graph: the graph object returned by 'create(...) function', root: starting index,
 target: ending index, searchAlgoId: the id the search algorithm being used (default: 1[dijkstra]) '''
```

- The search(...) function returns a custom Stack object, it contains the array(stackArray) that will provide the solution / path to take from root(0) to target(8).
```py
#use:
# 'maze' was defined above when create function was called
path = mgs.search(maze["mazeGraph"], 0, maze["mazeGraph"].v-1) # retuns a stack object that contains the solution/path
print(path)
'''
output of a 3x3 maze will be similar to:
[0,1,4,7,8]
output of a 3x5 maze will be similar to:
[0,3,6,7,8,11,14]
'''
```
click <a href="#example">here</a> or scroll down to get a better understanding with the help of an example

#### Search Algorithm IDs
<table>
  <tr>
    <th>Algorithm ID</th>
    <th>Search Algorithm</th>
  </tr>
  <tr>
    <td>1</td>
    <td>Dijkstra</td>
  </tr>
</table>
More algorithms will be added soon ;P


## Example
Taking this (3x3)maze as an example. on the left(unsolved) and on the right, you can see it is solved.
<img alt="maze" src="https:#github.com/0-harshit-0/maze/blob/b3db9ca4a223457e2abaa2037a0676aaf55486b8/assets/maze-npm.png?raw=true" />

NOTE: create(...) use randomized DFS, so a (3x3) maze created on your system might return some different values.

create:
```py
maze = mgs.create(3, 3)
print(maze["mazeArray"])
# mazeArray: [0,1,4,5,8,7,6,3,6,7,8,5,2,5,4,1,0]
```
search: 
```py
path = mgs.search(maze.mazeGraph, 0, maze.mazeGraph.v-1)
print(path["stackArray"])
#stackArray: [0,1,4,5,8]
```

That's it, you are ready to create and solve maze :smile:. You can play with a working maze generator/solver (using py) at https:#0-harshit-0.github.io/maze

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "maze-generator-and-solver",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "",
    "author_email": "Harshit <harshitw3b@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/88/cc/7415ccaeeaf50feb42b4cf0abe01f3368c6c612e915c3b35dcfefc256e04/maze_generator_and_solver-0.0.7.tar.gz",
    "platform": null,
    "description": "# Maze Generation & Solving\nGenerate/Solve Maze of any dimension using DFS and search algorithms like, Dijkstra, etc.\n\n\n## Features\n- Create maze of different sizes.\n- Solve maze using path finding algorithm like Dijkstra(adding more later).\n\n\n## Usage\nThis module provides 2 functions, create(...) and search(...). Both of these functions require some parameter that needs to be given by the user.\ns start by ng the module, depending on what kind of project it is:\n```py\nimport importlib\nmgs = importlib.import_module(\"maze-generator-and-solver.main\")\n```\n\n### Generate/Create a maze\nThere are 2 ways of using the create(...) function to generate a maze, both of them return same structure so you can use either of them as per the need.\n```py\n#definition:\ncreate(width=3, height=3, cellSize=1) # width (default: 3), height (default: 3), cellsize (default: 1)\n```\n\n- The create(...) function returns 2 structure, one is a simple 1D Array and the other one is a custom Graph structure.\n  - The array contains maze/grid index in the order they should be visited (including bactracked indexes). This is useful if you want to create some kind of animation to create a maze.\n  - The Graph, as the name suggest, will return an object that has a Map object(adjList). This Map object maps all the index connected to each other.\n\nNOTE: create(...) use randomized DFS, so a (3x3) maze created on your system might return some different values.\n```py\n#use:\nmaze = create(3, 3) # to create a maze of (3 x 3) grid\nmaze = create(90, 90, 30) # to create a maze of (3 x 3) grid\nprint(maze)\n''' output of both the function call will be similar to this:\n  {\n    \"mazeArr\": [0,3,6,7,8,5,2,1,4,1,2,5,8,7,6,3,0],\n    \"mazeGraph\": {\n        \"v\": 9,\n        \"AdjList\": {},\n        \"length\": 9\n    }\n  }\n'''\n\nmaze = create(3, 5) # to create a maze of (3 x 5) grid\nmaze = create(90, 150, 30) # to create a maze of (3 x 5) grid\nprint(maze)\n''' output of both the function call will similar to this\n  {\n    \"mazeArr\": [0,3,4,7,6,9,12,13,10,11,14,11,8,5,2,1,2,5,8,11,10,13,12,9,6,7,4,3,0],\n    \"mazeGraph\": {\n        \"v\": 15,\n        \"AdjList\": {},\n        \"length\": 15\n    }\n  }\n'''\n\n# all these functions return the same structures, an array and a Graph object\n```\nclick <a href=\"#example\">here</a> or scroll down to get a better understanding with the help of an example\n\n### Solve the maze\nTo search/solve the maze use the search(...) function,\n```py\n#definition:\nsearch(graph, root, target, searchAlgoId=1)\n''' graph: the graph object returned by 'create(...) function', root: starting index,\n target: ending index, searchAlgoId: the id the search algorithm being used (default: 1[dijkstra]) '''\n```\n\n- The search(...) function returns a custom Stack object, it contains the array(stackArray) that will provide the solution / path to take from root(0) to target(8).\n```py\n#use:\n# 'maze' was defined above when create function was called\npath = mgs.search(maze[\"mazeGraph\"], 0, maze[\"mazeGraph\"].v-1) # retuns a stack object that contains the solution/path\nprint(path)\n'''\noutput of a 3x3 maze will be similar to:\n[0,1,4,7,8]\noutput of a 3x5 maze will be similar to:\n[0,3,6,7,8,11,14]\n'''\n```\nclick <a href=\"#example\">here</a> or scroll down to get a better understanding with the help of an example\n\n#### Search Algorithm IDs\n<table>\n  <tr>\n    <th>Algorithm ID</th>\n    <th>Search Algorithm</th>\n  </tr>\n  <tr>\n    <td>1</td>\n    <td>Dijkstra</td>\n  </tr>\n</table>\nMore algorithms will be added soon ;P\n\n\n## Example\nTaking this (3x3)maze as an example. on the left(unsolved) and on the right, you can see it is solved.\n<img alt=\"maze\" src=\"https:#github.com/0-harshit-0/maze/blob/b3db9ca4a223457e2abaa2037a0676aaf55486b8/assets/maze-npm.png?raw=true\" />\n\nNOTE: create(...) use randomized DFS, so a (3x3) maze created on your system might return some different values.\n\ncreate:\n```py\nmaze = mgs.create(3, 3)\nprint(maze[\"mazeArray\"])\n# mazeArray: [0,1,4,5,8,7,6,3,6,7,8,5,2,5,4,1,0]\n```\nsearch: \n```py\npath = mgs.search(maze.mazeGraph, 0, maze.mazeGraph.v-1)\nprint(path[\"stackArray\"])\n#stackArray: [0,1,4,5,8]\n```\n\nThat's it, you are ready to create and solve maze :smile:. You can play with a working maze generator/solver (using py) at https:#0-harshit-0.github.io/maze\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Generate maze using randomized DFS and Solve it using Path Finding algorithms",
    "version": "0.0.7",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "4f4af475f2c091e4dabeda422c8ab946",
                "sha256": "09d22b181c8cf754540964df613dc624c7dd8f1a42f2d210b4e5b6ac8b7a0b52"
            },
            "downloads": -1,
            "filename": "maze_generator_and_solver-0.0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4f4af475f2c091e4dabeda422c8ab946",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 17443,
            "upload_time": "2022-12-10T05:42:08",
            "upload_time_iso_8601": "2022-12-10T05:42:08.007985Z",
            "url": "https://files.pythonhosted.org/packages/36/8c/aa29f3990f7936670cb8caa1822a65505849cc7987992532de189a8fb4e3/maze_generator_and_solver-0.0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "86589976fe79753d4d33c211591189f2",
                "sha256": "444dd1ff22eb81f674e06bdcf30c98d4ac91eb008a1f5714ff3b03fcf8b105ab"
            },
            "downloads": -1,
            "filename": "maze_generator_and_solver-0.0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "86589976fe79753d4d33c211591189f2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 16754,
            "upload_time": "2022-12-10T05:42:10",
            "upload_time_iso_8601": "2022-12-10T05:42:10.142988Z",
            "url": "https://files.pythonhosted.org/packages/88/cc/7415ccaeeaf50feb42b4cf0abe01f3368c6c612e915c3b35dcfefc256e04/maze_generator_and_solver-0.0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-10 05:42:10",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "maze-generator-and-solver"
}
        
Elapsed time: 0.02004s