{
"id": "255",
"prompt": "Autumn leaves on the wind: six leaves blow left-to-right, pushed by a shared gust strength that mixes two sine-table reads at different tempos (clamped so it never goes below a breeze), while each leaf flutters vertically on its own phase-offset sine. A leaf that exits the right edge respawns at the left at an LCG-random height. Leaf positions persist in state slots in 1/8-px fixed point; draw a wind-strength bar in the corner and tint the leaves from a small autumn palette.",
"solution_rl": "fn frame(t: i32) {\n let tab = [0, 25, 49, 71, 90, 106, 117, 124, 127, 124, 117, 106, 90, 71, 49, 25, 0, -25, -49, -71, -90, -106, -117, -124, -127, -124, -117, -106, -90, -71, -49, -25];\n let w: i32 = host::display::width();\n let h: i32 = host::display::height();\n if host::display::state_get(0) == 0 {\n host::display::state_set(0, 1);\n host::display::state_set(2, 4242);\n let mut i: i32 = 0;\n while i < 6 {\n host::display::state_set(8 + i * 2, i * 70 * 8);\n host::display::state_set(9 + i * 2, (50 + i * 60) * 8);\n i = i + 1;\n }\n }\n let mut gust: i32 = 12 + tab[(t / 5) & 31] * 8 / 127 + tab[(t / 13) & 31] * 4 / 127;\n if gust < 2 { gust = 2; }\n host::display::clear(0x101812);\n let pal: [i32; 3] = [0xc07030, 0xa08020, 0x907040];\n let mut i: i32 = 0;\n while i < 6 {\n let mut x: i32 = host::display::state_get(8 + i * 2);\n let mut y: i32 = host::display::state_get(9 + i * 2);\n let flut: i32 = tab[(t * 2 + i * 11) & 31] * 6 / 127;\n x = x + gust;\n y = y + 3 + flut;\n if x > w * 8 {\n x = -80;\n let seed: i32 = host::display::state_get(2) * 1103515245 + 12345;\n host::display::state_set(2, seed);\n y = (20 + ((seed >> 16) & 4095) % (h - 40)) * 8;\n }\n if y > (h - 8) * 8 { y = 16 * 8; }\n if y < 8 { y = (h - 16) * 8; }\n host::display::state_set(8 + i * 2, x);\n host::display::state_set(9 + i * 2, y);\n host::display::fill_rect(x / 8, y / 8, 12, 8, pal[i % 3]);\n i = i + 1;\n }\n host::display::fill_rect(8, 12, gust * 10, 6, 0x608090);\n host::display::draw_string(8, 24, \"WIND\", 0x707070, 1);\n host::display::present();\n}\n",
"tags": [
"simulation",
"wind",
"sine-table",
"state"
]
}