Comparison between BFS and DFS in solving several real-world puzzle problems.
- Python 3.x
- Terminal (in Unix) OR PowerShell (in Windows)
Download source code
# Change to HOME directory $ cd ~ # Clone this repo and 'cd' into it $ git clone https://github.com/jellycsc/BFS-DFS-puzzle-solving.git $ cd BFS-DFS-puzzle-solving/
Image source: https://en.wikipedia.org/wiki/Sudoku
$ python3 sudoku_puzzle.py
Solving Peg solitaire
Image source: http://www.gibell.net/pegsolitaire/diagonal/index.html
$ python3 grid_peg_solitaire_puzzle.py
Solving MN puzzle (15-puzzle)
Image source: https://en.wikipedia.org/wiki/15_puzzle
$ python3 mn_puzzle.py
Solving Word ladder
$ python3 word_ladder_puzzle.py
Thoughts and future improvements
- BFS and DFS are both uninformed search algorithms. BFS is capable of finding shortest path solution but it's not memory efficient. In contrast, DFS uses a lot less memory, but it's not guaranteed to find a solution if the depth of the search tree is infinite.
- A* with clever heuristic will save your life.
- Pacman in Stanford CS221
Contributing to this project
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -m 'Add some feature')
- Push to your feature branch (
git push origin my-new-feature)
- Create a new Pull Request
Details are described here.
issue button above↑ to report any issues related to this project
OR you can shoot an email to email@example.com
This project is licensed under the MIT License - see LICENSE file for more details.