Skip to content

About

🧠🧩 Python solver for PipeMania using AI search techniques and state-space problem modeling.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PipeMania Solver

Python project that solves an adaptation of the PipeMania puzzle using state-space search and problem-solving techniques from Artificial Intelligence.


Project Description

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 Board representation for the puzzle grid
  • a PipeManiaState class to represent search states
  • a PipeMania problem class compatible with the provided search framework
  • a pipe.py entry point that parses input, solves the puzzle, and prints the solution

Piece Types

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, D for directional pieces
  • H, V for straight horizontal/vertical pieces

Examples:

  • FB, VC, VD
  • BC, BB, LV

Input Format

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

Project Structure

.
β”œβ”€β”€ README.md
β”œβ”€β”€ pipe.py
β”œβ”€β”€ search.py
β”œβ”€β”€ utils.py
β”œβ”€β”€ Visualizador/
β”‚   β”œβ”€β”€ visualizer.py
β”‚   β”œβ”€β”€ images/
β”‚   └── test-*.txt / test-*.out
└── __pycache__/

Main Files

  • pipe.py β€” main implementation of the PipeMania solver
  • search.py β€” provided search algorithms framework
  • utils.py β€” support utilities
  • Visualizador/ β€” visualizer, test boards, expected outputs, and piece images

Approach

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.


Running the Project

Run the solver by redirecting an input board into pipe.py:

python3 pipe.py < input.txt

Example

python3 pipe.py < Visualizador/test-01.txt

Example Usage

Input

FB VC VD
BC BB LV
FB FB FE

Output

FB VB VE
BD BE LV
FC FC FC

Technical Highlights

  • Developed in Python
  • Models the puzzle as an AI search problem
  • Uses state representation and action generation
  • Reads from stdin and writes to stdout
  • Compatible with the provided search framework
  • Includes test boards and a visualizer for experimentation

Notes

  • The repository includes a Visualizador/ folder with example boards, expected outputs, piece images, and a visualizer script.
  • search.py and utils.py were 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.

Credits

This project was developed by:

About

🧠🧩 Python solver for PipeMania using AI search techniques and state-space problem modeling.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages