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` に由来する、グリッドにランダムな対角線を引くシンプルなパターン生成。
コード
上のデモの実際のスケッチ(サンドボックスで再現可能)。これで全部です。
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 タイルと出現比率に一般化できる。
パラメータ
gridSize: number — Number of cells per side.cellSize: number — Pixel size of each cell.probability: number — Chance of drawing "/" vs "\\" in each cell (the 10 PRINT coin flip).charSet: array — The two glyphs alternated (classically the forward/back slash).
系譜
よく組み合わされるアルゴリズム
- Perlin / Simplex Noise · 2 作品
- HSL / Hue Cycle · 2 作品
- Particle System · 1 作品
- Quadtree / Recursive Quad Split · 1 作品
- Flow Field / Vector Field · 1 作品
- Bezier / Catmull-Rom Splines · 1 作品
- Truchet Tiles · 1 作品
このアルゴリズムを使う作品 (4)
参考文献
最終更新 2026-07-16