10 PRINT

初出 1982 — The Commodore 64 one-liner "10 PRINT CHR$(205.5+RND(1));" (1982); see the book "10 PRINT", 2012. · 年表 ↗

コミュニティ・通称 名称 — Commodore 64 のワンライナー「10 PRINT CHR$(205.5+RND(1));」(1982) そのものから採られた 通称。2012 年の書籍『10 PRINT』(Montfort ほか) が固有名として正典化した。

ひとことで Commodore 64 の `10 PRINT CHR$(205.5+RND(1));:GOTO 10` に由来する、グリッドにランダムな対角線を引くシンプルなパターン生成。

10 PRINT · Open in new tab ↗ · Motion begins only when you press Run.

コード

上のデモの実際のスケッチ(サンドボックスで再現可能)。これで全部です。

ten-print/index.html
const SEED = Math.floor(Math.random()*1e9);

function setup() {
  randomSeed(SEED);
  const s = Math.min(windowWidth, windowHeight);
  createCanvas(s, s);
  background(15);

  // 10 PRINT CHR$(205.5+RND(1)); : GOTO 10
  // Each grid cell draws one of two diagonals at 50/50. The maze-like
  // structure is an emergent side effect of how adjacent diagonals connect.
  const N = 22;
  const cs = width / N;
  stroke(240);
  strokeWeight(cs * 0.18);
  strokeCap(SQUARE);

  for (let i = 0; i < N; i++) {
    for (let j = 0; j < N; j++) {
      const x = i * cs, y = j * cs;
      if (random() < 0.5) line(x, y, x + cs, y + cs);   // "\"
      else                line(x, y + cs, x + cs, y);    // "/"
    }
  }
}

デモのソースを開く ↗

仕組み

グリッドをセル順(左→右・上→下、折り返し)に走査し、各セルでコインを投げて 2 つの対角文字「╱」か「╲」のどちらかを描く。C64 では CHR$(205.5+RND(1)) が 205.5+乱数(0〜1)を丸めて PETSCII の 205 か 206(2 つの対角文字)になり、": GOTO 10" で無限ループする。面白さは創発的で、ランダムな対角線が全体計画なしに連続した迷路状の通路につながる。任意の相補的 2 タイルと出現比率に一般化できる。

パラメータ

系譜

関連
Cellular Automata、Truchet Tiles

よく組み合わされるアルゴリズム

このアルゴリズムを使う作品 (4)

D-D-Dots
tuplart
Gravity Grid
eliya-stein
ilumz
wolffia-inc-motus-art
Undercover
artplusbrad

参考文献

最終更新 2026-07-16