Models 44
Train snakeOne-line

Nemotron 3 Nano Omni (free)

by NVIDIAReasoningClean
Open in new window

Running live in a sandboxed frame. Click inside it before using the keyboard.

How it went

Total time
20.6 s
Cost
$0
Output tokens
1,678
Spent thinking
0 tokens
Speed
83.3 tok/s
Console errors
0
First token after
431 ms
First visible text after
431 ms
Prompt tokens
379
Code size
5.3 KB
Finish reason
stop
Served by
Nvidia
Model id
nvidia/nemotron-3-nano-omni-30b-a3b-reasoning:free
Reasoning sent
{"effort":"none"}
Max output
32,000 tokens
Generated
Nov 9, 2026

What it was asked

The prompt
“make me a snake game where the snake is a little train with a locomotive and colorful wagons, picking up passengers waiting on the platform”
System prompt, sent with every prompt
You are generating a self-contained web demo. It will be rendered automatically in a sandboxed iframe and compared side by side with the output of other AI models given the exact same task.

Output rules:
- Reply with exactly ONE fenced code block containing the complete file: ```html (or ```svg when the task asks for an SVG). No text before or after the code block.
- Everything must be inline: CSS in <style>, JavaScript in <script>. No external files, images, fonts or network requests, except the CDN URLs explicitly allowed by the task.
- Do not use localStorage, sessionStorage, cookies, IndexedDB, alert(), confirm(), prompt() or window.open(): they are blocked in the sandbox and will throw.
- The page must look right in a 1280×800 viewport and adapt gracefully down to 375px wide. No horizontal scrollbar.
- Something meaningful must be visible on first paint: a screenshot is taken automatically about 3 seconds after load, without any interaction.
- Everything that makes the demo interesting must be visible within the first seconds: nothing hidden behind a high score, a later level or a long play session.
- Games must start in a self-playing demo mode (a simple AI plays) behind a "Click or press a key to start" message, so the game can be judged in action without playing.
- The iframe only receives keyboard events after the user clicks it: if the demo uses the keyboard, display a clear "Click or press a key to start" message.
- The code must run with zero errors in the console of the latest Chrome.

