This class is designed to solve a linked-list dictonary maze using the A* or Breadth-First algorithms. It takes a maze as input, represented as a dictionary where each key represents a room and the exits value is another dictionary that contains the exits of the room.
Project description
Linked-List Maze Solver
This python class provides an A* algorithm to solve linked list, represented as a dictonary, mazes. It can be used to find the shortest path between a start and end point in a maze.
The LinkedListMazeSolver class is optimized for readability and performance. It has been designed to work with mazes that contain linked list representations with no x,y,z coordinates.
Usage
from LinkedListMazeSolver import AStarMazeSolver, BFSMazeSolver
maze = {
"A": {"exit": {"n": "B", "e": "D", "w": "C", "ne": "G", "nw": "F"}},
"B": {"exit": {"s": "A"}},
"C": {"exit": {"e": "A"}},
"D": {"exit": {"w": "A", "ne": "G", "se": "H", "u": "K"}},
"E": {"exit": {"n": "F", "e": "H", "ne": "I"}},
"F": {"exit": {"s": "E", "ne": "G", "se": "C"}},
"G": {"exit": {"s": "A", "nw": "F", "sw": "E"}},
"H": {"exit": {"w": "D", "n": "I", "nw": "E"}},
"I": {"exit": {"s": "H", "sw": "D"}},
"J": {"exit": {"n": "K", "e": "L"}},
"K": {"exit": {"s": "J", "d": "D"}},
"L": {"exit": {"w": "J", "e": "M"}},
"M": {"exit": {"w": "L"}},
}
solver = AStarMazeSolver(maze, "A", "M")
result = solver.solve()
print(result)
solver = BFSMazeSolver(maze, "A", "M")
result = solver.solve()
print(result)
Output
e u s e e
e u s e e
Supported Maze Directions
This implementation was designed with a maze containing the following directions:
n, s, e, w, ne, nw, se, sw, u, d
However, you may define your own directions in your sample data.
Customization
If you need to customize the behavior of the BidirectionalAStarMazeSolver class, you can do so by subclassing the class and overriding its methods.
For example, if you want to use a different heuristic function, you can override the heuristic method:
class CustomMazeSolver(AStarMazeSolver):
def __heuristic__(self, curr, end, maze):
# Custom heuristic function
pass
Contributions
Contributions to the MazeSolver class are welcome! If you find a bug or want to suggest a new feature, please open an issue or submit a pull request on Github.
License
This implementation is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file LinkedListMazeSolver-1.0.0.tar.gz.
File metadata
- Download URL: LinkedListMazeSolver-1.0.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3e15adcbc182088b0d214fb46ff7178c17f65f7f9781c9b6785cdff1760d411
|
|
| MD5 |
ef15d94708f7b9587a2893f987ed4f3c
|
|
| BLAKE2b-256 |
46c739990959c9fd9ab45f897a31df2816fe7bb2a8d3bd0326b04bd0304efee0
|
File details
Details for the file LinkedListMazeSolver-1.0.0-py3-none-any.whl.
File metadata
- Download URL: LinkedListMazeSolver-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f2dddfc1d2361add5b49658137dc8872b4bd8929b0e47fc90ae80933bbecd5a
|
|
| MD5 |
7e75916d5ec33bfe92d0f3b2148d0ec9
|
|
| BLAKE2b-256 |
84cc9f882d07f80d8a9883c88dce2e79e5a3212dd48f67bf33c6a2b9a9971264
|