
         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         
{"id":"gen-1775641242-P9zOHkYu8t2LXF0moKlO","object":"chat.completion","created":1775641242,"model":"anthropic/claude-4.6-opus-20260205","provider":"Amazon Bedrock","system_fingerprint":null,"choices":[{"index":0,"logprobs":null,"finish_reason":"stop","native_finish_reason":"end_turn","message":{"role":"assistant","content":"\n\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<title>Conway's Game of Life</title>\n<style>\n* {\n    margin: 0;\n    padding: 0;\n    overflow: hidden;\n}\nbody {\n    background: white;\n}\ncanvas {\n    display: block;\n}\n</style>\n</head>\n<body>\n<canvas id=\"c\"></canvas>\n<script>\nconst canvas = document.getElementById('c');\nconst ctx = canvas.getContext('2d');\nconst CELL = 24;\n\nlet cols, rows, grid, next;\n\nfunction resize() {\n    canvas.width = window.innerWidth;\n    canvas.height = window.innerHeight;\n    const newCols = Math.ceil(canvas.width / CELL);\n    const newRows = Math.ceil(canvas.height / CELL);\n    const newGrid = [];\n    for (let y = 0; y < newRows; y++) {\n        newGrid[y] = [];\n        for (let x = 0; x < newCols; x++) {\n            newGrid[y][x] = (grid && y < rows && x < cols) ? grid[y][x] : 0;\n        }\n    }\n    cols = newCols;\n    rows = newRows;\n    grid = newGrid;\n    next = [];\n    for (let y = 0; y < rows; y++) {\n        next[y] = new Array(cols).fill(0);\n    }\n}\n\nfunction init() {\n    resize();\n    for (let y = 0; y < rows; y++) {\n        for (let x = 0; x < cols; x++) {\n            grid[y][x] = Math.random() < 0.15 ? 1 : 0;\n        }\n    }\n}\n\nfunction countNeighbors(g, x, y) {\n    let sum = 0;\n    for (let dy = -1; dy <= 1; dy++) {\n        for (let dx = -1; dx <= 1; dx++) {\n            if (dx === 0 && dy === 0) continue;\n            const ny = (y + dy + rows) % rows;\n            const nx = (x + dx + cols) % cols;\n            sum += g[ny][nx];\n        }\n    }\n    return sum;\n}\n\nfunction step() {\n    for (let y = 0; y < rows; y++) {\n        for (let x = 0; x < cols; x++) {\n            const n = countNeighbors(grid, x, y);\n            if (grid[y][x] === 1) {\n                next[y][x] = (n === 2 || n === 3) ? 1 : 0;\n            } else {\n                next[y][x] = (n === 3) ? 1 : 0;\n            }\n        }\n    }\n    const tmp = grid;\n    grid = next;\n    next = tmp;\n}\n\nfunction draw() {\n    ctx.fillStyle = 'white';\n    ctx.fillRect(0, 0, canvas.width, canvas.height);\n\n    ctx.strokeStyle = 'rgba(0,0,0,0.06)';\n    ctx.lineWidth = 0.5;\n    for (let x = 0; x <= cols; x++) {\n        ctx.beginPath();\n        ctx.moveTo(x * CELL, 0);\n        ctx.lineTo(x * CELL, rows * CELL);\n        ctx.stroke();\n    }\n    for (let y = 0; y <= rows; y++) {\n        ctx.beginPath();\n        ctx.moveTo(0, y * CELL);\n        ctx.lineTo(cols * CELL, y * CELL);\n        ctx.stroke();\n    }\n\n    ctx.fillStyle = 'red';\n    for (let y = 0; y < rows; y++) {\n        for (let x = 0; x < cols; x++) {\n            if (grid[y][x] === 1) {\n                ctx.fillRect(x * CELL + 1, y * CELL + 1, CELL - 2, CELL - 2);\n            }\n        }\n    }\n}\n\nlet mouseDown = false;\n\ncanvas.addEventListener('mousedown', (e) => {\n    mouseDown = true;\n    toggle(e);\n});\ncanvas.addEventListener('mousemove', (e) => {\n    if (mouseDown) toggle(e);\n});\ncanvas.addEventListener('mouseup', () => { mouseDown = false; });\n\nfunction toggle(e) {\n    const x = Math.floor(e.clientX / CELL);\n    const y = Math.floor(e.clientY / CELL);\n    if (x >= 0 && x < cols && y >= 0 && y < rows) {\n        grid[y][x] = 1;\n    }\n}\n\ndocument.addEventListener('keydown', (e) => {\n    const cx = Math.floor(cols / 2);\n    const cy = Math.floor(rows / 2);\n    const patterns = [\n        [[0,0],[1,0],[2,0],[2,1],[1,2]],\n        [[0,0],[1,0],[2,0]],\n        [[0,0],[1,0],[2,0],[0,1],[1,2]],\n        [[0,0],[0,1],[1,0],[1,1],[2,2],[2,3],[3,2],[3,3]],\n        [[0,1],[1,2],[2,0],[2,1],[2,2]]\n    ];\n    const p = patterns[Math.floor(Math.random() * patterns.length)];\n    const ox = cx - 1 + Math.floor(Math.random() * 10 - 5);\n    const oy = cy - 1 + Math.floor(Math.random() * 10 - 5);\n    for (const [dx, dy] of p) {\n        const nx = (ox + dx + cols) % cols;\n        const ny = (oy + dy + rows) % rows;\n        grid[ny][nx] = 1;\n    }\n});\n\nwindow.addEventListener('resize', resize);\n\ninit();\n\nfunction loop() {\n    step();\n    draw();\n    requestAnimationFrame(loop);\n}\nloop();\n</script>\n</body>\n</html>","refusal":null,"reasoning":null}}],"usage":{"prompt_tokens":3350,"completion_tokens":1591,"total_tokens":4941,"cost":0,"is_byok":true,"prompt_tokens_details":{"cached_tokens":0,"cache_write_tokens":0,"audio_tokens":0,"video_tokens":0},"cost_details":{"upstream_inference_cost":0.056525,"upstream_inference_prompt_cost":0.01675,"upstream_inference_completions_cost":0.039775},"completion_tokens_details":{"reasoning_tokens":0,"image_tokens":0,"audio_tokens":0}}}