CS0502
Vibe CodingIntroduction to AI
and Computer
Science
A project-based introduction to computer science where students learn through vibe coding: directing AI agents to build, test, and explain working computational systems.
Course overview
The essentials for Fall 2026.
课程信息 · Course details
Introduction to Computer Science
计算机科学导论
- Course code
- CS0502
- Term
- Fall 2026
- Class time
- Mon 16:00–17:40
Thu 10:00–11:40 (odd weeks only / 仅单周) - Room
- 东中院 2-203
- Instructor
- 袁肖赟 · Xiaoyun Yuan
yuanxiaoyun@sjtu.edu.cn - Teaching assistants
- 季飞宇 · Feiyu Ji
jownr25@sjtu.edu.cn
陈敏冲 · Minchong Chen
chenminchong@sjtu.edu.cn - Course platform
- Canvas — course materials, references, submissions, group projects, and recordings. Please follow the course site for current deadlines and schedule updates.
评分构成 · Assessment
How the course is assessed.
课后作业(3 次)
小组项目(3–5 人)
期末考试
课堂表现
Topics · 课程主题
- Programming, data structures & algorithms
- Architecture, operating systems & software engineering
- Networks, security, databases & visualization
- AI, machine learning, computer vision & frontiers
Tentative schedule: Sep 14–Dec 28, 2026. 日程可能根据教学进度调整,请以课程网站为准。
Course tutorials
Learn the agent workflow before you build.
01 OpenCode video tutorials 通过这组视频,熟悉用 AI coding agent 进行对话、迭代和调试的基本流程,再开始课程项目。 Use this video series to learn the basic workflow of talking with, iterating with, and debugging through an AI coding agent before beginning the course projects.
建议在开始第一个项目之前观看。视频会帮助你建立一次对话不够、需要持续发现问题并让 agent 改进的工作方式。
We recommend watching this before Project 01. It introduces a working rhythm in which one conversation is not enough: notice issues, then guide the agent through focused improvements.
02 Sequential List Visual Lab 用连续内存、base、i 和 n 指针,观察顺序表在访问、查找、插入和删除时如何移动。 Explore contiguous memory, base, i, and n pointers while visualizing access, search, insertion, and deletion in a sequential list.
面向数据结构导论课堂的交互式演示。点击操作按钮,或打开“逐步执行”,观察内存格和指针的变化。
An interactive classroom demo for the introduction to data structures. Choose an operation or use step-by-step mode to inspect memory cells and pointer changes.
Course projects
Learn to program by talking to computers.
01 图灵机 与 AI coding agent 一起构建可运行、可检查的图灵机,用测试用例验证,并记录从输入到停机的完整过程。 Build a working, inspectable Turing machine with an AI coding agent, verify it with test cases, and record the complete run from input to halt.
使用下方提示词与 coding agent 多轮迭代,并提交可运行 HTML、简短录屏和图文迭代报告。
Use the prompt below, iterate with your coding agent, and submit a runnable HTML file, a short recording, and an illustrated iteration report.
提交内容
完成你的图灵机项目
- 01用 AI agent 完成图灵机。
不要自己手写代码;通过与 AI coding agent 对话,做出一个能运行、能复现课堂指定算法的图灵机,并提交可直接运行的 HTML 文件。
- 02提交一段运行录屏。
除 HTML 文件外,再提交一段简短录屏,展示输入、运行过程和最终结果。
- 03提交图文并茂的迭代报告。
一次对话通常不够。请记录每一轮对话得到的结果、发现的问题、你再次输入的提示词,以及该轮解决了什么;尽量附上界面或运行截图。
- 04扩展功能可获得加分。
完成基本功能即可获得基础分。在此基础上实现额外功能,例如扩展图灵机的能力、增加更丰富的交互或更多算法演示,可获得加分。
- 01Build the Turing machine with an AI agent.
Do not hand-code the project yourself. Work through conversations with an AI coding agent to create a runnable machine that reproduces the algorithm assigned in class, then submit the runnable HTML file.
- 02Submit a short run recording.
Alongside the HTML file, submit a short screen recording that shows an input, the execution, and the final result.
- 03Submit an illustrated iteration report.
One conversation is usually not enough. For every round, record the result, the problem you noticed, the next prompt you entered, and what that round solved; include interface or run screenshots wherever possible.
- 04Extensions can earn bonus credit.
Completing the core functionality earns the base score. Extra features—such as extending the machine, adding richer interactions, or demonstrating more algorithms—can earn bonus credit.
Agent 提示词
把这段提示词交给你的 coding agent
请生成一个可直接运行的图灵机模拟器网页,保存为一个单独的 HTML 文件。
## 最重要要求
这个 HTML 文件必须能直接双击打开使用,不需要安装任何软件,不需要运行任何命令,不需要本地服务器,不需要联网。
- 所有代码、样式、资源全部内联在这个 HTML 文件里
- 不许使用 <script type="module">
- 不许从网络加载任何内容(完全离线可用)
- 不许写任何需要用户额外操作的代码
## 技术方案
用 React 18 实现(它有 UMD 格式,可以直接内联到 HTML 中)。
React 和 ReactDOM 的 UMD 文件从 https://unpkg.com/react@18/umd/ 下载后内联。
用 esbuild 的 build() API 将源码打包成 IIFE 格式内联到 HTML。
jsx 用经典模式(React.createElement),不要用 automatic JSX runtime。
所有 CSS 内联在 <style> 标签中。
Lucide 图标用内联 SVG 替代,不要引入图标库。
## 功能要求
制作一个交互式图灵机模拟器,面向大学课堂投影教学,中文界面。
### 核心界面
页面打开后直接显示模拟器(不要宣传首页)。第一视觉重点是横向纸带。每个格子显示一个符号,当前格子高亮,读写头在格子上方。
纸带可以向左右无限扩展(内部用 Map<number, string> 实现,只渲染读写头周围 15 格的窗口)。
纸带上方显示状态寄存器,包括:当前状态、当前读取符号、执行步数、运行状态(就绪/运行中/已暂停/接受/拒绝/已停机/错误)。
### 控制功能
- Demo 选择菜单(三个内置示例)
- 输入字符串 + 应用输入按钮
- 重置按钮
- 单步执行按钮
- 连续运行 / 暂停按钮
- 后退一步按钮
- 执行速度滑块
- 转移规则表(支持添加、删除、编辑规则,检查重复规则)
- 执行日志(显示中文步骤说明和形式化 δ 规则)
- 自定义图灵机编辑器(编辑状态集、字母表、规则等)
- 导入 / 导出 JSON 文件
### 特殊符号约定
- ⊢ 输入左边界;⊣ 输入右边界;□ 空白符
- 初始状态 q0;接受状态 q_accept;拒绝状态 q_reject
- 支持 L(左移)、R(右移)、S(不动)三种移动
- 如果当前状态+读取符号没有对应规则,显示“未定义转移”并停机(不许报错)
- 设置最大执行步数(如 1000 步)防止无限循环
### 三个内置示例
1. 一进制加法:输入 11101111(表示 3+4),运行后得到 1111111。动画展示扫描第一个操作数、删除分隔符、扫描第二个操作数、停机。
2. 二进制加一:输入 1011 输出 1100,111 输出 1000。正确处理进位和全 1 的情况。
3. 二进制回文识别:1001 进入接受状态,1010 进入拒绝状态。展示标记首尾字符、来回扫描的过程。
### 动画效果
每一步的动画按顺序播放:读取高亮→规则高亮→写入淡入淡出→读写头移动→状态更新。
连续运行时也必须按阶段播放,不能直接跳到最终结果。速度滑块能明显控制动画快慢。后退一步能恢复纸带、读写头和位置。
### 教学反馈
执行日志显示可读的中文步骤,同时显示形式化规则,例如:
δ(q0, 1) = (q1, 0, R)
停机后显示结果摘要:是否接受、总步数、最终状态、最终纸带内容、停机原因。
### 自定义模式
用户可以编辑:状态集合、输入字母表、纸带字母表、空白符、左右边界符、初始状态、接受状态、拒绝状态、初始纸带内容、读写头初始位置、转移规则。
支持用表格编辑规则,也支持粘贴文本格式的规则(如 q0,1 -> q1,0,R)。修改配置后可以立即重置并运行。
## 工程质量
- 不要把所有代码写在一个组件里,保持代码结构清晰
- 图灵机执行引擎要写成独立的模块,与界面分离
- 页面不能有文字重叠、按钮溢出或纸带格子变形
- 按钮用图标+文字,适配电脑和平板屏幕
- 为图灵机引擎写单元测试,覆盖三个示例的预期结果、负坐标移动、空白格读写、未定义规则、后退恢复和最大步数停止
- 不要留下 TODO、占位按钮或不可用功能
- 运行测试确认全部通过
Create a fully runnable interactive Turing Machine simulator as a single HTML file.
## Most important requirements
The HTML file must work by double-clicking it directly. It must not require software installation, commands, a local server, or an internet connection.
- Inline every piece of code, styling, and asset in this one HTML file.
- Do not use <script type="module">.
- Do not load anything from the network; it must work completely offline.
- Do not require any extra action from the user beyond opening the file.
## Technical approach
Build it with React 18 using its UMD build, which can be inlined directly in HTML.
Download the React and ReactDOM UMD files from https://unpkg.com/react@18/umd/ and inline them.
Use esbuild's build() API to bundle the source into an IIFE and inline it.
Use classic JSX mode (React.createElement), not the automatic JSX runtime.
Put all CSS in a <style> tag.
Replace Lucide icons with inline SVG; do not import an icon library.
## Functional requirements
Create an interactive Turing Machine simulator for Chinese university classroom projection. The interface language should be Chinese.
### Main interface
Open directly to the simulator, with no marketing landing page. Make the horizontal tape the primary visual focus. Each cell shows a symbol, the current cell is highlighted, and the read/write head sits above it.
The tape must expand infinitely in both directions (use Map<number, string> internally and render only a 15-cell window around the head).
Above the tape, show registers for: current state, currently read symbol, step count, and status (ready / running / paused / accepted / rejected / halted / error).
### Controls
- Demo picker with three built-in examples
- Input string and Apply Input button
- Reset
- Single step
- Run / Pause
- Step back
- Speed slider
- Transition-rule table with add, delete, edit, and duplicate-rule detection
- Execution log with readable Chinese steps and formal δ rules
- Custom Turing-machine editor for states, alphabets, and rules
- JSON import and export
### Symbol conventions
- ⊢ is the left input boundary, ⊣ the right input boundary, and □ the blank symbol.
- Initial state q0, accepting state q_accept, rejecting state q_reject.
- Support L, R, and S moves.
- If no rule exists for the current state and symbol, show “未定义转移” and halt without throwing an error.
- Add a maximum-step setting (for example 1000) to prevent infinite loops.
### Three built-in examples
1. Unary addition: input 11101111 represents 3+4 and must produce 1111111. Animate scanning the first operand, deleting the separator, scanning the second operand, and halting.
2. Binary increment: 1011 becomes 1100 and 111 becomes 1000. Correctly handle carry and all-ones inputs.
3. Binary palindrome recognition: 1001 accepts and 1010 rejects. Show marking the first and last characters and scanning back and forth.
### Animation
For every step, animate in this order: read highlight → rule highlight → write fade → head movement → state update.
Continuous running must preserve these phases rather than jumping to the final result. The speed slider must clearly affect the animation speed. Step back must restore the tape, head, and state.
### Teaching feedback
The execution log must show readable Chinese descriptions and formal rules, for example:
δ(q0, 1) = (q1, 0, R)
After halting, show a result summary: accepted or not, total steps, final state, final tape content, and halt reason.
### Custom mode
Allow editing the state set, input alphabet, tape alphabet, blank symbol, boundary symbols, initial state, accepting state, rejecting state, initial tape, initial head position, and transition rules.
Support both a table editor and pasted textual rules such as q0,1 -> q1,0,R. After editing, the configuration must be resettable and runnable immediately.
## Engineering quality
- Do not put all code in one component; keep the code structure clear.
- Implement the Turing-machine engine as a separate module from the interface.
- Avoid overlapping text, overflowing buttons, and distorted tape cells.
- Use icon-plus-text buttons that work on desktop and tablet screens.
- Write unit tests for the engine covering all three example results, negative-coordinate movement, blank reading and writing, undefined transitions, undo restoration, and maximum-step stopping.
- Leave no TODOs, placeholder buttons, or nonfunctional controls.
- Run the tests and confirm that all pass.
使用完整提示词作为起点,与 coding agent 多轮对话、测试并解释你最终完成的实现。Use this prompt as a starting point, continue the dialogue with your coding agent, then test and explain the implementation you produce.
三个示例结果
Three example results
三个示例实现
使用上方提示词,与 coding agent 继续对话,做出你自己的版本。
Use the prompt above, continue the dialogue with your coding agent, and build your own version.
02 校园寻路项目 使用校园地图项目资料,与 AI coding agent 对话,把它逐步改造成你自己的数据结构与寻路项目。 Turn the campus-map project materials into your own data-structures and pathfinding studio, using conversations with an AI coding agent.
本项目提供项目网页、任务说明和建议提示词;请自行设计并迭代与 AI coding agent 的对话策略。没有参考实现。
This project provides a project web page, a task brief, and suggested prompts. Design and iterate on your own conversations with an AI coding agent; no reference implementation is provided.
项目任务
完成校园寻路项目
- 01完成核心数据结构。
为校园地点实现数组、链表、二分查找和二叉搜索树。
- 02完成图搜索与最短路。
从提供的图数据建立邻接表,并完成 BFS 与 Dijkstra;可由 AI agent 自行实现或选用合适的图算法库。
- 03在项目资料上迭代。
保持地图数据不变,用自己的 AI agent 对话完成和改进项目。完整顺序见任务说明。
- +1扩展更高级算法。
可实现哈希表、A* 等扩展算法;如实现 A*,在报告中与 Dijkstra 比较理论差异和实验结果。
- +2优化 Web app。
对可视化、交互或整体使用体验做出实质改进,可获得额外加分。
- 01Implement the core data structures.
Build array search, linked lists, binary search, and a binary search tree for campus places.
- 02Implement graph search and shortest paths.
Construct an adjacency list from the supplied data, then complete BFS and Dijkstra. Your AI agent may implement them or choose an appropriate graph-algorithm library.
- 03Iterate from the project materials.
Keep the map data unchanged, then use your own AI-agent conversations to build and improve the project. The brief gives the full sequence.
- +1Extend with advanced algorithms.
Possible extensions include a hash table, A*, and more. If you implement A*, compare its theoretical differences and experimental results with Dijkstra.
- +2Improve the web app.
Substantial improvements to the visualization, interactions, or overall experience can earn additional bonus credit.
提交内容
需要提交什么
- 01基础任务:可运行项目。
提交完成后的完整网页文件夹或压缩包;无需提交代码仓库。它应能直接打开,并展示所有基础数据结构与 BFS、Dijkstra 功能。
- 02基础任务:运行录屏。
提交简短录屏,展示地点查找、起终点选择、寻路过程与结果。
- 03基础任务:图文迭代报告。
记录每轮与 AI agent 的对话结果、发现的问题、后续提示词、解决方案和关键截图;说明算法原理、各数据结构的优势、不同算法的比较,并用实验结果支撑结论。
- +1 / +2加分内容。
可扩展哈希表、A* 等更高级算法;Web app 优化也可加分。所有加分内容都需在录屏和报告中清楚展示。
- 01Core: runnable project.
Submit the completed web folder or a ZIP—no code repository is required. It must open directly and demonstrate all core structures plus BFS and Dijkstra.
- 02Core: run recording.
Submit a short recording that shows place search, start/end selection, pathfinding, and the result.
- 03Core: illustrated iteration report.
For each AI-agent round, record the result, issue found, follow-up prompt, resolution, and key screenshots. Explain algorithmic principles, the advantages of each data structure, comparisons between algorithms, and conclusions supported by experimental results.
- +1 / +2Bonus work.
Extend the project with advanced algorithms such as a hash table or A*; web-app improvements can also earn credit. Show all bonus work clearly in both the recording and report.
项目网页中的查找与寻路算法尚未实现。选择起终点后点击“运行寻路”,页面会明确提示“算法尚未实现”;这正是你需要完成的部分。
The project web page does not implement search or pathfinding algorithms yet. After selecting endpoints, clicking “Run pathfinding” clearly reports that the algorithm is not implemented; that is the work you will complete.
03 PeerDrop 在可信局域网中的两台独立设备之间,构建一个具有加密、认证和完整性校验的真实文件传输系统。 Build a real file-transfer system between two devices on a trusted local network, with encryption, authentication, and integrity verification.
本项目不提供完整提示词或参考实现。请自行设计与 AI coding agent 的协作策略、技术方案和测试方法。
This project provides no complete prompt or reference implementation. Design your own AI-agent collaboration, technical approach, and testing strategy.
Project task
Build secure local-network file transfer
- 01完成真实跨设备传输。
两台独立设备在同一可信局域网中;手动输入接收端 IP 地址与端口,发送并保存一个真实文件。
- 02用混合加密保护文件。
使用成熟密码学库:随机文件密钥加密文件,接收端 RSA 公钥加密该文件密钥;接收端用私钥恢复文件密钥并解密。
- 03认证并校验传输。
发送端对 SHA-256 摘要进行 RSA 签名;接收端验证签名后才解密。解密后比较原始文件与接收文件的 SHA-256。
- 01Transfer one real file across two devices.
Use two independent devices on one trusted local network. Enter the receiver’s IP address and port manually, then send and save a real file.
- 02Protect the file with hybrid encryption.
Use mature cryptographic libraries: a random file key encrypts the file, while the receiver’s RSA public key encrypts that file key; the receiver restores it with the private key before decrypting.
- 03Authenticate and verify the transfer.
The sender signs a SHA-256 digest with RSA; the receiver verifies the signature before decryption, then compares SHA-256 for the original and received files.
What to submit
Runnable project, real demo, and iteration report
- 01基础:可运行项目与完整代码。
提交包含全部 HTML、Python 与其他源代码的完整项目文件夹或 ZIP,以及 README;代码必须足以复现演示结果。
- 02基础:双设备录屏。
用 60–120 秒展示真实传输、签名验证、解密、SHA-256 比对和最终保存结果。
- 03基础:图文迭代报告。
记录 AI agent 对话、问题、后续提示词、解决方案和截图;解释 RSA 公钥/私钥、文件密钥、SHA-256、签名,以及保密性、认证和完整性的区别。
- +1 / +2加分:可靠性与体验扩展。
配对码与接受/拒绝、传输状态和进度、错误处理、自动发现、历史记录、多文件队列等均可加分。
- 01Core: runnable project and complete source code.
Submit the full project folder or a ZIP containing all HTML, Python, and other source code, plus a README. The code must reproduce the demonstrated result.
- 02Core: two-device recording.
In 60–120 seconds, show a real transfer, signature verification, decryption, SHA-256 comparison, and the saved result.
- 03Core: illustrated iteration report.
Record AI-agent rounds, issues, follow-up prompts, resolutions, and screenshots. Explain RSA public/private keys, the file key, SHA-256, signatures, and the difference between confidentiality, authentication, and integrity.
- +1 / +2Bonus: reliability and experience.
Pairing and accept/reject, transfer status and progress, error handling, automatic discovery, history, and multi-file queues can earn bonus credit.
项目网页只提供界面参考,不包含真实传输或密码学功能。建议先体验 LocalSend,观察成熟局域网传输产品的交互与边界;仅在自己控制的设备和可信局域网中测试,不要暴露到公网或传输敏感文件。
The project web page is an interface reference only; it contains no real transfer or cryptographic implementation. Try LocalSend first to observe a mature local-network transfer product’s interactions and boundaries. Test only on devices and trusted local networks you control; never expose it to the public internet or transfer sensitive files.
04 Foundations of Artificial Intelligence 三选一:从数据挖掘、神经网络与深度学习、微型语言模型三个固定项目中选择一个,完成自己的 AI 应用。 Choose exactly one of three fixed projects—data mining, neural networks and deep learning, or small language models—then build your own AI application.
这是个人三选一项目:从 A、B、C 三个固定项目中选择一个独立完成。教师提供题目、数据或模型说明;不提供完整 AI 提示词,也没有参考实现。
This is an individual choose-one-of-three project. Select exactly one fixed project—A, B, or C. The instructor provides the task, data, or model notes; no complete AI prompt or reference implementation is provided.
Choose exactly one of three projects
Build your AI project with an AI agent
- A零售客户分群与洞察。
从交易数据构建 RFM 特征,以 K-Means 分群;展示群体画像、业务建议,以及一种不同设置下的对照结果。
- B手机活动识别:MLP 与一维 CNN。
用 UCI HAR 同时训练 MLP 与一维 CNN;比较准确率、混淆矩阵和一组容易混淆的活动。
- CMiniMind:部署、多模态与新闻 LoRA。
在三个 MiniMind 任务中任选两个完成:运行基础 MiniMind-3、部署 MiniMind-O 多模态 WebUI,或微调“财经/体育/游戏”新闻主题 LoRA;每项均须提交运行证据与简短分析。
- ARetail customer segmentation and insights.
Construct RFM features from transaction data and cluster with K-Means; show segment profiles, business suggestions, and one changed-setting comparison.
- BSmartphone activity recognition: MLP vs. 1D CNN.
Train both an MLP and 1D CNN with UCI HAR; compare accuracy, confusion matrices, and one easily confused activity pair.
- CMiniMind: deployment, multimodality, and news LoRA.
Complete any two of three MiniMind tasks: run base MiniMind-3, deploy the MiniMind-O multimodal WebUI, or fine-tune a finance/sports/gaming news-topic LoRA. Every task needs run evidence and a short analysis.
What to submit
Runnable app, complete code, and illustrated report
- 01完整项目与代码。
提交包含 HTML、Python 与其他源代码的完整项目文件夹或 ZIP、可运行 App 和 README。
- 02项目录屏。
展示程序实际运行、主要结果,以及所选项目要求的模型或设置比较。
- 03图文项目报告。
说明数据、方法、结果、AI agent 迭代、问题、局限性或失败案例;按所选项目要求完成解释与分析。
- +1扩展实验或交互。
完成所选项目中列出的加分实验、错误分析、可视化或网页交互改进。
- 01Complete project and code.
Submit the full project folder or ZIP containing HTML, Python, and other source code, plus a runnable app and README.
- 02Project recording.
Show the app running, its main results, and the model or setting comparison required by your selected project.
- 03Illustrated project report.
Explain data, method, results, AI-agent iteration, problems, and a limitation or failure case; complete the project-specific analysis.
- +1Extended experiments or interaction.
Complete a listed bonus experiment, error analysis, visualization, or web-interaction improvement from your selected project.
完整提示词仅供助教验证项目可行性,学生不提供也不应索取。请自行设计提示词,并在报告中记录自己的对话与迭代过程。
Complete prompts are kept only for staff feasibility checks; they are neither provided to nor expected from students. Design your own prompts and record your dialogue and iteration in the report.
Course feedback
Help improve the next iteration.
Share course feedback
欢迎反馈教程、项目说明、课程节奏或遇到的问题。请登录飞书后填写这份简洁问卷,帮助我们持续改进这门课。
Share feedback on the tutorials, project briefs, course pacing, or an issue you encountered. Sign in to Feishu to complete this short questionnaire and help us improve the course over time.
请勿填写密码、API key、访问令牌或其他敏感内容。
Do not include passwords, API keys, access tokens, or other sensitive content.