{
"id": "139",
"prompt": "Number flash memory test: a 3-digit number from an LCG hash shows for a shrinking beat, disappears, then two candidate cards appear - the real number and a near-miss decoy, with the true position hashed too. Tap the card I actually saw: right answers build a streak and shorten the flash toward a floor, one wrong answer shows the truth, streak and best, and a tap starts a new game.",
"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, 1);\n host::display::state_set(2, 0);\n host::display::state_set(3, 0);\n host::display::state_set(4, 0);\n host::display::state_set(7, 50);\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 round: i32 = host::display::state_get(1);\n let phase: i32 = host::display::state_get(2);\n let num: i32 = 100 + hash(round * 3) % 900;\n let mut delta: i32 = 1 + hash(round * 5) % 9;\n if hash(round * 11) % 2 == 0 { delta = -delta; }\n let mut decoy: i32 = num + delta;\n if decoy < 100 { decoy = num + 9; }\n let real_top: i32 = hash(round * 7) % 2;\n if phase == 2 {\n host::display::clear(0x181008);\n host::display::draw_string(120, 160, \"MEMORY FAULT\", 0xff4040, 3);\n host::display::draw_string(100, 220, \"THE NUMBER WAS\", 0x808080, 2);\n host::display::draw_number(370, 214, num, 0xffffff, 3);\n host::display::draw_string(100, 270, \"STREAK\", 0x808080, 2);\n host::display::draw_number(240, 264, host::display::state_get(4), 0xffffff, 3);\n host::display::draw_string(100, 304, \"BEST\", 0x808080, 2);\n host::display::draw_number(240, 298, host::display::state_get(5), 0x00ff88, 3);\n host::display::draw_string(110, 370, \"TAP TO TRY AGAIN\", 0x808080, 2);\n if tap {\n host::display::state_set(0, 0);\n }\n } else if phase == 0 {\n let timer: i32 = host::display::state_get(3) + 1;\n host::display::state_set(3, timer);\n host::display::clear(0x0c0c14);\n host::display::draw_string(140, 100, \"MEMORIZE\", 0x808080, 2);\n host::display::draw_number(w / 2 - 54, h / 2 - 24, num, 0xffffff, 8);\n if timer >= host::display::state_get(7) {\n host::display::state_set(2, 1);\n host::display::state_set(3, 0);\n }\n } else {\n let mut top_num: i32 = decoy;\n let mut bot_num: i32 = num;\n if real_top == 1 {\n top_num = num;\n bot_num = decoy;\n }\n if tap {\n let mut picked_top: i32 = 0;\n if host::display::pointer_y() < h / 2 { picked_top = 1; }\n if picked_top == real_top {\n let s: i32 = host::display::state_get(4) + 1;\n host::display::state_set(4, s);\n if s > host::display::state_get(5) {\n host::display::state_set(5, s);\n }\n let mut lim: i32 = host::display::state_get(7) - 2;\n if lim < 24 { lim = 24; }\n host::display::state_set(7, lim);\n host::display::state_set(1, round + 1);\n host::display::state_set(2, 0);\n host::display::state_set(3, 0);\n } else {\n host::display::state_set(2, 2);\n }\n }\n host::display::clear(0x0c0c14);\n host::display::draw_string(110, 20, \"WHICH ONE DID YOU SEE\", 0x808080, 2);\n host::display::fill_rect(w / 2 - 90, 70, 180, 120, 0x1c2436);\n host::display::draw_number(w / 2 - 40, 110, top_num, 0xffffff, 5);\n host::display::fill_rect(w / 2 - 90, h - 190, 180, 120, 0x1c2436);\n host::display::draw_number(w / 2 - 40, h - 150, bot_num, 0xffffff, 5);\n host::display::draw_number(8, 8, host::display::state_get(4), 0x00ff88, 2);\n }\n host::display::present();\n}\n",
"tags": [
"game",
"state",
"prng",
"ui"
]
}