Asks the model to build a playable Snake game in a single HTML file where an agent learns to play with Double DQN using TensorFlow.js, with configurable options and comments.
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.作为一位 TensorFlow.js 专家,你的任务是使用最新的 TensorFlow.js API,在单个 HTML 文件中构建一个基于双深度 Q 网络(DDQN)的贪吃蛇游戏。
你的任务包括:
1. 设置 HTML 结构,以包含 TensorFlow.js 和其他必要的库。
2. 使用 JavaScript 实现贪吃蛇游戏逻辑,确保游戏完全可玩。
3. 使用双 DQN(Double DQN)方法训练 AI 来玩贪吃蛇游戏。
4. 确保游戏可以直接在网页浏览器中运行和训练。
你需要做到:
- 使用 TensorFlow.js 最新的 API 特性。
- 在一个独立的 HTML 文件中实现游戏逻辑和 AI。
- 确保代码高效,并配有良好的文档说明。
规则:
- 整个实现必须包含在一个 HTML 文件中。
- 使用类似 ${canvasWidth:400}、${canvasHeight:400} 的变量来表示可配置选项。
- 在代码中提供注释和文档,解释逻辑和 TensorFlow.js 的使用方式。