用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/zhizhunbao/gangwon-business-portal --skill code-comment命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| name | code-comment |
| description | 中英文双语代码注释规范。Use when (1) 为代码添加注释, (2) 需要中英双语文档, (3) 规范化代码注释格式, (4) 学习类项目代码注释 |
| Location | Language | Format |
|---|---|---|
| File-level docstring | English only | Standard docstring |
| Function docstring | Chinese + English | Two-line format: Chinese first line, English second line |
| Inline comments | Chinese + English | Chinese line, then English line, above code |
| Code spacing | - | Blank line between code blocks |
"""
Lab 2: Q-Learning Agent for Cliff Walking
Student ID: 041107730
Implements Q-Learning using Bellman equation: Q(s,a) = r + γ * max Q(s',a')
Modified from Hybrid Activity 1 to solve the Cliff Walking problem.
"""
Two lines with Chinese first line, English second line:
def train(env, episodes: int = 50, gamma: float = 0.9) -> list:
"""训练Q-Learning智能体
Train Q-Learning agent"""
def reset() -> tuple:
"""重置环境到初始状态
Reset environment to initial state"""
Rules:
"""Chinese comment immediately followed by English comment, placed ABOVE code:
# 初始化Q表,使用随机值
# Initialize Q-table with random values
qtable = [[random.random() for _ in range(env.actions())] for _ in range(env.states())]
# 增加步数计数
# Increment step count
steps += 1
Rules:
# 使用贝尔曼方程更新Q表:Q(s,a) = r + γ * max Q(s',a')
# Update Q-table using Bellman equation: Q(s,a) = r + γ * max Q(s',a')
qtable[state][action] = reward + gamma * max(qtable[next_state])
# 衰减探索率,随着学习进行减少随机探索
# Decay exploration rate, reduce random exploration as learning progresses
epsilon -= decay * epsilon
IMPORTANT: Always add blank lines between code blocks:
def main():
# 打印程序标题
# Print program header
print("=" * 50)
# 创建悬崖行走环境
# Create Cliff Walking environment
env = GridEnv(size=12)
# 设置超参数
# Set hyperparameters
EPISODES = 50
GAMMA = 0.9
Rules:
For complex logic with multiple lines, keep Chinese and English paired line-by-line:
# 使用贝尔曼方程更新Q表:Q(s,a) = r + γ * max Q(s',a')
# Update Q-table using Bellman equation: Q(s,a) = r + γ * max Q(s',a')
# 这里alpha=1,即完全替换旧值(不使用加权平均)
# Here alpha=1, meaning completely replace old value (no weighted average)
# 完整公式应为:Q(s,a) = Q(s,a) + α * [r + γ * max Q(s',a') - Q(s,a)]
# Full formula should be: Q(s,a) = Q(s,a) + α * [r + γ * max Q(s',a') - Q(s,a)]
qtable[state][action] = reward + gamma * max(qtable[next_state])
# 检查是否掉下悬崖(底行,第1-10列)
# Check if agent fell off cliff (bottom row, columns 1-10)
# 原因:悬崖行走问题的核心机制,大负奖励惩罚掉入悬崖
# Reason: Core mechanism of Cliff Walking problem, large negative reward penalizes falling
if self.y == 3 and 1 <= self.x <= 10:
reward = -100
Add bilingual comments above imports:
# 导入抽象基类模块,用于定义环境接口
# Import abstract base class module for defining environment interface
import abc
# 导入操作系统、时间和随机模块
# Import os, time and random modules
import os
import time
import random
# 程序入口点,运行主函数
# Program entry point, run main function
if __name__ == "__main__":
main()
Before finishing:
# File docstring (English only)
"""
Lab 2: Q-Learning Agent
Implements Q-Learning algorithm
"""
# Function docstring (two-line bilingual)
def train(env):
"""训练Q-Learning智能体
Train Q-Learning agent"""
# Inline comment (line-by-line bilingual, above code)
# 初始化Q表,使用随机值
# Initialize Q-table with random values
qtable = [[random.random() for _ in range(env.actions())] for _ in range(env.states())]
# 增加步数计数
# Increment step count
steps += 1
"""
Lab 2: Q-Learning Agent for Cliff Walking
Student ID: 041107730
Implements Q-Learning using Bellman equation
"""
# 导入抽象基类模块,用于定义环境接口
# Import abstract base class module for defining environment interface
import abc
# 导入操作系统、时间和随机模块
# Import os, time and random modules
import os
import time
import random
class Env(abc.ABC):
"""环境抽象基类
Environment abstract base class"""
@abc.abstractmethod
def actions(self) -> int:
"""返回动作空间的大小
Return the size of action space"""
raise NotImplementedError()
def train(env, episodes: int = 50, gamma: float = 0.9) -> list:
"""训练Q-Learning智能体
Train Q-Learning agent"""
# 初始化Q表,使用随机值
# Initialize Q-table with random values
qtable = [[random.random() for _ in range(env.actions())] for _ in range(env.states())]
# 训练主循环,遍历所有回合
# Main training loop, iterate through all episodes
for episode in range(episodes):
# 重置环境,获取初始状态
# Reset environment and get initial state
state = env.reset()
# 使用贝尔曼方程更新Q表
qtable[state][action] = reward + gamma * (qtable[next_state])
qtable
__name__ == :
main()
基于 SOC 职业分类