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

Dependencies

  • Python 3.9.0 or higher

Execution

  • 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.
68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f352f35642f427265616474682d46697273742d5365617263682d416c676f726974686d2e676966

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.
68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f372f37662f44657074682d46697273742d5365617263682e676966

Optional settings

Board

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

GitHub

https://github.com/Nakahwra/EightPuzzle