Lab 2. State Space Search
TODO:
Fill missing code according to the TODO:
comments in the following files:
solvers/generic/uninformed.py
solvers/generic/best_first.py
solvers/iddfs.py
solvers/idastar.py
problems/grid_pathfinding/heuristics/euclidean_heuristic.py
problems/grid_pathfinding/heuristics/manhattan_heuristic.py
problems/grid_pathfinding/heuristics/diagonal_heuristic.py
problems/n_puzzle/heuristics/n_puzzle_tiles_out_of_place_heuristic.py
problems/n_puzzle/heuristics/n_puzzle_manhattan_heuristic.py
problems/blocks_world/blocks_world_heuristic.py
problems/blocks_world/blocks_world_problem.py
problems/blocks_world/blocks_world_action.py
Useful links:
- interactive pathfinding on grids
- definitions of various grid heuristics
- nice blog post about A*
- elegant n-puzzle visualization
Grading
- Make sure, you have a private group
- Fork this project into your private group
- Add @bobot-is-a-bot as the new project's member (role: maintainer)
How To Submit Solutions
- Clone repository: git clone:
git clone <repository url>
- Solve the exercises
- use MiniZincIDE, whatever
- Commit your changes
git add <path to the changed files> git commit -m <commit message>
- Push changes to the gitlab master branch
git push -u origin master
The rest will be taken care of automatically. You can check the GRADE.md
file for your grade / test results. Be aware that it may take some time (up to one hour) till this file
How To Run
This class requires Python with version at least 3.8. Recommended way to run is to create a virtual environment first:
python -m venv state-search
source state-search/bin/activate
Then install required packages:
pip install -r requirements.txt
Finally you can run a solver:
python solve.py -a <algorithm> -p <problem> -h <heuristic> <path_to_instance>
, e.g.python solve.py -p rush_hour -a astar -h rush_hour_indirect problems/rush_hour/instances/81.txt
(every problem has several instances in theinstances
directory)
You can also run a benchmark:
python benchmark.py -p <problem> -t timeout <path_to_instance>
, e.g.python benchmark.py -p rush_hour problems/rush_hour/instances/54.txt
If you run script with incorrect arguments, you will get some helpful info ;)
Project Structure
.
├── base # API for problem and solver classes
├── problems # List of defined problems (place to define problems)
│ ├── ...
│ ├── n_puzzle # directory with a problem
│ │ ├── instances # directory with problem instances
│ │ └── ...
│ └── ...
├── solvers # directory with algorithms
│ ├── generic # code shared by several algorithms
│ ├── bfs.py # example of an algorithm
│ └── ...
├── tree # search tree representation
├── utils # various utilities
├── solve.py # solve tool (run as a script)
├── benchmark.py # benchmark tool (run as a script)
└── cli_config.py # configuration of the cli tools (do not touch)