miniworlds_data
miniworlds_data is an extension library for miniworlds. It provides pixel
worlds that visualize classic data structures so that algorithms (search,
sorting, traversal, pathfinding) can be shown step by step.
The library builds everything from miniworlds worlds and actors. It does not load pygame sprites or expose pygame primitives.
The package lives in its own repository and uses miniworlds as its rendering engine.
Worlds
| World | Visualizes | Typical algorithms |
|---|---|---|
ListWorld |
array of bars | linear/binary search, bubble/selection sort |
StackWorld |
LIFO stack | recursion / call-stack, DFS, undo |
QueueWorld |
FIFO queue | BFS frontier |
TreeWorld |
binary tree | traversals (pre/in/post-order), BST search |
GraphWorld |
graph with edges | BFS, DFS, shortest path |
Each world uses the same standardized color language for highlight states
(default, compare, swap, sorted, pivot, visited, current,
frontier, start, target, path).
Stepper
Algorithms written as plain loops run inside a single frame, so intermediate
states are never visible. Stepper solves this: the algorithm is written as a
generator that yields once per step, and the stepper advances it one step
per frame (or on demand).
from miniworlds_data import ListWorld, Stepper
initial = [5, 2, 4, 1, 3]
world = ListWorld(initial)
def apply_step(step):
name, (i, j) = step
world.reset_all()
if name == "compare":
world.compare(i, j)
elif name == "swap":
world.swap(i, j)
def bubble_sort(data):
n = data.length
for i in range(n):
for j in range(n - i - 1):
yield "compare", (j, j + 1)
if data.values[j] > data.values[j + 1]:
yield "swap", (j, j + 1)
stepper = Stepper(bubble_sort(world), world, on_step=apply_step)
stepper.run() # advances one step per frame
world.run()
Stepper also supports single stepping (next_step), going back (prev_step),
reset, and goto. Pass an on_reset callback that restores the initial values
and highlights to use reset or move backward. Recorded steps can be replayed
after the generator finishes. See Bubble Sort with the Stepper
for an example with an on_reset callback.
Example: sorting
from miniworlds_data import ListWorld
world = ListWorld([5, 2, 4, 1, 3])
world.compare(0, 1)
world.swap(0, 1)
world.mark_sorted(0)
world.run()
Example: graph pathfinding
from miniworlds_data import GraphWorld
world = GraphWorld()
a = world.add_node("A", "A", (100, 100))
b = world.add_node("B", "B", (300, 100))
c = world.add_node("C", "C", (200, 250))
world.connect(a, b)
world.connect(a, c)
world.connect(b, c)
world.set_start(a)
world.set_target(c)
world.run()
Metadata
Release files for miniworlds-data 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| miniworlds_data-0.1.0.tar.gz | 18.5 kB | Without provenance | Details for miniworlds_data-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| miniworlds_data-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for miniworlds_data-0.1.0-py3-none-any.whl |
Total release size: 36.6 kB
Release files / miniworlds_data-0.1.0.tar.gz
| Download URL | miniworlds_data-0.1.0.tar.gz |
|---|---|
| Size | 18.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ac9dce6c37dfda4666e49b71e25b1d42e85d6d35ef8f7b5585a5b653f12fa70f
|
|
BLAKE2b-256 checksum How to use checksums |
23357b9988239efb9be1f35b1dd44e530a11da748a2697fb08ee72ff18123a94
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|
Release files / miniworlds_data-0.1.0-py3-none-any.whl
| Download URL | miniworlds_data-0.1.0-py3-none-any.whl |
|---|---|
| Size | 18.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
602f702f214cd992fb80271ce5f3559ac49e8cfb21ccae3c2161c7f251b6fa48
|
|
BLAKE2b-256 checksum How to use checksums |
bd25ac3b92e023933d603a33676e629cde4f6b501c988ba3262590799d9bde30
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|
Security for miniworlds-data 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.