extremely claude-assisted go game based on atproto! working on cleaning up and giving a more unique design, still has a bit of a slop vibe to it.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix OG image board state extraction from tenuki

Tenuki returns intersections as a flat array with {x, y, value}
properties, not a 2D array. Convert to 2D board state correctly.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

+26 -10
+26 -10
src/routes/og-image/[id]/+server.ts
··· 45 45 game.id // AT URI 46 46 ); 47 47 48 + console.log(`OG image: Found ${moves.length} moves for game ${gameRkey}`); 49 + 48 50 if (moves.length > 0) { 49 51 // Create a tenuki game and replay moves 50 52 const tenukiGame = new tenuki.Game({ boardSize }); 51 53 52 54 for (const move of moves) { 53 55 try { 54 - tenukiGame.playAt(move.y, move.x); // tenuki uses (y, x) format 56 + // tenuki uses (y, x) format where y is row and x is column 57 + const result = tenukiGame.playAt(move.y, move.x); 58 + console.log(`OG image: Playing move at (${move.x}, ${move.y}) color=${move.color}, result=${result}`); 55 59 lastMove = { x: move.x, y: move.y }; 56 - } catch { 57 - // Skip invalid moves 60 + } catch (moveErr) { 61 + console.error(`OG image: Failed to play move at (${move.x}, ${move.y}):`, moveErr); 58 62 } 59 63 } 60 64 61 65 // Extract board state from tenuki 62 - boardState = tenukiGame.currentState().intersections.map((row: any[]) => 63 - row.map((intersection: any) => { 64 - if (intersection.isBlack()) return 'black'; 65 - if (intersection.isWhite()) return 'white'; 66 - return null; 67 - }) 68 - ); 66 + // Note: tenuki returns a FLAT array of intersections with {x, y, value} properties 67 + const state = tenukiGame.currentState(); 68 + console.log(`OG image: Board state intersections:`, state.intersections?.length); 69 + 70 + if (state.intersections) { 71 + // Initialize empty 2D board 72 + boardState = Array.from({ length: boardSize }, () => 73 + Array.from({ length: boardSize }, () => null as 'black' | 'white' | null) 74 + ); 75 + 76 + // Fill in the stones from the flat array 77 + for (const intersection of state.intersections) { 78 + if (intersection.value === 'black' || intersection.value === 'white') { 79 + boardState[intersection.y][intersection.x] = intersection.value; 80 + } 81 + } 82 + } 83 + 84 + console.log(`OG image: Extracted board state, stones:`, boardState.flat().filter(s => s !== null).length); 69 85 } 70 86 } catch (err) { 71 87 console.error('Failed to fetch moves for OG image:', err);