{
"id": "129",
"prompt": "Reflex game: a ring shrinks around a random hash-placed center; tap inside it before it collapses to respawn it bigger elsewhere and score, with the shrink rate growing with my score. Color the ring by remaining radius using a match with ranges (40..=60 green, 20..40 amber, else red). A collapse is game over with hits plus best and a restart tap.",
"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 ring_color(r: i32) -> i32 {\n match r {\n 40..=60 => 0x00cc66,\n 20..40 => 0xffaa00,\n _ => 0xff3333,\n }\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, 1);\n host::display::state_set(2, 240);\n host::display::state_set(3, 0);\n host::display::state_set(5, 0);\n }\n let down: i32 = host::display::pointer_down();\n let tap: bool = down == 1 && host::display::state_get(6) == 0;\n host::display::state_set(6, down);\n let score: i32 = host::display::state_get(3);\n if host::display::state_get(5) == 1 {\n host::display::clear(0x101010);\n host::display::draw_string(110, 180, \"IT SLIPPED AWAY\", 0xff4040, 3);\n host::display::draw_string(130, 250, \"HITS\", 0x808080, 2);\n host::display::draw_number(230, 244, score, 0xffffff, 3);\n host::display::draw_string(130, 284, \"BEST\", 0x808080, 2);\n host::display::draw_number(230, 278, host::display::state_get(4), 0x00ff88, 3);\n host::display::draw_string(130, 350, \"TAP TO CHASE\", 0x808080, 2);\n if tap { host::display::state_set(0, 0); }\n } else {\n let round: i32 = host::display::state_get(1);\n let cx: i32 = 60 + hash(round * 3) % (w - 120);\n let cy: i32 = 80 + hash(round * 3 + 1) % (h - 160);\n let mut rf: i32 = host::display::state_get(2);\n let mut shrink: i32 = 2 + score / 3;\n if shrink > 8 { shrink = 8; }\n rf = rf - shrink;\n let r: i32 = rf / 4;\n if r <= 6 {\n host::display::state_set(5, 1);\n if score > host::display::state_get(4) {\n host::display::state_set(4, score);\n }\n }\n if tap {\n let dx: i32 = host::display::pointer_x() - cx;\n let dy: i32 = host::display::pointer_y() - cy;\n if dx * dx + dy * dy <= r * r {\n host::display::state_set(3, score + 1);\n host::display::state_set(1, round + 1);\n rf = 240;\n }\n }\n host::display::state_set(2, rf);\n host::display::clear(0x0c0c14);\n host::display::fill_rect(cx - r, cy - r, 2 * r, 2 * r, ring_color(r));\n let inner: i32 = r * 2 / 3;\n host::display::fill_rect(cx - inner, cy - inner, 2 * inner, 2 * inner, 0x0c0c14);\n host::display::fill_rect(cx - 3, cy - 3, 6, 6, 0xffffff);\n host::display::draw_string(8, 8, \"HITS\", 0x808080, 2);\n host::display::draw_number(90, 8, score, 0xffffff, 2);\n }\n host::display::present();\n}\n",
"tags": [
"game",
"state",
"prng",
"match"
]
}