Home / Prompts / Build a DDQN Snake Game with TensorFlow.js in a Single HTML File

Build a DDQN Snake Game with TensorFlow.js in a Single HTML File

Text promptCodingPublic domain (CC0)Editor pick on prompts.chat
65score

Fill in

The prompt below updates as you type.

Prompt

Act as a TensorFlow.js expert. You are tasked with building a Deep Q-Network (DDQN) based Snake game using the latest TensorFlow.js API, all within a single HTML file. 

Your task is to:
1. Set up the HTML structure to include TensorFlow.js and other necessary libraries.
2. Implement the Snake game logic using JavaScript, ensuring the game is fully playable.
3. Use a Double DQN approach to train the AI to play the Snake game.
4. Ensure the game can be played and trained directly within a web browser.

You will:
- Use TensorFlow.js's latest API features.
- Implement the game logic and AI in a single, self-contained HTML file.
- Ensure the code is efficient and well-documented.

Rules:
- The entire implementation must be contained within one HTML file.
- Use variables like ${canvasWidth:400}, ${canvasHeight:400} for configurable options.
- Provide comments and documentation within the code to explain the logic and TensorFlow.js usage.

Context cost: ≈237 tokens when used.

Why this score

Quality checklist33/40
Community votes7/30
Editor pick15/15
Fill-in fields10/10
Discussion0/5

Quality checklist

  • Sets a role: yes
  • States a clear task: yes
  • Gives context: no
  • Sets constraints: yes
  • Defines the output: yes
  • Breaks work into steps: yes

The checklist is automatic and applies the same rules to every prompt. It checks structure, not whether the output is good. Prompt scores aren't comparable with tool scores. How we rank

Security

Scanned Nov 4, 2026 at the text shown on this page, with Cisco's open-source skill-scanner.

None of the patterns we list turned up: shell commands, network requests, reading environment variables, downloading and running code, or installing packages.

A scan lists patterns in the code. It can't prove an add-on is harmless, and it can miss things, so read what you install. How we scan

Similar prompts

Prompts that do the same job, most voted first.

NameVotesScore
This oneBuild a DDQN Snake Game with TensorFlow.js in a Single HTML File Coding ▲ 165
Next.js Specialized Front-End Developer Coding Both about js and flow ▲ 259