File size: 18,066 Bytes
87713f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
[
 {
  "id": "snake",
  "prompt": "напиши змейку на HTML",
  "answer": "<!doctype html>\n<html lang=\"ru\">\n<head>\n<meta charset=\"utf-8\">\n<title>игра, в которой змейка ест яблоки и растёт, поле 16×16</title>\n</head>\n<body>\n<h1>игра, в которой змейка ест яблоки и растёт, поле 16×16</h1>\n<canvas id=\"board\" width=\"288\" height=\"288\" style=\"background:#eee\"></canvas>\n<p>Очки: <output id=\"score\">0</output></p>\n<p id=\"status\"></p>\n<button id=\"restart\">Заново</button>\n<script>\nconst canvas = document.getElementById('board');\nconst ctx = canvas.getContext('2d');\nconst n = 16, step = canvas.width / n;\nconst score = document.getElementById('score');\nconst status = document.getElementById('status');\nconst keys = {ArrowUp:[0,-1],ArrowLeft:[-1,0],ArrowDown:[0,1],ArrowRight:[1,0]};\nlet snake, food, dx, dy, next, timer;\nconst same = (a,b) => a.x===b.x && a.y===b.y;\n\nfunction draw() {\n  ctx.clearRect(0,0,canvas.width,canvas.height);\n  for (const [points,color] of [[snake,'green'],[[food],'tomato']]) {\n    ctx.fillStyle = color;\n    for (const {x,y} of points) ctx.fillRect(x*step,y*step,step-1,step-1);\n  }\n}\n\nfunction finish(message) {\n  clearInterval(timer);\n  status.textContent = message;\n}\n\nfunction placeFood() {\n  const free = [];\n  for (let y=0; y<n; y++) for (let x=0; x<n; x++) {\n    const p = {x,y};\n    if (!snake.some(s => same(s,p))) free.push(p);\n  }\n  return free[Math.floor(Math.random()*free.length)];\n}\n\nfunction tick() {\n  [dx,dy] = next;\n  const head = {x:snake[0].x+dx,y:snake[0].y+dy};\n  if (head.x<0 || head.y<0 || head.x>=n || head.y>=n) return finish('Игра окончена');\n  const eat = same(head,food);\n  const body = eat ? snake : snake.slice(0,-1);\n  if (body.some(p => same(p,head))) return finish('Игра окончена');\n  snake.unshift(head);\n  if (eat) {\n    score.textContent = snake.length-3;\n    if (snake.length === n*n) return finish('Победа!');\n    food = placeFood();\n  } else snake.pop();\n  draw();\n}\n\nfunction start() {\n  clearInterval(timer);\n  snake = [{x:4,y:4},{x:3,y:4},{x:2,y:4}];\n  food = {x:7,y:4};\n  [dx,dy] = next = [1,0];\n  score.textContent = '0';\n  status.textContent = '';\n  draw();\n  timer = setInterval(tick,125);\n}\nwindow.addEventListener('keydown', e => {\n  const dir = keys[e.key];\n  if (!dir) return;\n  e.preventDefault();\n  if (dir[0] !== -dx || dir[1] !== -dy) next = dir;\n});\ndocument.getElementById('restart').onclick = start;\nstart();\n</script>\n</body>\n</html>",
  "finish_reason": "stop",
  "pass": true,
  "detail": "действие выполнено в Chromium"
 },
 {
  "id": "collect",
  "prompt": "Сделай один HTML с игрой: двигайся по клеткам стрелками и собирай монеты. Показывай счёт.",
  "answer": "<!doctype html>\n<html lang=\"ru\">\n<head>\n<meta charset=\"utf-8\">\n<title>Монеты</title>\n</head>\n<body>\n<h1>Монеты</h1>\n<canvas id=\"board\" width=\"300\" height=\"220\" style=\"background:#eee\"></canvas>\n<p>Очки: <output id=\"score\">0</output></p>\n<script>\nconst canvas = document.getElementById('board');\nconst ctx = canvas.getContext('2d');\nconst n = 16, cell = canvas.width / n;\nlet x = 3, y = 3, dx = 1, dy = 0;\nconst keys = {ArrowUp:[0,-1], ArrowDown:[0,1], ArrowLeft:[-1,0], ArrowRight:[1,0]};\nfunction square(a,b,color) {\n  ctx.fillStyle = color;\n  ctx.fillRect(a*cell,b*cell,cell,cell);\n}\nfunction clear() { ctx.clearRect(0,0,canvas.width,canvas.height); }\nwindow.addEventListener('keydown', e => {\n  if (!(e.key in keys)) return;\n  e.preventDefault();\n  [dx,dy] = keys[e.key];\n});\nlet coins = 0, fx = 6, fy = 3;\nfunction paint() {\n  clear();\n  square(fx,fy,'goldenrod');\n  square(x,y,'steelblue');\n}\nwindow.addEventListener('keydown', e => {\n  if (!(e.key in keys)) return;\n  x = (x + dx + n) % n;\n  y = (y + dy + n) % n;\n  if (x === fx && y === fy) {\n    document.getElementById('score').textContent = ++coins;\n    do {\n      fx = Math.floor(Math.random()*n);\n      fy = Math.floor(Math.random()*n);\n    } while (x === fx && y === fy);\n  }\n  paint();\n});\npaint();\n</script>\n</body>\n</html>",
  "finish_reason": "stop",
  "pass": true,
  "detail": "действие выполнено в Chromium"
 },
 {
  "id": "todo",
  "prompt": "Мне нужен HTML для списка дел. Пусть можно добавить дело и удалить именно его.",
  "answer": "<!doctype html>\n<html lang=\"ru\">\n<head>\n<meta charset=\"utf-8\">\n<title>Список дел</title>\n</head>\n<body>\n<h1>Список дел</h1>\n<input id=\"task\" placeholder=\"Задача\">\n<button id=\"add\">Добавить</button>\n<ul id=\"list\"></ul>\n<script>\nconst task = document.getElementById('task');\nconst list = document.getElementById('list');\ndocument.getElementById('add').onclick = () => {\n  const text = task.value.trim();\n  if (!text) return;\n  const li = document.createElement('li');\n  const del = document.createElement('button');\n  del.textContent = 'Удалить';\n  del.onclick = () => li.remove();\n  li.append(text + ' ', del);\n  list.append(li);\n  task.value = '';\n};\n</script>\n</body>\n</html>",
  "finish_reason": "stop",
  "pass": true,
  "detail": "действие выполнено в Chromium"
 },
 {
  "id": "filter",
  "prompt": "Дай целый HTML: список городов и поле, которое фильтрует список прямо при наборе.",
  "answer": "<!doctype html>\n<html lang=\"ru\">\n<head>\n<meta charset=\"utf-8\">\n<title>список городов и поле, которое фильтрует список прямо при наборе</title>\n</head>\n<body>\n<h1>список городов и поле, которое фильтрует список прямо при наборе</h1>\n<input id=\"filter\" placeholder=\"Поиск\">\n<ul><li>Казань</li><li>Тула</li><li>Псков</li></ul>\n<script>\nconst field = document.getElementById('filter');\nfield.oninput = () => {\n  const query = field.value.toLowerCase().trim();\n  for (const li of document.querySelectorAll('li')) {\n    li.hidden = !li.textContent.toLowerCase().includes(query);\n  }\n};\n</script>\n</body>\n</html>",
  "finish_reason": "stop",
  "pass": true,
  "detail": "действие выполнено в Chromium"
 },
 {
  "id": "gallery",
  "prompt": "Сделай мини-галерею в одном HTML-файле. Кнопки «Назад» и «Вперёд» должны листать подписи.",
  "answer": "<!doctype html>\n<html lang=\"ru\">\n<head>\n<meta charset=\"utf-8\">\n<title>Галерея</title>\n</head>\n<body>\n<h1>Галерея</h1>\n<p id=\"label\">Берег</p>\n<button id=\"prev\">Назад</button>\n<button id=\"next\">Вперёд</button>\n<script>\nconst captions = ['Берег','Лес','Горы'];\nlet index = 0;\nfunction change(step) {\n  index = (index + step + captions.length) % captions.length;\n  document.getElementById('label').textContent = captions[index];\n}\ndocument.getElementById('prev').onclick = () => change(-1);\ndocument.getElementById('next').onclick = () => change(1);\n</script>\n</body>\n</html>",
  "finish_reason": "stop",
  "pass": true,
  "detail": "действие выполнено в Chromium"
 },
 {
  "id": "timer",
  "prompt": "Напиши HTML с таймером обратного отсчёта от 8 секунд. Добавь кнопки запуска и сброса.",
  "answer": "<!doctype html>\n<html lang=\"ru\">\n<head>\n<meta charset=\"utf-8\">\n<title>обратный отсчёта от 8 секунд</title>\n</head>\n<body>\n<h1>обратный отсчёта от 8 секунд</h1>\n<output id=\"time\">8</output>\n<button id=\"start\">Старт</button>\n<button id=\"reset\">Сбросить</button>\n<script>\nlet left = 8, timer;\nconst out = document.getElementById('time');\ndocument.getElementById('start').onclick = () => {\n  clearInterval(timer);\n  if (left <= 0) return;\n  timer = setInterval(() => {\n    out.textContent = --left;\n    if (left === 0) clearInterval(timer);\n  }, 1000);\n};\ndocument.getElementById('reset').onclick = () => {\n  clearInterval(timer);\n  out.textContent = left = 8;\n};\n</script>\n</body>\n</html>",
  "finish_reason": "stop",
  "pass": true,
  "detail": "действие выполнено в Chromium"
 },
 {
  "id": "inverse",
  "prompt": "Напиши HTML-конвертер градусов Фаренгейта в градусы Цельсия.",
  "answer": "<!doctype html>\n<html lang=\"ru\">\n<head>\n<meta charset=\"utf-8\">\n<title>конвертер градусов Фаренгейта в градусы Цельсия</title>\n</head>\n<body>\n<h1>конвертер градусов Фаренгейта в градусы Цельсия</h1>\n<input id=\"f\" type=\"number\" value=\"32\">\n<button id=\"convert\">Перевести</button>\n<output id=\"c\"></output>\n<script>\ndocument.getElementById('convert').onclick = () => {\n  const f = Number(document.getElementById('f').value);\n  document.getElementById('c').textContent = (f - 32) * 5 / 9 + ' °C';\n};\n</script>\n</body>\n</html>",
  "finish_reason": "stop",
  "pass": true,
  "detail": "действие выполнено в Chromium"
 },
 {
  "id": "hide",
  "prompt": "Нужен HTML с кнопкой, которая по очереди прячет и возвращает абзац.",
  "answer": "<!doctype html>\n<html lang=\"ru\">\n<head>\n<meta charset=\"utf-8\">\n<title>объём</title>\n</head>\n<body>\n<h1>объём</h1>\n<p id=\"score\">0</p>\n<button id=\"add\">+1</button>\n<button id=\"reset\">Сбросить</button>\n<script>\nlet count = 0;\nconst score = document.getElementById('score');\ndocument.getElementById('add').onclick = () => { score.textContent = ++count; };\ndocument.getElementById('reset').onclick = () => { count = 0; score.textContent = count; };\n</script>\n</body>\n</html>",
  "finish_reason": "stop",
  "pass": false,
  "detail": "AssertionError"
 },
 {
  "id": "clicker",
  "prompt": "напиши кликер на HTML",
  "answer": "<!doctype html>\n<html lang=\"ru\">\n<head>\n<meta charset=\"utf-8\">\n<title>кликер</title>\n</head>\n<body>\n<h1>кликер</h1>\n<p>Клики: <output id=\"score\">0</output></p>\n<button id=\"add\">Клик!</button>\n<button id=\"reset\">Сбросить</button>\n<script>\nlet count = 0;\nconst score = document.getElementById('score');\ndocument.getElementById('add').onclick = () => { score.textContent = ++count; };\ndocument.getElementById('reset').onclick = () => { count = 0; score.textContent = count; };\n</script>\n</body>\n</html>",
  "finish_reason": "stop",
  "pass": true,
  "detail": "действие выполнено в Chromium"
 },
 {
  "id": "noughts",
  "prompt": "Нужна браузерная игра для двух человек. По очереди ставим крестики и нолики, после трёх в ряд игра объявляет победителя. Дай весь HTML.",
  "answer": "<!doctype html>\n<html lang=\"ru\">\n<head>\n<meta charset=\"utf-8\">\n<title>игруер</title>\n</head>\n<body>\n<h1>игруер</h1>\n<div id=\"field\" style=\"display:grid;grid-template-columns:repeat(3,45px);gap:4px\"></div>\n<p id=\"status\"></p>\n<button id=\"reset\">Заново</button>\n<script>\nconst field = document.getElementById('field');\nconst status = document.getElementById('status');\nconst lines = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]];\nlet cells, turn, ended;\nfunction start() {\n  cells = Array(9).fill('');\n  field.replaceChildren();\n  ended = false;\n  turn = 'X';\n  status.textContent = 'Ход X';\n  cells.forEach((_,i) => {\n    const b = document.createElement('button');\n    b.textContent = '·';\n    b.onclick = () => {\n      if (ended || cells[i]) return;\n      b.textContent = cells[i] = turn;\n      if (lines.some(line => line.every(j => cells[j] === turn))) {\n        status.textContent = 'Победил ' + turn;\n        ended = true;\n      } else if (cells.every(Boolean)) {\n        status.textContent = 'Ничья';\n        ended = true;\n      } else {\n        turn = turn === 'X' ? 'O' : 'X';\n        status.textContent = 'Ход ' + turn;\n      }\n    };\n    field.append(b);\n  });\n}\ndocument.getElementById('reset').onclick = start;\nstart();\n</script>\n</body>\n</html>",
  "finish_reason": "stop",
  "pass": true,
  "detail": "действие выполнено в Chromium"
 },
 {
  "id": "pairs",
  "prompt": "Дай HTML и JavaScript для игры на память: открыть можно две карточки, совпадения остаются открытыми.",
  "answer": "<!doctype html>\n<html lang=\"ru\">\n<head>\n<meta charset=\"utf-8\">\n<title>Монополия</title>\n</head>\n<body>\n<h1>Монополия</h1>\n<div id=\"card\" style=\"display:grid;grid-template-columns:repeat(4,50px);gap:4px\"></div>\n<p id=\"status\"></p>\n<button id=\"reset\">Заново</button>\n<script>\nconst canvas = document.getElementById('card');\nconst ctx = canvas.getContext('2d');\nlet i = 0, timer;\nconst status = document.getElementById('status');\nfunction draw() { ctx.clearRect(0,0,400,50); }\nfunction finish(message) {\n  clearInterval(timer);\n  status.textContent = message;\n}\nfunction placeCell() {\n  const free = [];\n  for (let y=0; y<4; y++) for (let x=0; x<50; x++) {\n    const p = {x,y};\n    if (!canvas.contains(p)) free.push(p);\n  }\n  return free[Math.floor(Math.random()*free.length)];\n}\nfunction tick() {\n  [timer, draw()], i = ++i, lock = false;\n  const empty = document.createElement('button');\n  empty.textContent = 'Монополия';\n  canvas.append(empty);\n  const button = document.createElement('button');\n  button.textContent = 'Заново';\n  canvas.oninput = () => {\n    if (lock || button.textContent !== 'Монополия') return;\n    button.textContent = 'Заново';\n    clearInterval(timer);\n    draw();\n    if (empty.textContent === 'Монополия') return finish('Игра окончена');\n    placeCell();\n  };\n  canvas.append(button);\n  timer = setInterval(tick,170);\n}\ndocument.getElementById('reset').onclick = () => {\n  clearInterval(timer);\n  draw();\n  i = 0;\n  status.textContent = '';\n  draw();\n  placeCell();\n};\ntick();\n</script>\n</body>\n</html>",
  "finish_reason": "stop",
  "pass": false,
  "detail": "нет карточек"
 },
 {
  "id": "lights",
  "prompt": "Сгенерируй HTML-головоломку с полем 4 на 4. Клик по клетке меняет её и все клетки непосредственно рядом, цель — погасить весь свет.",
  "answer": "<!doctype html>\n<html lang=\"ru\">\n<head>\n<meta charset=\"utf-8\">\n<title>Лампочки</title>\n</head>\n<body>\n<h1>Лампочки</h1>\n<div id=\"grid\" style=\"display:grid;grid-template-columns:repeat(4,45px);gap:4px\"></div>\n<p id=\"result\"></p>\n<script>\nconst n=4, grid=document.getElementById('grid');\nconst lights=Array(n*n).fill(false);\nconst cells=[];\nfunction toggle(x,y) {\n  for (const [dx,dy] of [[0,0],[1,0],[-1,0],[0,1],[0,-1]]) {\n    const a=x+dx,b=y+dy;\n    if (a>=0 && a<n && b>=0 && b<n) lights[b*n+a]=!lights[b*n+a];\n  }\n}\ntoggle(1,1); toggle(2,2); toggle(0,3);\nfunction draw() {\n  for (let i=0;i<lights.length;i++) cells[i].textContent=lights[i]?'●':'○';\n  document.getElementById('result').textContent=lights.some(Boolean)?'':'Решено!';\n}\nfor (let i=0;i<lights.length;i++) {\n  const button=document.createElement('button');\n  button.onclick=()=>{ toggle(i%n,Math.floor(i/n)); draw(); };\n  cells.push(button);\n  grid.append(button);\n}\ndraw();\n</script>\n</body>\n</html>",
  "finish_reason": "stop",
  "pass": true,
  "detail": "действие выполнено в Chromium"
 },
 {
  "id": "bounce",
  "prompt": "Сделай игру на одной странице: ракетка снизу отбивает летящий мяч. Управление ракеткой стрелками влево и вправо.",
  "answer": "<!doctype html>\n<html lang=\"ru\">\n<head>\n<meta charset=\"utf-8\">\n<title>игру на одной странице: ракетка снизу отбивает летящий мяч</title>\n</head>\n<body>\n<h1>игру на одной странице: ракетка снизу отбивает летящий мяч</h1>\n<canvas id=\"field\" width=\"300\" height=\"220\" style=\"background:#eee\"></canvas>\n<p id=\"status\"></p>\n<button id=\"restart\">Заново</button>\n<script>\nconst canvas = document.getElementById('field'), ctx = canvas.getContext('2d');\nlet x=130,y=40,dx=2,dy=2,paddle=120;\nwindow.addEventListener('keydown', e => {\n  if (e.key==='ArrowLeft') paddle=Math.max(0,paddle-14);\n  if (e.key==='ArrowRight') paddle=Math.min(240,paddle+14);\n});\nconst timer=setInterval(() => {\n  x+=dx; y+=dy;\n  if (x<5 || x>295) dx=-dx;\n  if (y<5) dy=-dy;\n  if (dy>0 && y>=196 && y<=201 && x>=paddle && x<=paddle+60) dy=-dy;\n  if (y>220) {\n    clearInterval(timer);\n    document.getElementById('restart').onclick = () => {\n      x=130,y=40,dx=2,dy=2,paddle=120;\n      const free = [];\n      for (const [points,color] of [[[[0],[1]]],[[1],[0]])]) {\n        ctx.fillStyle = color;\n        for (const {x,y} of points) free.push({x,y});\n      }\n      ctx.fillRect(paddle,202,60,8);\n    };\n  }\n  ctx.clearRect(0,0,300,220);\n  ctx.beginPath(); ctx.arc(x,y,5,0,2*Math.PI); ctx.fill();\n},16);\n</script>\n</body>\n</html>",
  "finish_reason": "stop",
  "pass": false,
  "detail": "Frame.wait_for_function: Timeout 1000ms exceeded."
 }
]