mirror of
https://github.com/kuhyx/testsAndMisc-archive.git
synced 2026-07-04 17:43:09 +02:00
Fix ruff violations in ~15 source files and ~60+ test files to minimize per-file-ignores in pyproject.toml. Remaining ignores are justified with comments explaining why each suppression is necessary. Source fixes: FBT003 (keyword args), S310 (URL validation), SLF001 (private access), T201 (print→logging), C901 (complexity), E501 (line length), E402 (import order). Test fixes: SIM117 (combined with), FBT (boolean args), PERF203 (try in loop), S310/S607 (URLs/executables), E402/E501 (imports/lines), S108 (tmp paths), PLR0913 (too many args), ARG (unused args), ANN (type annotations), RUF059 (unused unpacked vars), PT019 (fixture naming). Remaining per-file-ignores (with justifications): - Tests: ARG, D, PLC0415, PLR2004, S101, SLF001 - music_gen sources: PLC0415 (heavy ML lazy imports) - moviepy_showcase: PLC0415 (circular dependency) - generate_images: PLR0913 (matplotlib helpers need many params) - praca_magisterska_video: E501, E402 (long paths, mpl.use) |
||
|---|---|---|
| .. | ||
| tests | ||
| __init__.py | ||
| __main__.py | ||
| main.py | ||
| parse_image.py | ||
| README.md | ||
| solver.py | ||
Sliding-Square Puzzle Solver
Parses a screenshot of a sliding-square puzzle and solves it via BFS.
Setup
cd puzzle_solver
python -m venv .venv && source .venv/bin/activate
pip install opencv-python-headless numpy
Usage
# From workspace root, with venv active:
# Step 1 – Parse screenshot to editable JSON
python -m puzzle_solver parse screenshot.png -o puzzle.json
# Step 2 – Review & fix any "unknown" squares in puzzle.json
# (set "type" to: normal / portal / teleporter / key / lock)
# Step 3 – Solve
python -m puzzle_solver solve puzzle.json
# One-shot (no manual review)
python -m puzzle_solver run screenshot.png
# Debug overlay (visualise detected squares on image)
python -m puzzle_solver debug screenshot.png -o debug.png
Game mechanics
| Square | JSON type | Description |
|---|---|---|
| Empty outline | normal |
Regular landing square |
| Solid fill | player |
Starting position |
| Ring inside | goal |
Target destination |
| Inner square offset | portal |
Pass through from the side marked by "side" |
| Antenna line(s) | teleporter |
Warp to paired teleporter ("group" id) |
| Key symbol | key |
Removes matching lock ("lock_id") |
| Lock symbol | lock |
Solid until matching key collected, then vanishes |
Movement
You slide in a cardinal direction (up/down/left/right) until you hit another square. If you slide off the grid without hitting anything, you die.
Algorithm
BFS over state = (position, set_of_active_locks). Explores all
reachable states and returns the shortest move sequence to the goal.