{"id":"mod_checkers","type":"module","version":"1.1","context":{"title":"Checkers","icon":"⚫️"},"state":{"board":["","b","","b","","b","","b","b","","b","","b","","b","","","b","","b","","b","","b","","","","","","","","","","","","","","","","","r","","r","","r","","r","","","r","","r","","r","","r","r","","r","","r","","r",""],"turn":"r","selected":-1,"winner":"","message":"Red moves first","mustJump":false,"showToast":false,"toastText":"","aiThinking":false,"aiFrom":-1,"aiTo":-1,"aiCaptured":-1,"aiSeq":0},"dependencies":[{"service":{"audio":{"id":"chk_audio"}}},{"repository":{"ai":{"id":"chk_ai_repo","config":{}}}},{"repository":{"local":{"id":"chk_store","config":{}}}}],"children":[{"id":"chk_root","type":"vstack","context":{"_spacing":18,"_alignment":"center"},"style":{"layout":{"maxWidth":"infinity","maxHeight":"infinity","padding":{"top":18,"bottom":20,"leading":14,"trailing":14}},"common":{"background":{"gradient":{"linear":{"colors":[{"light":"#1B1A1F","dark":"#0D0D10"},{"light":"#2A2330","dark":"#17131D"}],"startPoint":"topLeading","endPoint":"bottomTrailing"}}}}},"children":[{"id":"chk_status_card","type":"vstack","context":{"_spacing":8,"_alignment":"center"},"style":{"layout":{"maxWidth":"infinity","padding":18},"common":{"background":{"gradient":{"linear":{"colors":["#7A3E2B","#C76B3D"],"startPoint":"topLeading","endPoint":"bottomTrailing"}}},"foreground":{"color":"white"},"cornerRadius":22,"glass":"regular"},"shadow":{"color":{"color":"black","opacity":0.22},"radius":12,"y":8},"animation":{"kind":"spring","value":"${turn}","duration":0.3,"bounce":0.35}},"children":[{"id":"chk_turn_icon","type":"image","context":{"_source":"{{ notEmpty(${winner}) ? 'sf://crown.fill' : ${turn} == 'r' ? 'sf://circle.fill' : 'sf://circle.circle.fill' }}"},"style":{"layout":{"width":24,"height":24},"common":{"foreground":{"color":"white"}}}},{"id":"chk_turn_text","type":"text","context":{"_text":"{{ notEmpty(${winner}) ? ${winner} == 'r' ? 'Red wins' : 'Black wins' : ${turn} == 'r' ? 'Red to move' : 'Black to move' }}"},"style":{"common":{"font":{"kind":"title3","weight":"bold"},"foreground":{"color":"white"}}}},{"id":"chk_message_text","type":"text","context":{"_text":"${message}"},"style":{"common":{"font":"subheadline","foreground":{"color":{"color":"white","opacity":0.86}}},"text":{"multilineTextAlignment":"center"}}},{"id":"chk_counts_row","type":"hstack","context":{"_spacing":18,"_alignment":"center"},"children":[{"id":"chk_red_count","type":"label","context":{"_title":"{{ cast(sum(map(${board}, @{item} == 'r' || @{item} == 'R' ? 1 : 0)), 'str') + ' red' }}","_image":"sf://circle.fill"},"style":{"common":{"font":"caption","foreground":{"color":"white"}}}},{"id":"chk_black_count","type":"label","context":{"_title":"{{ cast(sum(map(${board}, @{item} == 'b' || @{item} == 'B' ? 1 : 0)), 'str') + ' black' }}","_image":"sf://circle.circle.fill"},"style":{"common":{"font":"caption","foreground":{"color":"white"}}}}]}],"events":{"onChange":{"observed":"aiSeq","actions":[{"condition":{"id":"chk_ai_apply_guard","input":"{{ ${aiSeq} > 0 && (${board[${aiFrom}]} == 'b' || ${board[${aiFrom}]} == 'B') && empty(${board[${aiTo}]}) && (${aiCaptured} < 0 || ${board[${aiCaptured}]} == 'r' || ${board[${aiCaptured}]} == 'R') }}","output":{"success":[{"state":{"id":"chk_ai_apply","input":{"board":"{{ setAt(${aiCaptured} >= 0 ? setAt(setAt(${board}, ${aiFrom}, ''), ${aiCaptured}, '') : setAt(${board}, ${aiFrom}, ''), ${aiTo}, ${board[${aiFrom}]} == 'b' && cast(${aiTo} / 8, 'int') == 7 ? 'B' : ${board[${aiFrom}]}) }}","turn":"r","selected":-1,"mustJump":false,"winner":"{{ ${aiCaptured} >= 0 && sum(map(${board}, @{item} == 'r' || @{item} == 'R' ? 1 : 0)) == 1 ? 'b' : '' }}","message":"{{ ${aiCaptured} >= 0 && sum(map(${board}, @{item} == 'r' || @{item} == 'R' ? 1 : 0)) == 1 ? 'Black wins' : 'Red to move' }}","toastText":"{{ ${aiCaptured} >= 0 ? 'Black captured' : 'Black moved' }}","showToast":true},"output":{"success":[{"repo":{"id":"chk_persist_ai","input":{"repositoryId":"chk_store","operation":"create","params":{"collection":"save","documentId":"game","rewrite":true,"body":{"board":"${board}","turn":"${turn}","mustJump":"${mustJump}","winner":"${winner}"}}}}}]}}},{"service":{"id":"chk_ai_apply_haptic","input":{"serviceId":"chk_audio","params":{"sound":"keyPress","haptic":"light"}}}}],"failure":[{"state":{"id":"chk_ai_apply_skip","input":{"turn":"r","message":"{{ 'Black tried ' + cast(${aiFrom},'str') + '->' + cast(${aiTo},'str') + ' cap ' + cast(${aiCaptured},'str') + ' (rejected)' }}","toastText":"Illegal AI move","showToast":true}}}]}}}]}}},{"id":"chk_board_card","type":"vstack","context":{"_spacing":10,"_alignment":"center"},"style":{"layout":{"maxWidth":"infinity","padding":12},"common":{"background":{"light":"#2A2420","dark":"#201B18"},"cornerRadius":24,"glass":"regular"},"shadow":{"color":{"color":"black","opacity":0.18},"radius":10,"y":6}},"children":[{"id":"chk_board_grid","type":"grid","context":{"_gridType":"lazyVGrid","_spacing":2},"style":{"grid":{"columns":[{"kind":"flexible","minimum":30,"maximum":60,"spacing":2},{"kind":"flexible","minimum":30,"maximum":60,"spacing":2},{"kind":"flexible","minimum":30,"maximum":60,"spacing":2},{"kind":"flexible","minimum":30,"maximum":60,"spacing":2},{"kind":"flexible","minimum":30,"maximum":60,"spacing":2},{"kind":"flexible","minimum":30,"maximum":60,"spacing":2},{"kind":"flexible","minimum":30,"maximum":60,"spacing":2},{"kind":"flexible","minimum":30,"maximum":60,"spacing":2}]},"layout":{"maxWidth":"infinity"}},"children":[{"id":"chk_cells_dynamic","type":"dynamic","context":{"_data":"${board}"},"prototype":{"id":"chk_cell_button","type":"button","context":{"_label":"","cellIndex":"@{index}","cellValue":"@{item}","cellRow":"{{ cast(@{index} / 8, 'int') }}","cellCol":"{{ @{index} % 8 }}","selPiece":"{{ ${selected} >= 0 ? ${board[${selected}]} : '' }}","selRow":"{{ ${selected} >= 0 ? cast(${selected} / 8, 'int') : -1 }}","selCol":"{{ ${selected} >= 0 ? ${selected} % 8 : -1 }}","rowDiff":"{{ cast(@{index} / 8, 'int') - (${selected} >= 0 ? cast(${selected} / 8, 'int') : -1) }}","colDiff":"{{ (@{index} % 8) - (${selected} >= 0 ? ${selected} % 8 : -1) }}","midIndex":"{{ cast((${selected} + @{index}) / 2, 'int') }}","midPiece":"{{ ${selected} >= 0 ? ${board[@{midIndex}]} : '' }}","isKing":"{{ @{selPiece} == 'R' || @{selPiece} == 'B' }}","kdiag":"{{ @{rowDiff} != 0 && (@{rowDiff} == @{colDiff} || (@{rowDiff} + @{colDiff}) == 0) }}","kdist":"{{ @{rowDiff} > 0 ? @{rowDiff} : (0 - @{rowDiff}) }}","kstep":"{{ @{rowDiff} > 0 ? (@{colDiff} > 0 ? 9 : 7) : (@{colDiff} > 0 ? (0 - 7) : (0 - 9)) }}","kb1i":"{{ ${selected} + (@{kstep} * 1) }}","kb2i":"{{ ${selected} + (@{kstep} * 2) }}","kb3i":"{{ ${selected} + (@{kstep} * 3) }}","kb4i":"{{ ${selected} + (@{kstep} * 4) }}","kb5i":"{{ ${selected} + (@{kstep} * 5) }}","kb6i":"{{ ${selected} + (@{kstep} * 6) }}","kb1":"{{ @{kdist} > 1 ? ${board[@{kb1i}]} : '' }}","kb2":"{{ @{kdist} > 2 ? ${board[@{kb2i}]} : '' }}","kb3":"{{ @{kdist} > 3 ? ${board[@{kb3i}]} : '' }}","kb4":"{{ @{kdist} > 4 ? ${board[@{kb4i}]} : '' }}","kb5":"{{ @{kdist} > 5 ? ${board[@{kb5i}]} : '' }}","kb6":"{{ @{kdist} > 6 ? ${board[@{kb6i}]} : '' }}","kocc":"{{ (notEmpty(@{kb1}) ? 1 : 0) + (notEmpty(@{kb2}) ? 1 : 0) + (notEmpty(@{kb3}) ? 1 : 0) + (notEmpty(@{kb4}) ? 1 : 0) + (notEmpty(@{kb5}) ? 1 : 0) + (notEmpty(@{kb6}) ? 1 : 0) }}","kenemy":"{{ @{selPiece} == 'R' ? ((@{kb1} == 'b' || @{kb1} == 'B') ? 1 : 0) + ((@{kb2} == 'b' || @{kb2} == 'B') ? 1 : 0) + ((@{kb3} == 'b' || @{kb3} == 'B') ? 1 : 0) + ((@{kb4} == 'b' || @{kb4} == 'B') ? 1 : 0) + ((@{kb5} == 'b' || @{kb5} == 'B') ? 1 : 0) + ((@{kb6} == 'b' || @{kb6} == 'B') ? 1 : 0) : ((@{kb1} == 'r' || @{kb1} == 'R') ? 1 : 0) + ((@{kb2} == 'r' || @{kb2} == 'R') ? 1 : 0) + ((@{kb3} == 'r' || @{kb3} == 'R') ? 1 : 0) + ((@{kb4} == 'r' || @{kb4} == 'R') ? 1 : 0) + ((@{kb5} == 'r' || @{kb5} == 'R') ? 1 : 0) + ((@{kb6} == 'r' || @{kb6} == 'R') ? 1 : 0) }}","kcapIdx":"{{ (notEmpty(@{kb1}) ? @{kb1i} : 0) + (notEmpty(@{kb2}) ? @{kb2i} : 0) + (notEmpty(@{kb3}) ? @{kb3i} : 0) + (notEmpty(@{kb4}) ? @{kb4i} : 0) + (notEmpty(@{kb5}) ? @{kb5i} : 0) + (notEmpty(@{kb6}) ? @{kb6i} : 0) }}","capturedIdx":"{{ (@{selPiece} == 'R' || @{selPiece} == 'B') ? @{kcapIdx} : @{midIndex} }}","isOwnPiece":"{{ ${turn} == 'r' ? (@{item} == 'r' || @{item} == 'R') : (@{item} == 'b' || @{item} == 'B') }}","isLegalStep":"{{ empty(@{cellValue}) && ${selected} >= 0 && (@{selPiece} == 'r' && @{rowDiff} == -1 && (@{colDiff} == -1 || @{colDiff} == 1) || @{selPiece} == 'b' && @{rowDiff} == 1 && (@{colDiff} == -1 || @{colDiff} == 1) || @{isKing} && @{kdiag} && @{kocc} == 0) }}","isLegalCapture":"{{ empty(@{cellValue}) && ${selected} >= 0 && (@{selPiece} == 'r' && @{rowDiff} == -2 && (@{colDiff} == -2 || @{colDiff} == 2) && (@{midPiece} == 'b' || @{midPiece} == 'B') || @{selPiece} == 'b' && @{rowDiff} == 2 && (@{colDiff} == -2 || @{colDiff} == 2) && (@{midPiece} == 'r' || @{midPiece} == 'R') || @{isKing} && @{kdiag} && @{kocc} == 1 && @{kenemy} == 1) }}","isLegalMove":"{{ ${mustJump} ? @{isLegalCapture} : (@{isLegalStep} || @{isLegalCapture}) }}","fjAm":"{{ @{index} - 9 }}","fjA":"{{ @{index} - 18 }}","fjBm":"{{ @{index} - 7 }}","fjB":"{{ @{index} - 14 }}","hasManJump":"{{ @{selPiece} == 'r' && @{cellRow} >= 2 && ((@{cellCol} >= 2 && (${board[@{fjAm}]} == 'b' || ${board[@{fjAm}]} == 'B') && empty(${board[@{fjA}]})) || (@{cellCol} <= 5 && (${board[@{fjBm}]} == 'b' || ${board[@{fjBm}]} == 'B') && empty(${board[@{fjB}]}))) }}","canChain":"{{ @{isLegalCapture} && (@{selPiece} == 'R' || @{hasManJump}) }}"},"style":{"button":{"custom":{"layout":{"maxWidth":"infinity","height":44},"common":{"background":"{{ ${selected} == @{cellIndex} ? '#E0B14A' : ((@{cellRow} + @{cellCol}) % 2 == 0 ? '#E8D7BF' : '#7B5338') }}","cornerRadius":8}}}},"children":[{"id":"chk_cell_layer","type":"zstack","context":{"_alignment":"center"},"style":{"layout":{"maxWidth":"infinity","maxHeight":"infinity"}},"children":[{"id":"chk_move_hint","type":"conditional","context":{"_condition":"@{isLegalMove}","_trueComponent":{"id":"chk_move_hint_dot","type":"circle","style":{"layout":{"width":12,"height":12},"shape":{"fill":{"color":"white","opacity":0.35}}}},"_falseComponent":{"id":"chk_move_hint_none","type":"empty"}}},{"id":"chk_piece_cond","type":"conditional","context":{"_condition":"{{ notEmpty(@{cellValue}) }}","_trueComponent":{"id":"chk_piece_stack","type":"zstack","context":{"_alignment":"center"},"children":[{"id":"chk_piece_circle","type":"circle","style":{"layout":{"width":30,"height":30},"shape":{"fill":{"gradient":{"linear":{"colors":["{{ @{cellValue} == 'r' || @{cellValue} == 'R' ? '#FF7A59' : '#4B5563' }}","{{ @{cellValue} == 'r' || @{cellValue} == 'R' ? '#B93D2D' : '#111827' }}"],"startPoint":"topLeading","endPoint":"bottomTrailing"}}},"stroke":{"content":{"color":"white","opacity":0.25},"style":{"lineWidth":1}}}}},{"id":"chk_piece_king","type":"conditional","context":{"_condition":"{{ @{cellValue} == 'R' || @{cellValue} == 'B' }}","_trueComponent":{"id":"chk_piece_king_text","type":"text","context":{"_text":"K"},"style":{"common":{"font":{"kind":"caption","weight":"bold"},"foreground":{"color":"white"}}}},"_falseComponent":{"id":"chk_piece_king_none","type":"empty"}}}]},"_falseComponent":{"id":"chk_piece_none","type":"empty"}}}]}],"events":{"onTap":[{"condition":{"id":"chk_guard_game_active","input":"{{ empty(${winner}) && ${turn} == 'r' }}","output":{"success":[{"condition":{"id":"chk_guard_no_selection","input":"{{ ${selected} < 0 }}","output":{"success":[{"condition":{"id":"chk_guard_pick_own_piece","input":"@{isOwnPiece}","output":{"success":[{"state":{"id":"chk_select_piece","input":{"selected":"@{cellIndex}","message":"{{ ${turn} == 'r' ? 'Red piece selected' : 'Black piece selected' }}"}}}],"failure":[{"state":{"id":"chk_pick_hint","input":{"message":"{{ ${turn} == 'r' ? 'Select a red piece' : 'Select a black piece' }}","toastText":"{{ ${turn} == 'r' ? 'Select a red piece' : 'Select a black piece' }}","showToast":true}}},{"service":{"id":"chk_pick_hint_haptic","input":{"serviceId":"chk_audio","params":{"sound":"none","haptic":"warning"}}}}]}}}],"failure":[{"condition":{"id":"chk_guard_tap_same","input":"{{ ${selected} == @{cellIndex} }}","output":{"success":[{"state":{"id":"chk_deselect_piece","input":{"selected":-1,"turn":"{{ ${mustJump} ? (${turn} == 'r' ? 'b' : 'r') : ${turn} }}","mustJump":false,"message":"{{ ${mustJump} ? (${turn} == 'r' ? 'Black to move' : 'Red to move') : 'Selection cleared' }}"}}}],"failure":[{"condition":{"id":"chk_guard_reselect_own_piece","input":"{{ !${mustJump} && @{isOwnPiece} }}","output":{"success":[{"state":{"id":"chk_reselect_piece","input":{"selected":"@{cellIndex}","message":"Piece changed"}}}],"failure":[{"condition":{"id":"chk_guard_legal_move","input":"@{isLegalMove}","output":{"success":[{"state":{"id":"chk_make_move","input":{"board":"{{ setAt(setAt(setAt(${board}, ${selected}, ''), @{capturedIdx}, @{isLegalCapture} ? '' : ${board[@{capturedIdx}]}), @{index}, @{selPiece} == 'r' && @{cellRow} == 0 ? 'R' : @{selPiece} == 'b' && @{cellRow} == 7 ? 'B' : @{selPiece}) }}","selected":"{{ @{canChain} ? @{index} : -1 }}","mustJump":"{{ @{canChain} }}","turn":"{{ @{canChain} ? ${turn} : (${turn} == 'r' ? 'b' : 'r') }}","winner":"{{ @{isLegalCapture} && ${turn} == 'r' && sum(map(${board}, @{item} == 'b' || @{item} == 'B' ? 1 : 0)) == 1 ? 'r' : @{isLegalCapture} && ${turn} == 'b' && sum(map(${board}, @{item} == 'r' || @{item} == 'R' ? 1 : 0)) == 1 ? 'b' : '' }}","message":"{{ @{isLegalCapture} && ${turn} == 'r' && sum(map(${board}, @{item} == 'b' || @{item} == 'B' ? 1 : 0)) == 1 ? 'Red wins' : @{isLegalCapture} && ${turn} == 'b' && sum(map(${board}, @{item} == 'r' || @{item} == 'R' ? 1 : 0)) == 1 ? 'Black wins' : @{canChain} ? 'Captured! Jump again, or tap the piece to end your turn' : (${turn} == 'r' ? 'Black to move' : 'Red to move') }}","toastText":"{{ (@{selPiece} == 'r' && @{cellRow} == 0) || (@{selPiece} == 'b' && @{cellRow} == 7) ? 'King me' : @{isLegalCapture} ? 'Capture' : 'Move' }}","showToast":true},"output":{"success":[{"repo":{"id":"chk_persist_move","input":{"repositoryId":"chk_store","operation":"create","params":{"collection":"save","documentId":"game","rewrite":true,"body":{"board":"${board}","turn":"${turn}","mustJump":"${mustJump}","winner":"${winner}"}}}}}]}}},{"service":{"id":"chk_move_haptic","input":{"serviceId":"chk_audio","params":{"sound":"keyPress","haptic":"light"}}}}],"failure":[{"state":{"id":"chk_bad_move","input":{"message":"Illegal move","toastText":"Illegal move","showToast":true}}},{"service":{"id":"chk_bad_move_haptic","input":{"serviceId":"chk_audio","params":{"sound":"none","haptic":"warning"}}}}]}}}]}}}]}}}]}}}],"failure":[{"state":{"id":"chk_game_over_tap","input":{"message":"{{ notEmpty(${winner}) ? 'Game over — start a new game' : 'Black is thinking…' }}","toastText":"{{ notEmpty(${winner}) ? 'Game over' : 'Wait for Black' }}","showToast":true}}}]}}}]}}}]},{"id":"chk_board_note","type":"text","context":{"_text":"You play red against an AI opponent (black). Tap a red piece, then a highlighted square. Kings fly any distance diagonally; multi-jumps chain. Captures are optional (not forced)."},"style":{"common":{"font":"caption","foreground":{"color":"secondary"}},"text":{"multilineTextAlignment":"center"}}}]},{"id":"chk_actions_row","type":"hstack","context":{"_spacing":10,"_alignment":"center"},"style":{"layout":{"maxWidth":"infinity"}},"children":[{"id":"chk_reset_btn","type":"button","context":{"_label":"New game","_image":"sf://arrow.counterclockwise"},"style":{"button":{"custom":{"layout":{"maxWidth":"infinity","minHeight":48},"common":{"background":{"gradient":{"linear":{"colors":["#A44E2D","#D97B42"],"startPoint":"leading","endPoint":"trailing"}}},"foreground":{"color":"white"},"cornerRadius":16,"font":{"kind":"headline"}}}}},"events":{"onTap":[{"state":{"id":"chk_reset_game","input":{"board":["","b","","b","","b","","b","b","","b","","b","","b","","","b","","b","","b","","b","","","","","","","","","","","","","","","","","r","","r","","r","","r","","","r","","r","","r","","r","r","","r","","r","","r",""],"turn":"r","selected":-1,"winner":"","message":"Red moves first","mustJump":false,"toastText":"Board reset","showToast":true},"output":{"success":[{"repo":{"id":"chk_persist_reset","input":{"repositoryId":"chk_store","operation":"create","params":{"collection":"save","documentId":"game","rewrite":true,"body":{"board":"${board}","turn":"${turn}","mustJump":"${mustJump}","winner":"${winner}"}}}}}]}}},{"service":{"id":"chk_reset_haptic","input":{"serviceId":"chk_audio","params":{"sound":"none","haptic":"success"}}}}]}},{"id":"chk_clear_selection_btn","type":"button","context":{"_label":"Clear","_image":"sf://hand.tap"},"style":{"button":{"standard":{"type":"bordered","shape":"capsule"}}},"events":{"onTap":[{"state":{"id":"chk_clear_selection","input":{"selected":-1,"turn":"{{ ${mustJump} ? (${turn} == 'r' ? 'b' : 'r') : ${turn} }}","mustJump":false,"message":"{{ ${mustJump} ? 'Turn ended' : 'Selection cleared' }}"}}}]}}]},{"id":"chk_toast","type":"text","context":{"_text":"${toastText}"},"style":{"layout":{"padding":{"top":9,"bottom":9,"leading":16,"trailing":16}},"common":{"background":{"material":"ultraThin"},"foreground":{"color":"white"},"cornerRadius":18,"font":"subheadline","opacity":"{{ ${showToast} ? 1.0 : 0.0 }}","scale":"{{ ${showToast} ? 1.0 : 0.9 }}"},"animation":{"kind":"spring","value":"${showToast}","duration":0.35,"bounce":0.25}},"events":{"onChange":{"observed":"showToast","actions":[{"condition":{"id":"chk_toast_guard","input":"${showToast}","output":{"success":[{"interval":{"id":"chk_toast_timer","input":{"delay":1.5},"output":{"success":[{"state":{"id":"chk_hide_toast","input":{"showToast":false}}},{"interval":{"id":"chk_toast_timer","input":{"cancel":true}}}]}}}]}}}]}}},{"id":"chk_bottom_spacer","type":"spacer"}],"events":{"onAppear":[{"repo":{"id":"chk_load","input":{"repositoryId":"chk_store","operation":"read","params":{"collection":"save","documentId":"game"}},"output":{"success":[{"state":{"id":"chk_restore","input":{"board":"@{chk_load.board}","turn":"@{chk_load.turn}","mustJump":"@{chk_load.mustJump}","winner":"@{chk_load.winner}","selected":-1,"aiThinking":false}}}],"failure":[]}}}]}}],"events":{"onChange":{"observed":"turn","actions":[{"condition":{"id":"chk_ai_turn_guard","input":"{{ ${turn} == 'b' && empty(${winner}) }}","output":{"success":[{"state":{"id":"chk_ai_thinking","input":{"aiThinking":true,"selected":-1,"message":"Black is thinking…"},"output":{"success":[{"ai":{"id":"chk_ai_move","input":{"provider":"chk_ai_repo","body":{"tier":"strong","system":"This is a grid-logic task. A grid arrives as a JSON array of 64 cells; each cell has sq (0-63), row (0-7, top to bottom), col (0-7), and token ('empty', 'b', 'B', 'r', 'R'). Return ONE valid move for a 'b' token. MOVE RULES: a 'b' token at (row,col) advances to an EMPTY cell at (row+1,col-1) or (row+1,col+1) — one diagonal step. If an 'r' or 'R' token sits at an adjacent down-diagonal (row+1,col±1) and the cell beyond at (row+2,col±2) is empty, the 'b' may instead advance to that empty cell, clearing the token it passed over. A 'B' token may advance any number of EMPTY cells along a diagonal, and may clear a single 'r'/'R' that stands alone on an otherwise-empty diagonal, landing on an empty cell beyond it. If a clearing move exists, choose one. The destination must be 'empty'; the move must be a true diagonal; a token with no empty diagonal ahead has no move. Return sq indices: from (the 'b' token), to (the empty destination), captured (the sq of the token passed over, or -1 if none).","prompt":"Return one valid move for a 'b' token on this grid.","schema":{"type":"object","properties":{"from":{"type":"integer"},"to":{"type":"integer"},"captured":{"type":"integer"}},"required":["from","to","captured"],"additionalProperties":false},"data":"{{ map(${board}, { 'sq': @{index}, 'row': cast(@{index} / 8, 'int'), 'col': @{index} % 8, 'piece': (empty(@{item}) ? 'empty' : @{item}) }) }}"}},"output":{"success":[{"state":{"id":"chk_store_oai","input":{"aiFrom":"@{chk_ai_move.from}","aiTo":"@{chk_ai_move.to}","aiCaptured":"@{chk_ai_move.captured}","aiThinking":false,"aiSeq":"{{ ${aiSeq} + 1 }}"}}}],"failure":[{"state":{"id":"chk_ai_error","input":{"turn":"r","aiThinking":false,"message":"{{ 'Black is unavailable — ' + @{chk_ai_move.message} }}","toastText":"@{chk_ai_move.message}","showToast":true}}}]}}}]}}}]}}}]}}}