Code run-1.html · 194 lines

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Snake Train Game</title>
<style>
  body { margin:0; font-family:sans-serif; background:#111; display:flex; justify-content:center; align-items:center; height:100vh; }
  canvas { background:#222; border:2px solid #555; }
  #start-screen {
    position:absolute;
    top:0; left:0; right:0; bottom:0;
    display:flex; flex-direction:column; justify-content:center; align-items:center;
    color:#fff; text-align:center; font-size:24px;
    pointer-events:none;
  }
  #start-screen.visible { pointer-events:auto; }
  button {
    margin-top:20px;
    padding:10px 20px;
    font-size:18px;
    cursor:pointer;
  }
</style>
</head>
<body>
<canvas id="game" width="800" height="600"></canvas>
<div id="start-screen" class="visible">Click or press a key to start</div>

<script>
const canvas = document.getElementById('game');
const ctx = canvas.getContext('2d');
const tileSize = 20;
const cols = canvas.width / tileSize;
const rows = canvas.height / tileSize;

let snake = [{x: 5, y: 5}];
let direction = {x: 0, y: 0};
let nextDirection = {x: 0, y: 0};
let food = {x: 10, y: 10};
let passengers = [];
let score = 0;
let gameRunning = false;

// Train segments: head is first element, wagons follow
function drawTrain() {
  // Locomotive (head)
  ctx.fillStyle = '#ff6600';
  ctx.fillRect(snake[0].x * tileSize, snake[0].y * tileSize, tileSize, tileSize);
  // Wagons (colorful)
  const colors = ['#00ff00', '#00ffff', '#0000ff', '#ff00ff', '#ffff00', '#ff00aa'];
  for (let i = 1; i < snake.length; i++) {
    ctx.fillStyle = colors[(i - 1) % colors.length];
    ctx.fillRect(snake[i].x * tileSize, snake[i].y * tileSize, tileSize, tileSize);
  }
}

// Place a new passenger on a random empty platform cell
function spawnPassenger() {
  let valid = false;
  while (!valid) {
    const px = Math.floor(Math.random() * cols);
    const py = Math.floor(Math.random() * rows);
    // Ensure not on snake or existing passenger
    if (snake.some(seg => seg.x === px && seg.y === py)) continue;
    const occupied = passengers.some(p => p.x === px && p.y === py);
    if (!occupied) {
      passengers.push({x: px, y: py, collected: false});
      valid = true;
    }
  }
}

// Check if new head cell contains a passenger
function checkPassenger() {
  const head = snake[0];
  for (let i = 0; i < passengers.length; i++) {
    if (passengers[i].x === head.x && passengers[i].y === head.y && !passengers[i].collected) {
      passengers[i].collected = true;
      score++;
      // Remove collected passenger and spawn new one
      passengers.splice(i, 1);
      spawnPassenger();
    }
  }
}

// Game loop
function update() {
  if (!gameRunning) return;

  // Apply direction
  direction.x = nextDirection.x;
  direction.y = nextDirection.y;

  // Move snake
  const head = {x: snake[0].x + direction.x, y: snake[0].y + direction.y};

  // Wall collision
  if (head.x < 0 || head.x >= cols || head.y < 0 || head.y >= rows) {
    gameRunning = false;
    return;
  }

  // Self collision
  if (snake.some(seg => seg.x === head.x && seg.y === head.y)) {
    gameRunning = false;
    return;
  }

  // Add new head
  snake.unshift(head);

  // Check for passenger
  checkPassenger();

  // Check for food (optional, not used here)
  // if (head.x === food.x && head.y === food.y) { ... }

  // Remove tail if no passenger collected (snake grows only when passenger collected)
  if (!passengers.some(p => p.x === head.x && p.y === head.y && p.collected)) {
    snake.pop();
  }

  // Spawn new passenger occasionally
  if (Math.random() < 0.02) spawnPassenger();

  // Render
  ctx.clearRect(0, 0, canvas.width, canvas.height);
  drawTrain();

  // Draw passengers
  ctx.fillStyle = '#ffcc00';
  passengers.forEach(p => {
    if (!p.collected) {
      ctx.fillRect(p.x * tileSize, p.y * tileSize, tileSize, tileSize);
    }
  });

  // Draw score
  ctx.fillStyle = '#fff';
  ctx.font = '16px sans-serif';
  ctx.fillText('Score: ' + score, 10, 20);
}

// Keyboard handling
document.addEventListener('keydown', e => {
  if (!gameRunning) {
    // Start game on key press
    gameRunning = true;
    direction = {x: 0, y: 0};
    nextDirection = {x: 0, y: 0};
    snake = [{x: 5, y: 5}];
    score = 0;
    passengers = [];
    spawnPassenger();
    document.getElementById('start-screen').classList.remove('visible');
    return;
  }
  // Arrow keys or WASD
  if (e.key === 'ArrowUp' || e.key === 'w' || e.key === 'W') {
    if (direction.y === 0) nextDirection = {x: 0, y: -1};
  } else if (e.key === 'ArrowDown' || e.key === 's' || e.key === 'S') {
    if (direction.y === 0) nextDirection = {x: 0, y: 1};
  } else if (e.key === 'ArrowLeft' || e.key === 'a' || e.key === 'A') {
    if (direction.x === 0) nextDirection = {x: -1, y: 0};
  } else if (e.key === 'ArrowRight' || e.key === 'd' || e.key === 'D') {
    if (direction.x === 0) nextDirection = {x: 1, y: 0};
  }
});

// Touch handling for mobile
canvas.addEventListener('touchstart', e => {
  if (!gameRunning) {
    gameRunning = true;
    direction = {x: 0, y: 0};
    nextDirection = {x: 0, y: 0};
    snake = [{x: 5, y: 5}];
    score = 0;
    passengers = [];
    spawnPassenger();
    document.getElementById('start-screen').classList.remove('visible');
  }
});

// Game loop
function loop() {
  update();
  requestAnimationFrame(loop);
}
loop();
</script>
</body>
</html>