miniworlds-data 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,113 @@
1
+ Metadata-Version: 2.4
2
+ Name: miniworlds-data
3
+ Version: 0.1.0
4
+ Summary: Data structure visualization worlds for miniworlds
5
+ Author: Andreas Siebel
6
+ Classifier: Development Status :: 3 - Alpha
7
+ Classifier: Intended Audience :: Education
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Programming Language :: Python
10
+ Classifier: Topic :: Education
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: miniworlds
15
+ Dynamic: license-file
16
+
17
+ # miniworlds_data
18
+
19
+ `miniworlds_data` is an extension library for miniworlds. It provides pixel
20
+ worlds that visualize classic data structures so that algorithms (search,
21
+ sorting, traversal, pathfinding) can be shown step by step.
22
+
23
+ The library builds everything from miniworlds worlds and actors. It does not
24
+ load pygame sprites or expose pygame primitives.
25
+
26
+ The package lives in its own repository and uses miniworlds as its rendering
27
+ engine.
28
+
29
+ ## Worlds
30
+
31
+ | World | Visualizes | Typical algorithms |
32
+ |--------------|----------------------|--------------------------------------------|
33
+ | `ListWorld` | array of bars | linear/binary search, bubble/selection sort |
34
+ | `StackWorld` | LIFO stack | recursion / call-stack, DFS, undo |
35
+ | `QueueWorld` | FIFO queue | BFS frontier |
36
+ | `TreeWorld` | binary tree | traversals (pre/in/post-order), BST search |
37
+ | `GraphWorld` | graph with edges | BFS, DFS, shortest path |
38
+
39
+ Each world uses the same standardized color language for highlight states
40
+ (`default`, `compare`, `swap`, `sorted`, `pivot`, `visited`, `current`,
41
+ `frontier`, `start`, `target`, `path`).
42
+
43
+ ## Stepper
44
+
45
+ Algorithms written as plain loops run inside a single frame, so intermediate
46
+ states are never visible. `Stepper` solves this: the algorithm is written as a
47
+ *generator* that `yield`s once per step, and the stepper advances it one step
48
+ per frame (or on demand).
49
+
50
+ ```python
51
+ from miniworlds_data import ListWorld, Stepper
52
+
53
+ initial = [5, 2, 4, 1, 3]
54
+ world = ListWorld(initial)
55
+
56
+
57
+ def apply_step(step):
58
+ name, (i, j) = step
59
+ world.reset_all()
60
+ if name == "compare":
61
+ world.compare(i, j)
62
+ elif name == "swap":
63
+ world.swap(i, j)
64
+
65
+
66
+ def bubble_sort(data):
67
+ n = data.length
68
+ for i in range(n):
69
+ for j in range(n - i - 1):
70
+ yield "compare", (j, j + 1)
71
+ if data.values[j] > data.values[j + 1]:
72
+ yield "swap", (j, j + 1)
73
+
74
+
75
+ stepper = Stepper(bubble_sort(world), world, on_step=apply_step)
76
+ stepper.run() # advances one step per frame
77
+ world.run()
78
+ ```
79
+
80
+ `Stepper` also supports single stepping (`next_step`), going back (`prev_step`),
81
+ `reset`, and `goto`. Pass an `on_reset` callback that restores the initial values
82
+ and highlights to use `reset` or move backward. Recorded steps can be replayed
83
+ after the generator finishes. See [Bubble Sort with the Stepper](examples/03_bubble_sort_stepper.py)
84
+ for an example with an `on_reset` callback.
85
+
86
+ ## Example: sorting
87
+
88
+ ```python
89
+ from miniworlds_data import ListWorld
90
+
91
+ world = ListWorld([5, 2, 4, 1, 3])
92
+ world.compare(0, 1)
93
+ world.swap(0, 1)
94
+ world.mark_sorted(0)
95
+ world.run()
96
+ ```
97
+
98
+ ## Example: graph pathfinding
99
+
100
+ ```python
101
+ from miniworlds_data import GraphWorld
102
+
103
+ world = GraphWorld()
104
+ a = world.add_node("A", "A", (100, 100))
105
+ b = world.add_node("B", "B", (300, 100))
106
+ c = world.add_node("C", "C", (200, 250))
107
+ world.connect(a, b)
108
+ world.connect(a, c)
109
+ world.connect(b, c)
110
+ world.set_start(a)
111
+ world.set_target(c)
112
+ world.run()
113
+ ```
@@ -0,0 +1,13 @@
1
+ miniworlds_data/__init__.py,sha256=75pqebN6t9mKxhISoG2cKgYrLrHp99aD6H_ogMG1TXE,495
2
+ miniworlds_data/graph_world.py,sha256=ygCGWZRSPnl04PwN1zL3lxBfAuEPkeX4wqzZ0x-17KQ,9635
3
+ miniworlds_data/list_world.py,sha256=hBs6KqViT9IBw5Qno5riIhoq0fVwhCVPUQtsorDArzY,8485
4
+ miniworlds_data/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ miniworlds_data/queue_world.py,sha256=O4T6RA2BpGLBHaU5l0mPK0_nTssayY_0KBBdLDSCC1E,5511
6
+ miniworlds_data/stack_world.py,sha256=eORnzLPycFKJrQrEhjeDwNGiFMx3eh7EA1sXVHD3c6o,4973
7
+ miniworlds_data/stepper.py,sha256=m43O-lEDwf4cvUBoGX3BrGYMttmWR_LOvrjWMvNt1vA,6797
8
+ miniworlds_data/tree_world.py,sha256=HfQlM2vsepNo5CCGC70tnr87zj4axW8Rlz1AexDtkh0,9846
9
+ miniworlds_data-0.1.0.dist-info/licenses/LICENSE,sha256=BMli7ccF4eWgs9Iri_IcQaHvBmcMLfkwGQARb4woHLg,1071
10
+ miniworlds_data-0.1.0.dist-info/METADATA,sha256=VS9bWP16mFEFIkJx5WxvD9wVoLbTOh4GHEkUUi3sYHo,3558
11
+ miniworlds_data-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
12
+ miniworlds_data-0.1.0.dist-info/top_level.txt,sha256=e8dv9Y-uJ-ZPmkrpslu978_MWc_43sZc0krdGNOL-hw,16
13
+ miniworlds_data-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Andreas Siebel
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ miniworlds_data