Eight Puzzle CLI

8-piece command-line puzzle game developed for the Artificial Intelligence discipline. Written in python, this project aims to apply the studied concepts and implement a simple intelligent agent that can solve the game.

Project execution


  • Python 3.9.0 or higher


  • Clone the project (or download):
    git clone https://github.com/Nakahwra/EightPuzzle.git
    && EightPuzzle cd/
  • Run the main game.py file:
    python3 ./game.py

Automatic agents

Two automatic agents are implemented that use two "brute force" search algorithms:

Breadth-first Search Algorithm - BFS

Width search, graph/tree search algorithm where the exploration of all neighboring vertices is prioritized before traversing to the next depth, until a solution node is found.

Depth-first Search Algorithm - DFS

Depth search, graph/tree search algorithm where the exploration of one of the branches of the root node in its entirety is prioritized until a solution node is found.

Optional settings


The board can be adjusted in the game rules class constructor at: game_rules/eightpuzzle.py. There are available two other boards used for testing, and you can also configure new boards.

Interval between moves

The interval between each roll of an automatic agent can be configured by changing the sleep function parameter in agents/automatic_agent.py in the chooseNextAction method