Rebuilding the RoboZZle level database

These scripts produce ../levels.json, the library used by play.html.

1. Get the sources

mkdir -p src && cd src
git clone --depth 1 https://github.com/lostmsu/RoboZZle.LevelArchive.git arch
git clone --depth 1 https://github.com/arnfaldur/RobozzleSolver.git
cd ..

2. Convert and verify

RZ_SRC=src python3 convert.py     # writes levels_full.json
python3 build_db.py               # writes levels.json
cp levels.json ..

convert.py reads the archive’s levels.xml, adds the extra puzzles from RobozzleSolver’s data/puzzles, decodes the solver’s solutions (low 5 bits = instruction, bits 5-7 = colour condition, 247 = empty slot) and replays each one in a simulator that follows the game’s rules. Only solutions that collect every star are kept.

build_db.py attaches write-ups, videos and hints (with source links), tags stack and paint puzzles, drops malformed boards and writes the compact JSON.

Starter levels

gen.py and gen2.py build the 12 built-in levels and check each against a reference solution (python3 gen2.py). Their output is pasted into the BUILTIN list in play.html.

Record format (levels.json)

field meaning
id robozzle.com puzzle number
name, author, date, about from the original level
board 12 strings of 16 chars: . empty, r g b tiles, R G B tiles with a star
robot {x, y, d}; d: 0 east, 1 south, 2 west, 3 north
funcs slots per function F1..F5
paint allowed paint colours: 1 red + 2 green + 4 blue
diff, votes players’ average difficulty out of 5, number of votes
liked, disliked, solvers, comments, featured stats from robozzle.com
links[] {kind, label, url} write-ups, videos, solution images
hints[] {text, source}
solution {program, steps, source, by}; program entries like "r:R", "F", "f2", "pb"
tags stack, paint