A Python application for generating non-trivial tile arrangements with toroidal continuity
- Overview
- Core Principles
- GUI Features
- Requirements
- Installation
- Running the Application
- Building Executables
- Saving Results
- Project Structure
- License
This project solves the torus tiling problem using Google OR-Tools and provides a visual, user-friendly interface via Tkinter.
It allows the user to design a tiling layout using multiple tile formats and automatically finds a non-trivial periodic layout that satisfies a strict set of geometric constraints. The resulting pattern is displayed in a 3×3 toroidal tiling preview, demonstrating seamless periodicity.
The solver must place tiles according to these rules:
- No overlaps – tiles must not cover the same area.
- No gaps – the entire surface must be perfectly filled.
- Toroidal continuity – top edge must match the bottom, and left edge must match the right.
- Non-trivial boundaries – straight uninterrupted edges are disallowed.
- Tile diversity – every tile format listed must appear at least once.
- Labeling – each tile is marked with its ID.
- Visual output – shows a 3×3 tiling grid (central tile plus its eight toroidal neighbors).
- Optimization – tile usage is weighted by user-defined cost, and solutions are optimized accordingly.
The graphical interface offers the following:
Define tile formats with parameters:
- ID – unique integer label
- Width / Height (cm) – real-world dimensions
- Cost – optimization weight
- Min / Max Count – constraints on usage count
Buttons:
Add type– insert a new tile row with default valuesEdit type– modify selected row valuesRemove type– delete selected tile entry
- Width / Height (cm) – dimensions of the tiling surface
- Grid Size (cm) – unit of discretization (auto-computed from tile GCD)
- Max Time (s) – time budget for the solver
- Workers – number of threads
- Enforce wrap – require top/bottom and left/right continuity
- No straight lines – prohibit uninterrupted straight seams
- 4-corner penalty – weight to discourage perfect 2×2 tile alignment
- Dynamically updated image showing the tiling pattern
- Central layout plus eight neighbors for visual verification of toroidal constraints
Solve– launch the OR-Tools solverSave image– export preview to PNG
- Python 3.8+
- OR-Tools
- Matplotlib
- Pillow
- Tkinter (usually bundled with Python)
git clone https://github.com/SebastianGruza/TorusTiling.git
cd TorusTiling
python -m venv .venv
source .venv/bin/activate # Linux/macOS
.\.venv\Scripts\activate # Windows
pip install -r requirements.txtpython -m gui.guiFill in the tile types, adjust constraints, and click Solve to view the result.
pip install pyinstaller
pyinstaller ^
--onefile ^
--windowed ^
--name TorusTiling ^
--add-data "core;core" ^
--collect-binaries ortools ^
gui\gui.pysudo apt install python3-tk
pip install pyinstaller
pyinstaller --onefile --name TorusTilingLinux --add-data "core:core" gui/gui.pyOr run directly:
python -m gui.guiClick Save image to export the current preview as PNG. You will be prompted to choose the file location.
TorusTiling/
├── core/
│ └── tiling.py # Solver and visualization logic
├── gui/
│ └── gui.py # Tkinter interface
├── requirements.txt
├── README.md
└── ...
Released under the MIT License.
Aplikacja w Pythonie do generowania nietrywialnych układów płytek z ciągłością toroidalną
- Opis
- Zasady działania
- Funkcje GUI
- Wymagania
- Instalacja
- Uruchamianie aplikacji
- Budowanie pliku wykonywalnego
- Zapisywanie wyników
- Struktura projektu
- Licencja
Projekt rozwiązuje problem układania płytek na torusie przy użyciu Google OR-Tools i udostępnia przyjazny graficzny interfejs zbudowany w Tkinterze.
Pozwala użytkownikowi zdefiniować różne formaty płytek i automatycznie znaleźć nietrywialny periodyczny układ, który spełnia zestaw rygorystycznych ograniczeń geometrycznych. Wynikowy wzór wyświetlany jest w formie podglądu układu 3×3, pokazującego ciągłość toroidalną.
Układanie płytek musi spełniać następujące reguły:
- Brak nakładania – płytki nie mogą się pokrywać.
- Brak dziur – cała powierzchnia musi być dokładnie pokryta.
- Ciągłość toroidalna – górna krawędź musi pasować do dolnej, a lewa do prawej.
- Nietrywialne krawędzie – niedozwolone są proste nieprzerwane linie na brzegach.
- Różnorodność płytek – każda zdefiniowana płytka musi wystąpić co najmniej raz.
- Etykiety – każda płytka oznaczona jest swoim ID.
- Wizualizacja – rysunek zawiera centralny układ oraz jego sąsiadów (3×3).
- Optymalizacja – użycie płytek uwzględnia zadane koszty, a rozwiązanie jest optymalne względem tych wag.
Interfejs graficzny zawiera:
Możliwość zdefiniowania płytek z parametrami:
- ID – unikalny numer
- Szerokość / Wysokość (cm) – rozmiar fizyczny płytki
- Koszt – waga w funkcji celu, solver minimalizuje łączny koszt
- Min / Max liczba – minimalna i maksymalna liczba użyć
Przyciski:
Add type– dodaje nowy wiersz z domyślnymi wartościamiEdit type– edytuje zaznaczony wierszRemove type– usuwa zaznaczony wiersz
- Szerokość / Wysokość (cm) – wymiary powierzchni
- Rozmiar siatki (cm) – jednostka dyskretyzacji
- Max czas (s) – limit czasu działania solvera
- Liczba wątków – równoległość przeszukiwania
- Enforce wrap – wymuszanie ciągłości brzegów
- No straight lines – zakaz długich linii przebiegających w całości przez krawędzie płytek
- 4-corner penalty – kara za punkty, w których łączą się 4 krawędzie płytek (solver unika sytuacji, że w jednym punkcie zbiegają się 4 krawędzie płytek)
- Dynamicznie aktualizowany rysunek z układem
- Pokazuje centralny blok i ośmiu sąsiadów toroidalnych
Solve– uruchamia solverSave image– zapisuje podgląd jako PNG
- Python 3.8 lub nowszy
- OR-Tools
- Matplotlib
- Pillow
- Tkinter (zwykle dołączony do Pythona)
git clone https://github.com/SebastianGruza/TorusTiling.git
cd TorusTiling
python -m venv .venv
source .venv/bin/activate # Linux/macOS
.\.venv\Scripts\activate # Windows
pip install -r requirements.txtpython -m gui.guiWypełnij dane o płytkach, dostosuj ograniczenia i kliknij Solve, by zobaczyć wynik.
pip install pyinstaller
pyinstaller ^
--onefile ^
--windowed ^
--name TorusTiling ^
--add-data "core;core" ^
--collect-binaries ortools ^
gui\gui.pysudo apt install python3-tk
pip install pyinstaller
pyinstaller --onefile --name TorusTilingLinux --add-data "core:core" gui/gui.pyLub uruchomienie bezpośrednio:
python -m gui.guiKliknij Save image, by zapisać podgląd jako PNG. Wybierz miejsce zapisania pliku.
TorusTiling/
├── core/
│ └── tiling.py # Logika solvera i rysowania
├── gui/
│ └── gui.py # Interfejs użytkownika w Tkinterze
├── requirements.txt
├── README.md
└── ...
Projekt jest udostępniony na licencji MIT.
