Python project that solves an adaptation of the PipeMania puzzle using state-space search and problem-solving techniques from Artificial Intelligence.
This project was developed for the Artificial Intelligence course. The objective is to read a PipeMania board from standard input, solve the puzzle, and print the solved board to standard output.
In this version of PipeMania, each board position contains a pipe piece, and the goal is to rotate the pieces so that the entire grid becomes a valid leak-free pipe network. According to the project statement, each instance can be assumed to have a unique solution.
The implementation is centered around:
- a
Boardrepresentation for the puzzle grid - a
PipeManiaStateclass to represent search states - a
PipeManiaproblem class compatible with the provided search framework - a
pipe.pyentry point that parses input, solves the puzzle, and prints the solution
The board includes four types of pieces:
- F β closing pieces
- B β branching pieces
- V β corner pieces
- L β straight pieces
Each piece also has an orientation, such as:
C,B,E,Dfor directional piecesH,Vfor straight horizontal/vertical pieces
Examples:
FB,VC,VDBC,BB,LV
The program reads a square PipeMania instance from standard input.
Example:
FB VC VD
BC BB LV
FB FB FE
Each token identifies:
- the piece type
- its current orientation
## Output Format
The program prints the solved board in the same grid format.
### Example
```text
FB VB VE
BD BE LV
FC FC FC
.
βββ README.md
βββ pipe.py
βββ search.py
βββ utils.py
βββ Visualizador/
β βββ visualizer.py
β βββ images/
β βββ test-*.txt / test-*.out
βββ __pycache__/
pipe.pyβ main implementation of the PipeMania solversearch.pyβ provided search algorithms frameworkutils.pyβ support utilitiesVisualizador/β visualizer, test boards, expected outputs, and piece images
The project models PipeMania as a search problem.
A state represents a board configuration, and actions correspond to changing the orientation of pieces. The solver then applies a search technique to reach a valid goal state where:
- all pipes are correctly connected
- there are no leaks
- the grid satisfies the puzzle constraints
The official statement explicitly frames the project as a problem-solving/search task and provides the Problem abstraction and search algorithms as the intended base infrastructure.
Run the solver by redirecting an input board into pipe.py:
python3 pipe.py < input.txtpython3 pipe.py < Visualizador/test-01.txtFB VC VD
BC BB LV
FB FB FE
FB VB VE
BD BE LV
FC FC FC
- Developed in Python
- Models the puzzle as an AI search problem
- Uses state representation and action generation
- Reads from
stdinand writes tostdout - Compatible with the provided search framework
- Includes test boards and a visualizer for experimentation
- The repository includes a
Visualizador/folder with example boards, expected outputs, piece images, and a visualizer script. search.pyandutils.pywere part of the provided support code used in the course.- The exact search strategy and heuristics may vary depending on the implementation in
pipe.py. - The focus of the project is on correctness and search-based problem solving rather than UI design.
This project was developed by: