Befunge Easy · Lesson 1 · On the house

Wrapping the playfield

Edges are a torus. Lesson 1 is free — on the house.

Lessons · Befunge Easy · Lesson 1 of 10 · On the house

Wrapping the playfield

Edges are a torus.

Illustration for the Befunge course
Lesson 1 is on the house. The rest opens with the paper, the Daily, or a gift.

This is Befunge · Easy, lesson 1: Wrapping the playfield. Introductory already gave you directions and the stack. Easy assumes you can steer and push. We build upward into classic Befunge-93 edge behavior.

Classic Befunge-93 uses a fixed playfield — commonly 80 columns by 25 rows. When the instruction pointer walks off the right edge moving east, it reappears on the left of the same row. South off the bottom reappears at the top of the same column. The playfield is a torus for IP motion.

Wrap is not an error. It is a feature. Infinite loops on a single row are often just >@ missing, with the IP wrapping forever. Without @, wrap turns a short line into a ring.

Draw the torus: label columns 0..79 and rows 0..24 in classic lore. Your interpreter may pad or clamp differently — probe a tiny wrap still before you trust a big diagram.

Wrap interacts with # bridges: skipping past the edge still advances one cell in the current direction, which may land on the opposite edge. Simulate wrap before you place bridges near borders.

Self-modifying p writes into coordinates that may themselves be near edges. Coordinate wrap for writes is dialect-sensitive; IP wrap for motion is the reliable classic story for this lesson.

A common trap: placing @ on the opposite edge and assuming the IP will never reach it because "it is off screen." On a torus, off-screen is next door.

Spaces are no-ops. An empty edge cell still advances the IP. Empty borders do not stop wrap — they just delay the next opcode by one step.

When debugging infinite runs, ask first: did I forget @, or did wrap reconnect a path I thought was linear?

Hold Wrapping the playfield as a behavior, not a vocabulary flashcard. Ask: what inputs matter, what action runs, what is visible afterward? If you cannot fill those three slots, you are skimming. Write them in a margin before the quizzes.

When something fails around Wrapping the playfield, change one thing. Read the wrong output. Return to the still. Do not rewrite the whole playfield when one cell is wrong. Calm retries beat dramatic rewrites.

Compare Wrapping the playfield with the nearest habit you know from C, Python, or Forth — and name the difference out loud. Befunge's teaching value is often the delta: familiar family, different ergonomics.

Open-book checks for Wrapping the playfield reward careful reading of this page. The right answer is a claim we actually made about Befunge-93. Near-miss choices sound technical; they fail because they invert the lesson.

Before the still, predict IP position, direction, and stack. After the still, compare. That predict-compare loop is how Wrapping the playfield becomes muscle memory.

Say a one-sentence teaching version of Wrapping the playfield you could give a friend. If the sentence needs five caveats, your mental model is still foggy — tighten it.

Keep a scratch note for Wrapping the playfield: one worked example, one failure you fixed, one sentence of definition. That tiny notebook beats highlighting the same paragraph five times.

Wrong answers on Wrapping the playfield quizzes are teachers too. Read the explain line. Relate it back to the still. A corrected misconception sticks harder than a lucky first guess.

Host-teacher note for Wrapping the playfield: I will not rush you, but I will not dilute the subject either. Read once for the story, once for the mechanism, once with the still under your finger. Three passes beat one skim.

Edge inventory for Wrapping the playfield: list one normal case, one boundary case, and one misuse. Boundaries and misuses are where quizzes live and where playfield bugs breed.

Transfer test for Wrapping the playfield: explain it to a skeptical friend who only knows Python. If they can predict the still's effect from your explanation, you own it.

Practice drill for Wrapping the playfield: change one cell in the still by a small delta, recompute the expected stack and IP by hand, then confirm. Single-delta drills expose off-by-ones faster than rereading.

vwrap

v
 
^
Tiny vertical wrap sketch: south then north on a short column.

ewarn

>  @
Without @ this line would wrap east forever on a torus.

Trace the vertical pair: v sends the IP down; after empty cells, ^ sends it up. On a short playfield the path is a ring until something else intervenes. The second still reminds you that @ is the only reliable stop.

Pitfalls: skim the still without a stack diagram; invent dialect rules not on this page; change three cells at once when debugging.

Quiz

What happens when the IP walks off the right edge moving east in classic Befunge-93?

Quiz

Classic Befunge-93 playfield size lore is often?

Quiz

Without @ on a single-row eastbound program, wrap often causes?

Quiz

Are empty edge cells barriers?

Quiz

Why must you draw wrap when placing # near a border?

Quiz

First debug question for an "endless" tiny program?

Check

Match the vertical wrap still.

Wrap is now a tool, not a surprise. Next: horizontal _ used as a real decision — not just the glyph.

Open-book: the answers are on this page. Pass every quiz and check (7) to mark the lesson done. This visit: 0/7.

Wrapping the playfield · Befunge Easy (free) — The Gold Standard