{
"id": "114",
"prompt": "Dodge-the-falling-blocks game: three grey blocks fall at different speeds with columns picked by an LCG hash per respawn, I slide a square along the bottom with the pointer, and the HUD counts seconds survived. One touch kills - show survived time plus the best run (kept in a state slot) and let me tap to retry.",
"solution_rl": "fn hash(seed: i32) -> i32 {\n let mut h: i32 = seed * 747796405 + 2891336453;\n h = (h >> 16) ^ h;\n if h < 0 { h = 0 - h; }\n h\n}\n\nfn frame(t: i32) {\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(1, -20);\n host::display::state_set(2, -180);\n host::display::state_set(3, -340);\n host::display::state_set(4, 1);\n host::display::state_set(5, 2);\n host::display::state_set(6, 3);\n host::display::state_set(7, 0);\n host::display::state_set(10, t);\n }\n let down: i32 = host::display::pointer_down();\n let tap: bool = down == 1 && host::display::state_get(8) == 0;\n host::display::state_set(8, down);\n if host::display::state_get(7) == 1 {\n host::display::clear(0x100010);\n host::display::draw_string(160, 180, \"CRUSHED\", 0xff4040, 4);\n host::display::draw_string(120, 250, \"SURVIVED\", 0x808080, 2);\n host::display::draw_number(270, 250, host::display::state_get(11), 0xffffff, 2);\n host::display::draw_string(120, 285, \"BEST\", 0x808080, 2);\n host::display::draw_number(270, 285, host::display::state_get(9), 0x00ff88, 2);\n host::display::draw_string(140, 340, \"TAP TO RETRY\", 0x808080, 2);\n if tap { host::display::state_set(0, 0); }\n } else {\n let mut px: i32 = host::display::pointer_x() - 16;\n if px < 0 { px = 0; }\n if px > w - 32 { px = w - 32; }\n let py: i32 = h - 44;\n let sec: i32 = (t - host::display::state_get(10)) / 60;\n host::display::state_set(11, sec);\n host::display::clear(0x0a0a12);\n host::display::fill_rect(px, py, 32, 32, 0x00ddff);\n let mut i: i32 = 0;\n while i < 3 {\n let mut ry: i32 = host::display::state_get(1 + i);\n let rnd: i32 = host::display::state_get(4 + i);\n let rx: i32 = hash(rnd * 100 + i) % (w - 32);\n let spd: i32 = 3 + hash(rnd * 7 + i) % 4;\n ry = ry + spd;\n if ry > h {\n host::display::state_set(4 + i, rnd + 1);\n ry = -30 - hash(rnd * 13 + i) % 120;\n }\n host::display::state_set(1 + i, ry);\n if rx + 32 > px && rx < px + 32 && ry + 32 > py && ry < py + 32 {\n host::display::state_set(7, 1);\n if sec > host::display::state_get(9) {\n host::display::state_set(9, sec);\n }\n }\n host::display::fill_rect(rx, ry, 32, 32, 0x8a8a92);\n host::display::fill_rect(rx + 6, ry + 6, 8, 8, 0x5a5a62);\n i = i + 1;\n }\n host::display::draw_number(8, 6, sec, 0xffffff, 3);\n }\n host::display::present();\n}\n",
"tags": [
"game",
"state",
"prng"
]
}