Genius Square puzzle solver in Python

Overview

Genius Square

Genius Square puzzle solver in Python

Screenshot

Introduction

The Genius Square is a spacial awareness game for children. The game consists of seven, six-sided dice, a 6x6 board, 7 'blocker' pieces, and 9 tetris-like pieces of different shapes.

A player rolls seven six-sided dice:

Dice

Each dice is then used to put a 'blocker' piece on the board at the given location:

Initial Board

The player then takes the 9 coloured pieces and attempts to fit them onto the board:

Pieces

One completed state for the board would be as follows:

Completed Board

Algorithm

To solve the puzzle we take one of the largest pieces, in our case the four-cell-square piece and attempt to find a place on the board where it fits in. Once we have done so, we then check the next smallest piece and attempt to find a place where that also fits. At some point we will reach a situation where there are no locations where the current piece can go. At this point we back-track to the previous pieces and see if there are additional locations that can be used. This is continued until we reach the smallest piece, which should fit in the large remaining cell.

Usage

Simply click ROLL DICE to set the seven blocker cells. Then click SOLVE to solve the puzzle.

Setup

For Python we need the following:

pygame (Tested with v1.9.6)
numpy (Tested with v1.18.3)

pip install pygame
pip install numpy
You might also like...
Python Sorted Container Types: Sorted List, Sorted Dict, and Sorted Set

Python Sorted Containers Sorted Containers is an Apache2 licensed sorted collections library, written in pure-Python, and fast as C-extensions. Python

All Algorithms implemented in Python

The Algorithms - Python All algorithms implemented in Python (for education) These implementations are for learning purposes only. Therefore they may

A collection of design patterns/idioms in Python

python-patterns A collection of design patterns and idioms in Python. Current Patterns Creational Patterns: Pattern Description abstract_factory use a

A lightweight, object-oriented finite state machine implementation in Python with many extensions

transitions A lightweight, object-oriented state machine implementation in Python with many extensions. Compatible with Python 2.7+ and 3.0+. Installa

:computer: Data Structures and Algorithms in Python

Algorithms in Python Implementations of a few algorithms and datastructures for fun and profit! Completed Karatsuba Multiplication Basic Sorting Rabin

Algorithms implemented in Python

Python Algorithms Library Laurent Luce Description The purpose of this library is to help you with common algorithms like: A* path finding. String Mat

A fast python implementation of the SimHash algorithm.

This Python package provides hashing algorithms for computing cohort ids of users based on their browsing history. As such, it may be used to compute cohort ids of users following Google's Federated Learning of Cohorts (FLoC) proposal.

A command line tool for memorizing algorithms in Python by typing them.

Algo Drills A command line tool for memorizing algorithms in Python by typing them. In alpha and things will change. How it works Type out an algorith

A genetic algorithm written in Python for educational purposes.
A genetic algorithm written in Python for educational purposes.

Genea: A Genetic Algorithm in Python Genea is a Genetic Algorithm written in Python, for educational purposes. I started writing it for fun, while lea

Comments
  • Dice combination issue?

    Dice combination issue?

    Hi Thanks for this code. Ran this and ended up with a duplicate "blocking" location from your dice. "F2" & "F2". This resulted in there only being 6 blocking squares on the board. The game was SOLVED, leaving one BLANK square on the board! Think there's a little tweaking required in either your dice combinations or the dice "throwing" routine. Screenshot 2021-12-29 151017

    Not being a programmer, I doubt I'd have any clue as to what the issue is, but just thought you might like to know. Thanks again for a great program to compliment my addiction to THE GENIUS SQUARE. Regards, Richard.

    opened by RichardJThorp 4
  • Anyway to make a manual input for pegs?

    Anyway to make a manual input for pegs?

    I was wondering if there was anyway to make a manual input for the pegs so we can use the solver to actually solve the genius square. When I say manual input for pegs, I just mean like B4, F1,etc.

    opened by ghost 2
  • CLI version

    CLI version

    How easy would a CLI-only version that uses multiple threads (but that's only an idea, threading can make a whole ton of issues) be?

    Or at least a standalone function which you give dice locations to and it returns the solution or False, without pygame or numpy? Obviously numpy can do a lot of heavy lifting, but perhaps a more "educational" version where the code is pure python?

    Thanks!

    opened by Pythonic456 0
  • Computation time to show all solutions for given blockers pattern

    Computation time to show all solutions for given blockers pattern

    How many combinations should the software test to list all possible solutions for a given blockers pattern?

    The red piece can be rotated or flipped in 4 different ways and it should be tested on 36 different cells, obviously some positions could have a blocker or another already placed piece but in terms of iterations just the red piece accounts for 4*36 combinations, this value has to be multiplied by the combinations of other pieces. This is a huge number and then listing all possible solutions for a given blockers pattern is not possible in a reasonable time.

    What's your opinion?

    opened by adibacco 1
Owner
James
Busily reinventing the wheel
James
CLI Eight Puzzle mini-game featuring BFS, DFS, Greedy and A* searches as solver algorithms.

?? Eight Puzzle CLI Jogo do quebra-cabeças de 8 peças em linha de comando desenvolvido para a disciplina de Inteligência Artificial. Escrito em python

Lucas Nakahara 1 Jun 30, 2021
A simple python implementation of A* and bfs algorithm solving Eight-Puzzle

A simple python implementation of A* and bfs algorithm solving Eight-Puzzle

null 2 May 22, 2022
A Python project for optimizing the 8 Queens Puzzle using the Genetic Algorithm implemented in PyGAD.

8QueensGenetic A Python project for optimizing the 8 Queens Puzzle using the Genetic Algorithm implemented in PyGAD. The project uses the Kivy cross-p

Ahmed Gad 16 Nov 13, 2022
8 Puzzle with A* , Greedy & BFS Search in Python

8_Puzzle 8 Puzzle with A* , Greedy & BFS Search in Python Python Install Python from here. Pip Install pip from here. How to run? ?? Install 8_Puzzle

I3L4CK H4CK3l2 1 Jan 30, 2022
sudoku solver using CSP forward-tracking algorithms.

Sudoku sudoku solver using CSP forward-tracking algorithms. Description Sudoku is a logic-based game that consists of 9 3x3 grids that create one larg

Cindy 0 Dec 27, 2021
Classic algorithms including Fizz Buzz, Bubble Sort, the Fibonacci Sequence, a Sudoku solver, and more.

Algorithms Classic algorithms including Fizz Buzz, Bubble Sort, the Fibonacci Sequence, a Sudoku solver, and more. Algorithm Complexity Time and Space

null 1 Jan 14, 2022
Wordle-solver - A program that solves a Wordle using a simple algorithm

Wordle Solver A program that solves a Wordle using a simple algorithm. To see it

Luc Bouchard 3 Feb 13, 2022
Algorithms-in-Python - Programs related to DSA in Python for placement practice

Algorithms-in-Python Programs related to DSA in Python for placement practice CO

MAINAK CHAUDHURI 2 Feb 2, 2022
Minimal examples of data structures and algorithms in Python

Pythonic Data Structures and Algorithms Minimal and clean example implementations of data structures and algorithms in Python 3. Contributing Thanks f

Keon 22k Jan 9, 2023
Repository for data structure and algorithms in Python for coding interviews

Python Data Structures and Algorithms This repository contains questions requiring implementation of data structures and algorithms concepts. It is us

Prabhu Pant 1.9k Jan 1, 2023