This repository contains an implementation of the Towers of Hanoi problem using the AIMA-Python library. The solution utilizes A (A-Star Search)* as the search strategy, ensuring a more efficient resolution compared to breadth-first search.
Problem modeling using AIMA's Problem class. Implementation of a heuristic that considers the weight of the disks and the pegs. Support for different numbers of disks. Solution output displaying the sequence of moves.
Python 3
AIMA-Python (Artificial Intelligence: A Modern Approach)
1️⃣ Clone the AIMA-Python repository (required to import search functions):
git clone https://github.com/aimacode/aima-python.git
2️⃣ Navigate to the cloned folder:
cd aima-python
3️⃣ Clone this repository inside the aima-python folder:
git clone https://github.com/pewilliam/hanoi_python.git
4️⃣ Navigate to the project folder:
cd repository-name
5️⃣ Run the script:
python solve_hanoi.py
The number of disks can be changed in the code (default: num_disks = 6). For very high values (such as 20 disks), execution time may be significantly long due to the problem's exponential complexity.
Este repositório contém a implementação do problema das Torres de Hanoi utilizando a biblioteca AIMA-Python. A solução usa A (A-Star Search)* como estratégia de busca, garantindo uma resolução mais eficiente em comparação com a busca em largura.
Modelagem do problema usando a classe Problem da AIMA. Implementação de uma heurística que leva em conta o peso dos discos e das hastes. Suporte para diferentes números de discos. Impressão da solução com os movimentos realizados.
Python 3
AIMA-Python (Artificial Intelligence: A Modern Approach)
1️⃣ Clone o repositório AIMA-Python (necessário para importar as funções de busca):
git clone https://github.com/aimacode/aima-python.git
2️⃣ Entre na pasta clonada:
cd aima-python
3️⃣ Clone este repositório dentro da pasta aima-python:
git clone https://github.com/pewilliam/hanoi_python.git
4️⃣ Entre na pasta do projeto:
cd nome-do-repositorio
5️⃣ Execute o script:
python solve_hanoi.py
O número de discos pode ser alterado no código (por padrão, num_disks = 6). Para valores muito altos (como 20 discos), o tempo de execução pode ser muito longo devido à complexidade exponencial do problema.