Today a robot writes the code for the robot. You decide if it's right.
Save both in your Karel folder, next to MyKarel.java. Keep the names exactly as they are.
Download AGENTS.md Download CleanRowKarel.java
Already got them from Slack in class? You're set.
# AGENTS.md This is a Karel the Robot project for COSC 10001, a first-year course at TCU. The person asking you for help may never have programmed before. ## Rules for code you write - Every program extends `Karel`, not `SuperKarel`. There is no `turnRight()` or `turnAround()`; if you need one, write it as a private method built from `turnLeft()`. - Use only what the class has learned: `move()`, `turnLeft()`, `pickBeeper()`, `putBeeper()`, the conditions `frontIsClear()`, `frontIsBlocked()`, `leftIsClear()`, `leftIsBlocked()`, `rightIsClear()`, `rightIsBlocked()`, `beepersPresent()`, `noBeepersPresent()`, and `while`, `if`, `else`. - Break every program into small methods with names that say what they do. `run()` should read like a to-do list. - A program must work for every world of the same kind, not only the one in `worlds/`. Never count beepers or steps from a world file. - Put each new program in its own file named after what it does, like `DoubleBeepers.java`. Do not change `MyKarel.java`. ## Checking your work - Compile with `javac -cp lib/karel.jar *.java`. Do not run the program: it opens a window, and the student runs it themselves. - When you finish, explain what you did in two or three plain sentences a beginner can follow.
import stanford.karel.*;
/*
* CleanRowKarel.java
*
* Karel should walk along the row and pick up every beeper in it.
* Load the world long-row.w and press Run. Count what is left.
*/
public class CleanRowKarel extends Karel {
public void run() {
while (frontIsClear()) {
pickUpBeeperIfThere();
move();
}
}
private void pickUpBeeperIfThere() {
if (beepersPresent()) {
pickBeeper();
}
}
}
commit → prompt → review → run → commit
| Save your work first, so you can always get it back | commit |
| Say what you want, in plain English, one step at a time | prompt |
| Read what it wrote. Every line is yours now | review |
| Run it, on more than one world | run |
| Save again, so the history shows what the agent did | commit |
Last week's git restore . is your undo button for anything an agent does.
Standing instructions the agent reads before every task, so you don't repeat yourself in every prompt.
| GitHub Copilot, Codex | AGENTS.md |
| Claude Code | CLAUDE.md, or AGENTS.md if there isn't one |
So one AGENTS.md works for all three.
Each prompt takes the agent a minute or two. That's normal.
Write DoubleBeepers.java. Karel doubles the pile of beepers one step east of him, then comes back to where he started. See worlds/pile.w.
Is it what we wrote? Then: change the pile to seven and run it again.
Write NewspaperKarel.java. Karel walks out of his house to the newspaper, picks it up, and comes back to where he started, facing the same way. See worlds/CollectNewspaperWorld.w.
Read run() first. Can you tell what it does without reading anything else?
Write StaircaseKarel.java. Karel climbs the staircase, putting one beeper on each step, and stops at the top. It should work for a staircase of any height. See worlds/staircase.w.
Before we run it:
how many steps? So how many beepers?
You only catch that if you knew what you expected before you pressed Run. That's the review step.
Don't put a beeper on the floor. Only on the steps.
1. Both files from Slack are in your Karel folder. Commit:
git add . git commit -m "Add the charter and a buggy program"
2. Run CleanRowKarel, then Load World long-row.w. It should pick up every beeper. Count what's left.
3. In a terminal in your Karel folder, start copilot or codex and type:
CleanRowKarel.java should pick up every beeper in the row, but it leaves one behind. Find the bug and fix it.
4. Review: git diff. How many lines changed?
5. Run it on long-row.w and short-row.w
6. Commit and push:
git add . git commit -m "Agent fixes the last beeper" git push
The loop stops when the wall is in front of Karel, and that's before he checks the last square.
No error. No complaint. Just one beeper left behind.
The most common bug in programming, and now you've fixed one.
| CS Engagement, first reflection. One event, 250 words | Wed, Sep 30 |
| Professional Foundations. Step-by-step on the site; email it to your peer mentor | Wed, Sep 30 |
| Tell your pod which Ship-It project you picked | Wed, Sep 30 |
| Build Checkpoint 1. Your Karel repo, a world you built, an agent commit (today's counts), NOTES.md | Wed, Oct 7 |
That part doesn't get automated.