프랙털 · 카오스 게임

무작위 점프는 왜 완벽한 삼각형을 그릴까

규칙

무작위로 고른 꼭짓점을 향해 절반만큼 점프하기를 되풀이해요. 순수한 우연에서 완벽한 프랙털이 나타나요.

클릭하면 YouTube에서 재생돼요.

라이브 데모 · 브라우저에서 실행

해 보기: 규칙을 바꿔 보세요

3
0.500

순수한 우연, 규칙 하나: 시에르핀스키 삼각형, 절반 크기의 자기 복사본 세 개.

왜 이렇게 될까

삼각형의 세 꼭짓점 중 하나를 무작위로 골라 그쪽으로 절반만큼 점프해요. 그 자리에 점을 찍고 되풀이해요. 점프는 순전히 우연인데도, 몇천 번 뒤에는 시에르핀스키 삼각형이 나타나요. 모든 크기에서 삼각형이 도려내진 삼각형이에요.

xₖ₊₁ = xₖ + r · (꼭짓점 − xₖ)삼각형: r = 1/2오각형: r ≈ 0.618육각형: r = 2/3

직접 만들기

Python 3 · numpy · matplotlib

꼭짓점을 향한 무작위 절반 점프 60,000번, 꼭짓점에 따라 색칠.

chaos-game.py
"""Chaos game: jump a part r of the way to a random corner of a polygon, again and again.
Run: python chaos-game.py   (needs: pip install numpy matplotlib)
"""
import numpy as np
import matplotlib.pyplot as plt

plt.style.use("dark_background")

corners, r, no_repeat = 3, 0.5, False  # triangle, halfway: the Sierpinski triangle
steps = 60000
rng = np.random.default_rng()

angles = np.pi / 2 + 2 * np.pi * np.arange(corners) / corners
vertex = np.column_stack([np.cos(angles), np.sin(angles)])

points, chosen = np.zeros((steps, 2)), np.zeros(steps, dtype=int)
x, last = np.array([0.0, 0.0]), -1
for i in range(steps):
    c = rng.integers(corners)
    while no_repeat and c == last:  # the restricted game: never the same corner twice
        c = rng.integers(corners)
    x = x + r * (vertex[c] - x)  # the whole rule
    points[i], chosen[i], last = x, c, c

plt.figure(figsize=(6, 6))
plt.scatter(points[20:, 0], points[20:, 1], s=0.3, c=chosen[20:], cmap="rainbow")
plt.axis("equal")
plt.axis("off")
plt.show()

# Try: corners, r = 5, 0.618 (a pentagon) or corners, no_repeat = 4, True (a square, restricted)

해 보기: corners = 5와 r = 0.618로 바꾸거나, corners = 4에 no_repeat = True로 해 보세요.

이 스크립트를 한 줄씩, 연습 문제와 퀴즈로 배우기 → · Google Colab에서 실행 (영어) →

선생님을 위해: 45분 수업 지도안과 3단계 활동지 →

영상이 들려주는 수학

영상 노트 보기 (YouTube에서, 영어)

Start anywhere. Pick one of the triangle's three corners at random and jump exactly halfway toward it. Plot the point.

Repeat. Nothing about the choices is planned — a coin, a die, pure chance — and yet after a few thousand jumps the Sierpiński triangle appears, sharp and complete. The reason is that "jump halfway to a corner" is a contraction: it shrinks every distance by half, so wherever the point starts, after a handful of jumps it is pulled onto the one shape that the three half-size copies of itself map back onto — the fractal is the only set the rule leaves unchanged.

Each point here is coloured by the corner it just jumped toward, which is why order seems to grow out of rainbow noise. From the triangle on, only the rule changes: a pentagon with a golden jump of 0.618, a pentagon where the same corner may never be chosen twice in a row, a square where the opposite corner is forbidden, a hexagon with a two-thirds jump. Every new shape is born from the cloud of the previous one, because the walkers simply keep going under the new rule.

Nothing is drawn; everything is counted.

출처: 다음 영상의 설명 The Chaos Game: Pure Randomness Draws a Perfect Fractal (영어).

Shorts

출처