Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/0xosiris/twiddlesolver

Breadth First search solution to solve 3x3 twiddle board in short time
https://github.com/0xosiris/twiddlesolver

ai bfs-algorithm java twiddle-algorithm

Last synced: 18 days ago
JSON representation

Breadth First search solution to solve 3x3 twiddle board in short time

Awesome Lists containing this project

README

        

```
___________ .__ .___ .___.__
\__ ___/_ _ _|__| __| _/__| _/| | ____
| | \ \/ \/ / |/ __ |/ __ | | | _/ __ \
| | \ /| / /_/ / /_/ | | |_\ ___/
|____| \/\_/ |__\____ \____ | |____/\___ >
\/ \/ \/
```
Breadth First search solution to solve 3x3 twiddle board implemented in Java. A link to a demo of the game Twiddle can be found below.

https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/twiddle.html

# Puzzle Description
Twiddle is a simple puzzle game with an nxn grid of sequentially numbered tiles. This repository implements a Java BFS algorithm to solve an arbitrary 3x3
twiddle board in the optimal number of moves.

With a 3x3 board, the initial values in the 9 tiles are randomly initialized to a unique value in 1..9. A 3x3 board has 4 possible axis of rotation,
and a Clockwise/Counter Clockwise rotation on each of the 4 axis is a legal move. The goal is to order all the tiles in ascending order through a sequence
of Clockwise/Counter Clockwise rotation on the 4 axis' of the board.

![twiddle-web](https://user-images.githubusercontent.com/26036115/167118678-d1f27a16-741c-4bce-b787-15f449a35804.png)

# Solver
Performs a BFS traversal of a tree generated by applying all possible moves to the initial state, and cutting out repeated states from the queue. Applying
all possible moves to each sequential state until it reaches the goal state of the board. It then traverses back up the path to the initial state,
and outputs all of the moves leading to the goal state as the solution.

# Twiddle
Main function, this is will prompt you to enter an initial board state to be solved represented as a 9 digiit string.

# Node
Defines all of the logic on C/CC moves and their respective transformation logic on the board state.