patterns — trails

generator verdict no votes yet
source — gen_b.g10_trails
def g10_trails(rng):
    """TRAILS — many random walkers cross a wrapping grid. Each cell climbs the
    density ramp per visit, so the pattern is a record of its own traffic:
    worn paths go solid, untravelled ground stays open."""
    N = 40
    c = Canvas(N, "GLYPH", "glyph", "trails", tiles=True)
    NX, NY = c.cols, c.rows
    R = FULL_RAMP
    hits = [[0] * NY for _ in range(NX)]
    walkers = rng.randint(60, 150)
    steps = rng.randint(120, 320)
    inertia = rng.uniform(0.55, 0.92)
    dirs = [(1, 0), (-1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
    for _ in range(walkers):
        x, y = rng.randrange(NX), rng.randrange(NY)
        d = rng.choice(dirs)
        for _ in range(steps):
            if rng.random() > inertia:
                d = rng.choice(dirs)
            x = (x + d[0]) % NX
            y = (y + d[1]) % NY
            hits[x][y] += 1
    mx = max(max(r) for r in hits) or 1
    bias = rng.uniform(0.28, 0.45)
    for i in range(NX):
        for j in range(NY):
            t = (hits[i][j] / mx) ** bias
            k = int(round(t * (len(R) - 1)))
            if R[k] != " ":
                c.glyph(i, j, R[k])
    return c
trails-glyph-40-4739
trails-glyph-40-4739
trails-glyph-40-ce4d
trails-glyph-40-ce4d
trails-glyph-40-1b56
trails-glyph-40-1b56
trails-glyph-40-dad1
trails-glyph-40-dad1
trails-glyph-40-6474
trails-glyph-40-6474
trails-glyph-40-2756
trails-glyph-40-2756
trails-glyph-40-a77d
trails-glyph-40-a77d
trails-glyph-40-2dc4
trails-glyph-40-2dc4
trails-glyph-40-32ac
trails-glyph-40-32ac
trails-glyph-40-8c1f
trails-glyph-40-8c1f
trails-glyph-40-47ec
trails-glyph-40-47ec
trails-glyph-40-d2d6
trails-glyph-40-d2d6
trails-glyph-40-ea39
trails-glyph-40-ea39

generator