Fraser commited on
Commit
2bb0b33
·
verified ·
1 Parent(s): 11ef8f8

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +304 -67
README.md CHANGED
@@ -1,69 +1,306 @@
1
  ---
2
- dataset_info:
3
- features:
4
- - name: cart_id
5
- dtype: string
6
- - name: title
7
- dtype: string
8
- - name: author
9
- dtype: string
10
- - name: description
11
- dtype: string
12
- - name: tags
13
- list: string
14
- - name: stars
15
- dtype: int32
16
- - name: reply_count
17
- dtype: int32
18
- - name: date_posted
19
- dtype: string
20
- - name: date_updated
21
- dtype: string
22
- - name: license
23
- dtype: string
24
- - name: thread_id
25
- dtype: int32
26
- - name: thread_url
27
- dtype: string
28
- - name: lua_code
29
- dtype: string
30
- - name: token_count
31
- dtype: int32
32
- - name: char_count
33
- dtype: int32
34
- - name: has_init
35
- dtype: bool
36
- - name: has_update
37
- dtype: bool
38
- - name: has_draw
39
- dtype: bool
40
- - name: is_duplicate
41
- dtype: bool
42
- - name: spritesheet
43
- dtype: image
44
- - name: label_image
45
- dtype: image
46
- - name: map_image
47
- dtype: image
48
- - name: map_data
49
- list: uint8
50
- - name: sprite_flags
51
- list: uint8
52
- - name: gfx_hex
53
- dtype: string
54
- - name: sfx_hex
55
- dtype: string
56
- - name: music_hex
57
- dtype: string
58
- splits:
59
- - name: train
60
- num_bytes: 456531640
61
- num_examples: 10967
62
- download_size: 303731870
63
- dataset_size: 456531640
64
- configs:
65
- - config_name: default
66
- data_files:
67
- - split: train
68
- path: data/train-*
69
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: cc-by-nc-sa-4.0
3
+ task_categories:
4
+ - text-generation
5
+ - image-to-text
6
+ language:
7
+ - en
8
+ tags:
9
+ - pico-8
10
+ - games
11
+ - pixel-art
12
+ - lua
13
+ - code-generation
14
+ - retro
15
+ - fantasy-console
16
+ - sprites
17
+ - chiptune
18
+ - game-development
19
+ pretty_name: "PICO-8 Games"
20
+ size_categories:
21
+ - 10K<n<100K
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  ---
23
+
24
+ # PICO-8 Games Dataset
25
+
26
+ <p align="center">
27
+ <img src="showcase.gif" alt="PICO-8 Games Showcase" width="384">
28
+ </p>
29
+
30
+ **The first multimodal dataset of PICO-8 games.** 10,967 cartridges scraped from the [Lexaloffle BBS](https://www.lexaloffle.com/bbs/?cat=7#sub=2), each decomposed into Lua source code, pixel-art spritesheets, tile maps, sound effects, music patterns, and metadata.
31
+
32
+ <p align="center">
33
+ <img src="hero_grid.png" alt="Top 48 PICO-8 games by star count" width="800">
34
+ <br>
35
+ <em>Label screenshots from the top 48 games by star count</em>
36
+ </p>
37
+
38
+ ## What's Inside
39
+
40
+ Every PICO-8 cartridge is a self-contained game packed into a single file. This dataset cracks each one open into its component parts:
41
+
42
+ <p align="center">
43
+ <img src="modalities.png" alt="Cart modalities breakdown" width="800">
44
+ <br>
45
+ <em>The anatomy of a PICO-8 cartridge (Celeste by Matt Thorson & Noel Berry)</em>
46
+ </p>
47
+
48
+ | Modality | Format | Description |
49
+ |----------|--------|-------------|
50
+ | **Lua source code** | String (up to 65,535 chars) | The complete game logic in PICO-8's Lua dialect |
51
+ | **Spritesheet** | 128x128 PNG (16 colors) | Up to 256 8x8 sprites — all the game's pixel art |
52
+ | **Label image** | 128x128 PNG | The developer's chosen screenshot representing the game |
53
+ | **Tile map** | 128x32 grid of tile indices | The spatial layout of game levels |
54
+ | **Sound effects** | 64 SFX slots, hex-encoded | Each SFX has 32 notes with pitch, waveform, volume, and effects |
55
+ | **Music patterns** | 64 patterns, hex-encoded | 4-channel music sequencer data referencing SFX slots |
56
+ | **Sprite flags** | 256 bytes | 8 boolean flags per sprite, used for collision/behavior |
57
+
58
+ ## Dataset Schema
59
+
60
+ ```python
61
+ {
62
+ # --- Metadata ---
63
+ "cart_id": str, # Unique cart identifier (lid)
64
+ "title": str, # Game title
65
+ "author": str, # Author username
66
+ "description": str, # Author's description (when available)
67
+ "tags": list[str], # User-applied tags ("platformer", "shooter", etc.)
68
+ "stars": int, # Community star/like count (primary quality signal)
69
+ "reply_count": int, # Number of thread replies (engagement signal)
70
+ "date_posted": str, # Original post date (YYYY-MM-DD HH:MM:SS)
71
+ "date_updated": str, # Last update date
72
+ "license": str, # "CC4-BY-NC-SA" or "" (71% are CC4-licensed)
73
+ "thread_id": int, # BBS thread ID
74
+ "thread_url": str, # Direct link to the BBS thread
75
+
76
+ # --- Code ---
77
+ "lua_code": str, # Complete Lua source code
78
+ "token_count": int, # Approximate PICO-8 token count
79
+ "char_count": int, # Character count of Lua code
80
+
81
+ # --- Quality flags ---
82
+ "has_init": bool, # Has _init() function
83
+ "has_update": bool, # Has _update() or _update60() function
84
+ "has_draw": bool, # Has _draw() function
85
+ "is_duplicate": bool, # Exact code duplicate of a higher-starred cart
86
+
87
+ # --- Visual data ---
88
+ "spritesheet": Image, # 128x128 RGB spritesheet (PICO-8's 16-color palette)
89
+ "label_image": Image, # 128x128 cart label screenshot (if captured by dev)
90
+ "map_image": Image, # Rendered tile map using spritesheet (if map data exists)
91
+
92
+ # --- Raw data (for lossless roundtripping) ---
93
+ "gfx_hex": str, # Raw spritesheet as hex digits
94
+ "map_data": list[int], # Raw tile indices (uint8)
95
+ "sprite_flags": list[int], # Raw sprite flags (uint8)
96
+ "sfx_hex": str, # Raw sound effect data
97
+ "music_hex": str, # Raw music pattern data
98
+ }
99
+ ```
100
+
101
+ ## Quick Start
102
+
103
+ ```python
104
+ from datasets import load_dataset
105
+
106
+ ds = load_dataset("Fraser/pico-8-games")
107
+
108
+ # Browse the top games
109
+ top = ds["train"].sort("stars", reverse=True)
110
+ for row in top.select(range(10)):
111
+ print(f"{row['title']:30s} {row['stars']:4d} stars by {row['author']}")
112
+
113
+ # Filter to high-quality, unique, CC4-licensed games
114
+ hq = ds["train"].filter(lambda x: (
115
+ x["stars"] >= 10
116
+ and not x["is_duplicate"]
117
+ and x["has_init"] and x["has_update"] and x["has_draw"]
118
+ and x["license"] == "CC4-BY-NC-SA"
119
+ ))
120
+ print(f"High-quality subset: {len(hq)} games")
121
+ ```
122
+
123
+ ## Running a Cart
124
+
125
+ PICO-8 carts are playable games. To run one:
126
+
127
+ **1. In the browser** — Visit the `thread_url` for any cart and click "Play" on the BBS page.
128
+
129
+ **2. With PICO-8** ($15, [lexaloffle.com](https://www.lexaloffle.com/pico-8.php)) — Reconstruct the `.p8` text file:
130
+
131
+ ```python
132
+ row = ds["train"][0]
133
+
134
+ # Build the .p8 file from dataset columns
135
+ p8_text = "pico-8 cartridge // http://www.pico-8.com\nversion 42\n"
136
+ p8_text += f"__lua__\n{row['lua_code']}\n"
137
+ p8_text += f"__gfx__\n{row['gfx_hex']}\n"
138
+
139
+ # Add map data (convert byte array back to hex lines)
140
+ map_bytes = row["map_data"]
141
+ if map_bytes:
142
+ p8_text += "__map__\n"
143
+ for y in range(0, len(map_bytes), 128):
144
+ line = "".join(f"{b:02x}" for b in map_bytes[y:y+128])
145
+ p8_text += line + "\n"
146
+
147
+ # Add sprite flags
148
+ flags = row["sprite_flags"]
149
+ if flags:
150
+ p8_text += "__gff__\n"
151
+ p8_text += "".join(f"{b:02x}" for b in flags) + "\n"
152
+
153
+ p8_text += f"__sfx__\n{row['sfx_hex']}\n"
154
+ p8_text += f"__music__\n{row['music_hex']}\n"
155
+
156
+ with open("game.p8", "w") as f:
157
+ f.write(p8_text)
158
+ # Then: pico8 -run game.p8
159
+ ```
160
+
161
+ ## Extracting Components
162
+
163
+ ### Render the spritesheet
164
+
165
+ Each cart's spritesheet is a 128x128 image using PICO-8's fixed 16-color palette. It's stored both as a rendered PNG and as raw hex for lossless access.
166
+
167
+ ```python
168
+ # The spritesheet is already a PIL Image
169
+ row = ds["train"][0]
170
+ row["spritesheet"].save("sprites.png")
171
+
172
+ # Or parse individual 8x8 sprites from the hex data
173
+ gfx = row["gfx_hex"]
174
+ lines = gfx.strip().split("\n")
175
+ # Each hex digit = one pixel (4-bit color index)
176
+ # Sprite 0 is at (0,0), sprite 1 at (8,0), ..., sprite 16 at (0,8)
177
+ sprite_id = 42
178
+ sx = (sprite_id % 16) * 8
179
+ sy = (sprite_id // 16) * 8
180
+ for y in range(8):
181
+ row_pixels = lines[sy + y][sx:sx + 8]
182
+ print(row_pixels) # e.g. "00770700" — each digit is a color index
183
+ ```
184
+
185
+ ### Extract the tile map
186
+
187
+ The map is a grid of tile indices referencing sprites from the spritesheet:
188
+
189
+ ```python
190
+ import numpy as np
191
+ from PIL import Image
192
+
193
+ PICO8_PALETTE = [
194
+ (0,0,0), (29,43,83), (126,37,83), (0,135,81),
195
+ (171,82,54), (95,87,79), (194,195,199), (255,241,232),
196
+ (255,0,77), (255,163,0), (255,236,39), (0,228,54),
197
+ (41,173,255), (131,118,156), (255,119,168), (255,204,170),
198
+ ]
199
+
200
+ row = ds["train"][0]
201
+ map_data = row["map_data"] # flat list of uint8 tile indices
202
+ # Reshape to 32 rows x 128 columns (some carts use 64 rows, sharing sprite memory)
203
+ width = 128
204
+ height = len(map_data) // width
205
+ tiles = np.array(map_data).reshape(height, width)
206
+
207
+ print(f"Map size: {width}x{height} tiles = {width*8}x{height*8} pixels")
208
+ print(f"Unique tiles used: {len(np.unique(tiles))}")
209
+ ```
210
+
211
+ ### Parse sound effects
212
+
213
+ Each SFX slot contains 32 notes. The hex format encodes pitch, waveform, volume, and effect per note:
214
+
215
+ ```python
216
+ row = ds["train"][0]
217
+ sfx_lines = row["sfx_hex"].strip().split("\n")
218
+
219
+ for i, line in enumerate(sfx_lines[:4]): # First 4 SFX
220
+ # First 2 chars: editor mode, next 2: speed, next 2: loop start, next 2: loop end
221
+ header = line[:8]
222
+ notes = line[8:]
223
+ speed = int(header[2:4], 16)
224
+ print(f"SFX {i}: speed={speed}, {len(notes)//5} notes")
225
+ # Each note is 5 hex chars: pitch(2) waveform(1) volume(1) effect(1)
226
+ ```
227
+
228
+ ### Parse music patterns
229
+
230
+ Music patterns sequence up to 4 SFX channels together:
231
+
232
+ ```python
233
+ row = ds["train"][0]
234
+ music_lines = row["music_hex"].strip().split("\n")
235
+
236
+ for i, line in enumerate(music_lines[:8]):
237
+ # Each line: 2 flag chars + 4 channel values (2 hex chars each)
238
+ flags = int(line[0:2], 16)
239
+ channels = [int(line[2+j*2:4+j*2], 16) for j in range(4)]
240
+ # Bit 0-2 of each channel byte: loop flags; bits 6+: SFX index (0-63, 65+ = off)
241
+ ch_display = [f"sfx {c & 0x3f}" if c < 65 else "---" for c in channels]
242
+ print(f"Pattern {i}: {' | '.join(ch_display)} flags={flags:08b}")
243
+ ```
244
+
245
+ ## Quality Distribution
246
+
247
+ <p align="center">
248
+ <img src="quality_analysis.png" alt="Quality analysis plots" width="900">
249
+ </p>
250
+
251
+ | Star Tier | Count | % |
252
+ |-----------|------:|---:|
253
+ | 0 stars | 858 | 7.8% |
254
+ | 1-4 stars | 4,049 | 36.8% |
255
+ | 5-9 stars | 2,653 | 24.1% |
256
+ | 10-49 stars | 2,868 | 26.0% |
257
+ | 50-99 stars | 206 | 1.9% |
258
+ | 100-199 stars | 246 | 2.2% |
259
+ | 200+ stars | 133 | 1.2% |
260
+
261
+ **Suggested quality tiers for downstream use:**
262
+ - **Featured** (200+ stars): 133 exceptional games — Celeste, POOM, Porklike, etc.
263
+ - **High quality** (50+ stars): 585 polished, community-recognized games
264
+ - **Solid** (10+ stars): 3,453 games that found an audience
265
+ - **Full corpus**: 10,967 games including experiments, demos, tools, and art
266
+
267
+ Use `is_duplicate=False` to exclude 53 carts that are exact code copies of higher-starred originals (mostly Celeste/Jelpi mods).
268
+
269
+ ## About PICO-8
270
+
271
+ [PICO-8](https://www.lexaloffle.com/pico-8.php) is a fantasy console by [Lexaloffle](https://www.lexaloffle.com/) — a deliberately constrained environment for making tiny games:
272
+
273
+ - **Display**: 128x128 pixels, 16 fixed colors
274
+ - **Code**: Lua subset, max 8,192 tokens / 65,535 characters
275
+ - **Sprites**: 256 8x8 sprites on a 128x128 sheet
276
+ - **Map**: 128x32 tiles (or 128x64 sharing sprite memory)
277
+ - **Sound**: 64 SFX slots, 64 music patterns, 4 channels
278
+ - **Input**: 6 buttons (directional pad + O/X)
279
+
280
+ Every game's complete source code, art, sound, and music fits in a single `.p8.png` file — a 160x205 PNG with data steganographically encoded in the least significant bits.
281
+
282
+ ## How This Dataset Was Built
283
+
284
+ 1. **Index**: Scraped all ~368 pages of the [PICO-8 BBS Releases](https://www.lexaloffle.com/bbs/?cat=7#sub=2) category
285
+ 2. **Download**: Fetched 10,999 `.p8.png` cart files (14 were unavailable)
286
+ 3. **Parse**: Converted each cart to `.p8` text format using [shrinko8](https://github.com/thisismypassport/shrinko8), then extracted all sections
287
+ 4. **Render**: Generated spritesheet and map PNGs using the PICO-8 palette
288
+ 5. **Quality**: Computed entry point flags, duplicate detection, and star/engagement metadata
289
+
290
+ Data was collected in March 2026. The scraper respected rate limits (1.5s between requests) and identified itself via User-Agent.
291
+
292
+ ## Citation
293
+
294
+ ```bibtex
295
+ @dataset{pico8games2026,
296
+ title={PICO-8 Games Dataset},
297
+ author={Fraser Greenlee},
298
+ year={2026},
299
+ url={https://huggingface.co/datasets/Fraser/pico-8-games},
300
+ note={10,967 PICO-8 cartridges from the Lexaloffle BBS}
301
+ }
302
+ ```
303
+
304
+ ## License
305
+
306
+ 71% of carts in this dataset are released under [CC4-BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/4.0/) by their authors. The remaining 29% have no explicit license specified. Filter on the `license` column for your use case. The dataset metadata and tooling are released under CC-BY-NC-SA-4.0.